Pan-Tilt HAT calibration error


#1

Hi,

managed to setup the pan-tilt HAT quite beautifully - everything works correctly, I can interface to it etc.

Except one problem: the 0 position of the pan servo is off by a couple of degree - like this:

New photo by Valentin Galea

Also on powerup the servos jolt to random positions - is this a known issue? they will reset to same skewed 0 position tho following a python command.

Any ideas how to calibrate the 0 point or it’s a hardware fault?

Cheers,
Valentin


#2

It sounds like the servos are receiving random and incorrect signals, possibly due to a faulty electric connection that’s capturing signals from another pin. Try jostling around the GPIO pin insets and/or re-flowing solder joints.

I’ve never heard of anything like this before and my own pan-tilt hat has never done anything like this yet… It might be an issue on the board, but it’s unlikely.

The off-position 0-ing isn’t that hard of a bodge-fix. Just try setting your 0 position in your Python code.

Let me do a bit more research and I’ll get back to you with a better fix! :)


#3

thanks! one extra note: the HAT is connected via a solder-less jig, so chances of a bad connection are slim i think


#4

Good to know! Always worth a re-hammer though. ;)


#5

I’ve found a couple of similar posts here on the Pimoroni forums with similar problems to you:

1.Pan-Tilt Hat, how zero the position heads from both servos?

2.Pan-Tilt Hat

It seems to fix this, you should pop over to the “/library/pantilthat/pantilt.py” part of your pan-tilt hat directory (wherever that is) and change the values

servo1_min=575,
servo1_max=2325,
servo2_min=575,
servo2_max=2325,

in order to re-adjust the minimum and maximum position of your hat, which should hopefully reset the 0 position as well. The values are PWM (Pulse Width Modulation) based, so I’m not sure myself how they translate to degrees, have a fiddle around!

I’m still not sure why your hat moves randomly at boot. It is possible it’s a fault with your Pi, but I’d prefer to resort to that as a last resort (shortly after an error with your hat). Try running the “test.py” file in the library directory and see if you get, to Phil’s dismay (yes, I found that little Easter egg there sir), a happy message that your haven’t broken anything. If not, do post the log up here or have a look for any errors that may suggest why you’re getting this erratic behaviour!


#6

Hi, I have same problem, but I am waiting for a longer cable for the camera [20cm] as it all looks very tight when moving around. I suspect when they put it together the servo is not in the zero position, Once I get the new cable I will try the following put the servo with a python call to pan 90. Then unscrew the pihat from the servo [careful as not to move it, there is one screw on the bottom in the servo, unscrew and reposition the pihat.

If that is not going to work I need to find some more information about the pulse width and how this relates to the zero position, But I have strange effect that with every reboot the hat turns more to the left each time…


#7

Hmm… It’s starting to sound more likely that the hat is at fault here.


#8

It’s definitely something wrong with those PWM ranges… when setting the
the pan to the -90/90 extremes, it’s also offset.

Tricky to calculate PWM to degree tho:

Where can we find the exact specs of the HAT servos? That would be the
first step for the calculations…


#9

Ok I think I found them: http://www.micropik.com/PDF/SG90Servo.pdf


#10

That PDF is confirming the 1000-2000ms but you can easy set the pan to pulse_min 600ms or lower, so I really think we are talking about 2 different things here and the relationship to the degrees is total different. just my 2c.


#11

Over more testing I discovered the pantilt is very unrealiable and generally innacurate.

Now this may be because of the poor quality of the servos - you get what you pay for after all.

It maybe also be that driving it via GPIO is not good enough. I recently discovered this http://pythonhosted.org/RPIO/pwm_py.html - basicaly a more accurate way to drive servos.

@gadgetoid do you think this RPIO PWM lib could be integrated in?

Cheers,
Valentin