Lab: Motion and PID Control of Servo Motors

Lab Instructions

  1. Hardware setup: see the instruction below. Connect waveshare bus servo adapter to USB port of PC.
  2. Download Feetech FD.1.9.8.3 bus servo debug software and test the motor.
  3. Try to change PID parameters to observe how the motor moves.
  4. Download and install vs code and setup python environment
  5. Run the sample python code.
  6. Modify the code so that you can control the motor for a specific angle, say +-90 degrees.
  7. Set the motor at the middle position, target_position = 2097.
  8. Use Feetech debug software to check the result.
  9. 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
    

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:

Motor and Wiring Diagram

Feetech STS 3215 Servo Motor Waveshare Bus Servo Adapter Bus Servo Adapter 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.

PID Tuning Demo