Commissioning a Raspberry Pi Pan-Tilt HAT: Reference Pose, Limits and Smooth Motion
A pan-and-tilt camera platform is a small motion system, not just two servos attached to a Raspberry Pi. It needs a defined starting pose, movement limits that respect the bracket and cable, and a way to stop unintended motion. These details make the difference between a useful camera head and a mechanism that repeatedly strains against its stops.
PMD Way's pan-tilt HAT with servos combines a mechanism with a PCA9685-based controller and an ambient-light sensor. The camera is not included. This guide focuses on assembly, calibration and controlled movement; confirm the exact HAT revision and supported Pi model before applying its wiring or software instructions.
Define the camera's useful viewing range
Start by deciding what the camera must see. Mark the intended centre direction and the left, right, upper and lower limits. The useful viewing range may be much smaller than the servo's advertised travel, particularly once the camera cable and enclosure are present.
Consider the load carried by each axis. The tilt servo must support the camera and its mounting hardware against gravity, while the pan axis carries the rotating assembly. Place the load close to the relevant axis where practical. A longer offset increases the required torque even when the mass is unchanged.
For a classroom demonstrator, begin with a lightweight dummy load and a narrow motion range. Add the actual camera after the bracket moves freely. This separates mechanical problems from camera configuration and avoids damaging a ribbon cable during early tests.
Establish the starting position before final assembly
The Waveshare Pan-Tilt HAT manual for the documented hardware instructs users to position the servos with its test software before assembling the mechanism. Its reference arrangement assigns the pan servo to S1 and the tilt servo to S0. Confirm that your board and kit match that manual before using those labels.
Do not assume the angle called “zero” by software is the mechanical centre of every servo. Follow the kit's reference pose, then fit the arms and brackets in the documented orientation with power removed. Avoid manually forcing the geared output shaft to a different position during assembly.
Check the mechanism throughout the intended travel before attaching the final load. Screws, brackets and cables must remain clear. A servo that hums loudly while failing to move may be pushing against a stop or an excessive load; remove power and investigate instead of increasing the command range.
Distinguish a pulse command from measured position
The NXP PCA9685 datasheet describes a 12-bit PWM controller. In this application it generates the servo control signals; it does not directly measure the camera angle or supply the servo motor's mechanical power.
A command labelled 30 degrees in a library is a mapping chosen by that software. Its accuracy depends on the servo, linkage and calibration. Unless additional feedback is provided, the Pi does not know that the platform actually reached the requested angle.
For repeatable presets, record the tested command values that produce the desired views. Approach a reference position from a consistent direction when evaluating repeatability, because gear clearance and bracket flexibility can affect the final view. Do not describe a hobby servo platform as precision positioning equipment without measuring its performance.
Keep power planning separate from logic compatibility
An I2C interface needs only a small number of signal connections, but the servos still need an adequate power path. Their demand changes with movement and load. A HAT's logic-voltage compatibility does not establish that the Pi's supply can support every attached servo and accessory.
Follow the exact board schematic and manual for power connections. Do not add an external servo supply to an uncertain point or join two supply outputs together. Confirm connector orientation rather than relying solely on wire colour, especially if replacing either servo.
Test one axis first, then both axes moving together. Watch for Pi resets, communication errors or motion that becomes erratic under load. Those symptoms can indicate power or wiring problems rather than an incorrect angle calculation. Keep an accessible way to remove actuator power during commissioning.
Create conservative software limits
Store separate minimum and maximum commands for pan and tilt. Every input path should pass through those limits, including keyboard control, web commands and automatic tracking. Do not rely on a slider's visible endpoints if another part of the program can send unrestricted values.
Begin near the reference pose and expand the permitted range gradually. Stop short of mechanical contact and allow margin for cable movement and assembly tolerances. Recheck the limits after changing the camera, bracket or cable routing.
For smoother motion, move toward a target in bounded increments at a controlled update rate. This reduces abrupt changes in the mechanism, but it does not guarantee a particular speed or acceleration because the servo's internal controller and load also affect motion.
Handle startup and lost commands deliberately
| Situation | Design decision |
|---|---|
| Normal startup | Whether to remain still or move gradually to a tested reference pose. |
| Invalid command | Reject it or limit it to the permitted range and report the result. |
| Remote connection lost | Stop accepting stale movement commands and enter the chosen safe state. |
| Application restart | Re-establish a known command state without an unexpected sweep. |
| Servo power removed | Account for the platform no longer actively holding its position. |
Removing PWM is not a universal mechanical brake. A loaded tilt axis may droop when the servo is no longer holding. Support the camera appropriately during shutdown and maintenance, and choose behaviour suitable for the actual load rather than assuming “off” always means “stationary”.
Add camera and light sensing after motion works
Test the camera independently using the current Raspberry Pi camera software documentation. Older kit manuals may use camera commands or Python packages that no longer match the installed operating system. Keep hardware assembly guidance separate from dated software installation instructions.
The onboard light sensor can support experiments, but a single ambient-light reading does not directly reveal where a light source is located. A scanning experiment needs a repeatable movement sequence, settling time and consistent exposure conditions. Start with recorded measurements before adding automatic tracking.
Finally, repeat the motion tests with the camera cable secured in its final route. Save the reference pose, limit values and tested software version. Compare the motor and servo control HAT collection against the mechanism's needs. A dependable pan-tilt project moves only where intended and remains predictable after every restart.