Lab: Motion and PID Control of Servo Motors
Lab Instructions
- Hardware setup: see the instruction below. Connect waveshare bus servo adapter to USB port of PC.
- Download Feetech FD.1.9.8.3 bus servo debug software and test the motor.
- Try to change PID parameters to observe how the motor moves.
- Download and install vs code and setup python environment
- Run the sample python code.
- Modify the code so that you can control the motor for a specific angle, say +-90 degrees.
- Set the motor at the middle position, target_position = 2097.
- Use Feetech debug software to check the result.
- Use daisy chain to connect 2 or more servos and test the codes
1. Introduction to PID Control Theory
PID (Proportional-Integral-Derivative) control is a feedback control technique widely used in industrial and robotics applications. The PID controller calculates an error value as the difference between a desired setpoint and a measured process variable, then applies correction based on proportional, integral, and derivative terms:
u(t) = Kp * e(t) + Ki * ∫e(t)dt + Kd * de(t)/dt
- Kp: Proportional gain (reacts to current error)
- Ki: Integral gain (reacts to accumulated error)
- Kd: Derivative gain (reacts to rate of error change)
2. Practice: Applying PID Control to a Feetech STS 3215 Servo Motor
The Feetech STS 3215 is a bus servo motor commonly used in robotics. To control it with PID, you need:
- Feetech STS 3215 servo motor
- Waveshare bus servo adapter
- Microcontroller or PC with serial interface
Motor and Wiring Diagram
Feetech Bus Servo Debug Software
Download the Feetech FD.1.9.8.3 bus servo debug software to test and debug servo motors:
Sample Python Script
Download and review the sample Python script for motion control of the Feetech STS 3215 servo motor:
servo_control.py
Alternatively, download and review the sample Python script using the st3215 library (GitHub):
st3215_control.py
3. How to Tune the PID Controller for Positional Control
Change PID parameters using Feetech Servo Debug software. See the demo in the following.