Serial port control servo

1. Learning objectives

Drive 180 degree servo through the serial port of 16-way servo driver board

2. Hardware connection

The servo used in this case is a 180 degree servo, which is connected to the S1 pin of the 16-way servo driver board

16-way servo driver board and MSPM0G3507 wiring

Note: The core board sold in this store has no solder pins at PA10 and PA11, which need to be soldered by yourself. Or change the serial port pin settings

3. Program description

Header file that defines serial port transmission data and serial port control functions

 

Define the serial port initialization function, the function of sending a byte of data, the serial port interrupt service function, and the serial port data sending function to communicate with the 16-channel servo driver board to control the servo.

The value range of servonum is (1-16), and the value range of angle is (0-180).

 

Assign values to the serial port control function. Use loops to control the continuous change of the servo from 0 to 180 degrees.

Note: The project source code must be placed in the SDK path for compilation.

For example, the path is: D:\TI\M0_SDK\mspm0_sdk_1_30_00_03\1.TB6612

4

4. Experimental phenomenon

Connect the servo to the S1 interface of the 16-channel servo driver board and burn the program to MSPM0G3507. After burning, connect the MSPM0G3507 to the 16-channel servo driver board according to the wiring diagram. After powering on, you will see the servo rotate from 0 to 180 degrees. Finally, return to 0 degrees, and repeat.