Skip to content

Latest commit

 

History

History
122 lines (84 loc) · 4.18 KB

File metadata and controls

122 lines (84 loc) · 4.18 KB

ShunkoBot_STM32

Firmware project for STM32 microcontrollers developed with STM32CubeIDE. The code was written to be soft real time, the code here is non-blocking with use of interrupts and dma.

section divider

Folder Structure

Core/
├── Inc/                      # Shared header files
├── Src/                      # Source code
│   ├── Controls/             # Actuators control
│   │   ├── end_eff_gpio.c
│   │   ├── nidec_h24.c
│   │   └── servo.c
│   ├── Encapsulation/        # For better modularity
│   │   ├── loops.c           
│   │   └── setup.c
│   ├── Exceptions/           # Software exception handling
│   │   └── sw_exceptions.c
│   ├── Periphs/              # Hardware peripheral drivers
│   │   ├── encoder.c
│   │   ├── led.c
│   │   └── icm20948.c
│   ├── Processing/           # Application logic and algorithms
│   │   ├── pid.c
│   │   ├── sw_crc.c
│   │   └── uart_processing.c
│   └── main.c                # Application entry point
└── Startup/                  # Startup code generated by STM32CubeIDE

section divider

Requirements

  • IDE: STM32CubeIDE (latest version recommended)
  • Toolchain: GCC for ARM Embedded
  • Debugger: ST-Link (v2 or v3)
  • Target board: STM32 NUCLEO F446RE
  • Operative System: Bare metal

Import into STM32CubeIDE

  1. Open STM32CubeIDE
  2. Go to File > Import > Existing Projects into Workspace
  3. Select the cloned project folder and then Stm32Code
  4. Click Finish

Build and run

  1. Connect your STM32 board to the PC via USB
  2. Select the debug configuration
  3. Press Run or Debug to flash the firmware

Module Details

main.c

Contains the main() function and main system initialization. In the while (1) there is code that is interrupt driven without the stringent need to be inside the timers.

Controls/

  • end_eff_gpio.c: GPIO control for end-effector actuators.
  • nidec_h24.c: Brushless motor control for NIDEC H24.
  • servo.c: Servo Motor Control.

Encapsulation/

  • loops.c: File that contains the functions in control or check loops.
  • setup.c: File that contains all the setup functions required by the code.

Exceptions/

  • sw_exceptions.c: Handling of custom software exceptions

Periphs/

  • encoder.c: Library for encoder reading.
  • led.c: LED control.
  • icm20948.c: Library for icm20948 IMU sensor (and ak09916) via I2C.

Processing/

  • pid.c: PID control algorithm implementation.
  • sw_crc.c: Software CRC calculation (for packet verification).
  • uart_processing.c: UART command parsing and handling.

section divider

STM32 Logic Design Scheme

The image below shows a flow chart representing the main logic implemented in the STM32 firmware code.

Shunko_Bot STM32 Scheme

section divider

Additional Info

To calibrate the icm20948, click here.

You can check out the pinout configuration at this link.

If you are interested in learning more, you can find detailed explanations in the code itself and in the full project report!

section divider

License

Shunko_Bot © 2025 by Francesco Stasi, Davide Tonti, Simona Vatinno is licensed under Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International


Contact

For issues or requests, please open a GitHub issue.