6. SBUS model aircraft remote control 6.1. Purpose of the experiment 6.2. Configuration pin information 6.3. Analysis of the experimental flow chart 6.4. core code explanation 6.5. Hardware connection 6.6. Experimental effect
Use the serial communication of STM32 to analyze the SBUS protocol data transmitted by the remote control transmitter of the model aircraft, and print the value of each channel.
According to the schematic diagram, SBUS is connected to the RX pin of serial port 2, only receiving but not sending.
USART1_Init(): Initialize the serial port related content, open serial port 1 and serial port 2 to receive 1 data.
Among them, SBUS_ALL_CHANNELS controls the number of channels parsed. By default, only eight channels are displayed. If full channel display is required, modify it to 1.
Because SBUS communication needs to connect the SBUS receiver to the SBUS interface on the expansion board, S is connected to the signal, V is connected to the positive pole of the power supply, and G is connected to the ground. Therefore, you need to prepare your own model aircraft remote control and SBUS receiver, pair them in advance and turn on the power switch.
After programming the program, the LED light flashes every 200 milliseconds. After connecting the expansion board to the computer through the micro-USB data cable, open the serial port assistant (the specific parameters are shown in the figure below), and you can see that the model aircraft remote control has been printed on the serial port assistant. The data of each channel of the controller, when we manually toggle the joystick or button of the model aircraft remote controller, the data will change accordingly.