Pan-Tilt HAT not achieving 180 degree range of motion in pan or tilt

Upon getting the Pan-Tilt HAT set up, I have not been able to rotate ±90 degrees in either servo. I’m seeing roughly 145 degrees in the pan direction, and less (maybe 120) in tilt. If I set tilt=0, rather than pointing straight ahead, it points roughly 45 degrees upward, and setting tilt=90 will point it straight up (but make a grinding sound for a bit after it gets to this position). The ranges/offsets are consistent across power cycles. I’ve tried re-seating the connections and reinstalling the OS / libraries.

I see other users with similar issues:



Based on these posts, I tried adjusting the min/max pulse (pantilthat.servo_pulse_min/max(…)). I tried blindly adjusting the values, and I can achieve ~180 degrees in pan if I use the range [500,3000] for servo 1 (pan), but I haven’t been able to find the right range to make tilt behave correctly. If this is a calibration / zeroing issue, is there any documentation for doing this?

Hardware involved:
Pan-Tilt HAT (solderless)
Raspberry pi 4 (also tried a pi 3B; same results)
3.5A power supply (usb-c)

Thanks!

I’m afraid is just a limitation of this product - I think we expect too much out of it at this price… (and servo’s in general)

My experience with it was a mixed bag - initially I got it working but more and more I got drift and accuracy problems.

What I did with mine was set the pan and tilt to 0. Then took note of how far off center they were. I then carefully took it apart and repositioned things on the servo splines so when it went back together everything was centered correctly.
Then did the Pan tilt to 0 again to see if I had it right and didn’t move a servo in the process. Once you do that the servos shouldn’t grind any more when at thier limits.
If things are off center on the splines during manufacture, which is I think what happens, the servo keeps trying to go to 90 but the plastic bits have hit thier stops. Mine wasn’t too far off actually, but it was just far enough out of whack that I took the time to fix it. It’s a bit tricky but just take your time and keep track of what teeny tiny screw came out of where etc.
I do believe these come pre assembled from Adafruit, and Pimoroni bundles them with thier Hat. There are assembly instructions on the Adafruit site as you can buy just the plastic bits with no servo’s and assemble it yourself.

You can easily test the servos using a simple python bash script as below. So you can find both limits where servo start grinding… It is actually the same alphanumeric describes in his reply

pi@raspberrypi:~ $ python
Python 2.7.16 (default, Apr 6 2019, 01:42:57)
[GCC 8.2.0] on linux2
Type “help”, “copyright”, “credits” or “license” for more information.

import pantilthat
pantilthat.pan(0)
pantilthat.pan(30)
pantilthat.pan(60)
pantilthat.pan(90)
pantilthat.pan(-90)
pantilthat.tilt(0)
pantilthat.pan(0)
pantilthat.tilt(60)
pantilthat.tilt(-60)
pantilthat.tilt(-80)
pantilthat.tilt(80)

Then quit the script by ctrl D.
Good luck centering your servos

Yeah, it kind of depends on how far you want to take it.
If your fine with the degree of motion you have, finding your limits and making sure you don’t exceed them in your Python code will stop any servo grinding.
I likely could have got away with that approach. My Pan Tilt is centered in one of the front windows of my house. If I pan any more than 40 all I see is window frame lol. And I only ever tilt down about 15. It just bugged me that 0 wasn’t 0 and that I would have to fudge my code to compensate.
If you actually want to get full range, and you don’t have that now, your looking at rebuilding the Pan Tilt to get things where they should have been.
My best guess is somebody at Adafruit is forgetting to center the servo’s before putting it all together?

Understood, thanks for the tips! I’ll give the manual re-build a shot and see if that improves the range.

If one servo is way off, which it sounds like yours is, IMHO rebuilding it is the way to go. The Pan one is easy to adjust, the Tilt takes a bit more time and patience to get apart enough to pull the arm off of the spline.