STM32F103-Robot

🎉 A quadruped crawling robot based on STM32F103C8T6 🎉

project introduction

Using STM32F103C8T6 as the main controller, combined with ESP32-CAM and MQTT, to achieve real-time image feedback and remote control.

Two solutions, cloud control and local control, were used for the control of the robot. The mobile app written by Flet can communicate with EMQX installed on the server through MQTT protocol. The commands transmitted through the cloud are received by ESP32-CAM and transmitted to the microcontroller through USART2. The microcontroller can then control the module based on the commands to make the robot perform corresponding actions. The video stream captured by ESP32-CAM will be uploaded to the server in real time, and after being received by the Nodejs Server deployed on the server, it will be presented through a webpage, thus realizing the entire process of cloud control.

Local control, on the other hand, is realized by Microdot, which accesses the local control panel by accessing a specified IP after connecting to a hotspot issued by the ESP32-CAM. The ESP32-CAM can be controlled by clicking a button on the web page, and the ESP32-CAM sends commands to the Microdot through the serial port. The image stream returned by the ESP32-CAM will be displayed in real time on top of the local control panel via WIFI.

The repository contains all the code needed for this project, which also includes the 3D modeling files for the robot.

Project design process

The structural design of the quadruped crawling robot was carried out using the open-source software FreeCAD. Based on the size of the MG90S servo motor, grooves and screw mounting holes have been designed in the legs. A battery installation hole is reserved in the middle of the body, and screw holes are also designed at key positions to make the structure more sturdy and convenient for later installation.

After the modeling is completed, use slicing software to slice the model and import the slicing results into a 3D printer for printing. The filling density is 0.1mm, the layer thickness is 0.2mm, and the extrusion head temperature is set to 210 ℃. The printing material selected is PLA material with a diameter of 1.75mm. Screw holes are reserved on the power board for installing nylon columns. Each functional module is connected by a universal circuit board and stacked on top of the body through nylon columns, making it convenient for quick loading, unloading, and debugging.

The power module of the quadruped crawling robot uses TI's TPS5430, which was referenced in the design Electric competition module: TPS5430 positive and negative power output module. Three power sources are designed on the power module to supply power to the servo and the main control and functional modules.

After the robot is powered on, the first step is to initialize the functional modules and related peripherals, while also initializing FreeRTOS. The subsequent tasks are then handed over to FreeRTOS for scheduling. Before receiving a command from USART2, the microcontroller executes the default task. In the default task, the robot always remains in a stopped state, waiting for commands sent by the user. After receiving the command in USART2, the microcontroller will enter the serial interrupt program and determine the specific meaning of the instruction within the interrupt program, and execute the corresponding task based on the instruction content.

When USART2 receives a message from ESP32-CAM, the microcontroller will execute the interrupt function of USART2 to evaluate the received information. Firstly, create an array in the code to set a buffer, and use HAL library functions to store the received data in the buffer. Then, match the contents of the buffer to determine if it is the corresponding command.

In the code, it is first determined whether the task being executed by the current robot is already activated. If it is, it is skipped directly...

Read more »