Skip to main content
Servo Encoder

Mechatronics Lab Professor — SJSU

Servo Encoder

Servo motor and rotary encoder lab covering PWM control, quadrature decoding, closed-loop position feedback, and PID tuning fundamentals.

Lab 7: Servo Encoder combined two critical mechatronics building blocks — servo motor actuation and rotary encoder feedback — into a single closed-loop control exercise. Students learned how position feedback systems work from the ground up, connecting the dots between PWM signals, angular measurement, and real-time control algorithms.

The first half of the lab focused on servo motors: students generated PWM signals using the Arduino Servo library, characterized the pulse-width-to-angle relationship, and explored the effect of load and supply voltage on positioning accuracy. The second half introduced incremental rotary encoders — students wired quadrature A/B channels, wrote interrupt-driven decoding routines, and verified their count accuracy against known angular displacements.

In the final integration exercise, students built a closed-loop position controller: the encoder measured the actual shaft angle, a PID algorithm computed the correction, and the servo actuated the output. Students tuned proportional, integral, and derivative gains in real time, observing overshoot, steady-state error, and oscillation on a serial plotter. This exercise was one of the most popular in the course — it demonstrated, in a tangible way, how feedback transforms an open-loop actuator into a precise positioning system.

ArduinoServo MotorsEncodersPID ControlPWMEducation