Today i had a pan and tilt head arrive. 2 9g servos and brackets. I decided to do a little project that drives the X and Y servos from a joystick.
Within 1 hour i had the thing built, hooked up to the breadboard and working using 2 PWM pins on the extender. its not smooth motion yet but it works.
As promised, sorry about the poor quality of the Vid but i couldnt hold my phone the joystick and the bottom servo all at the same time
At the moment there is not smoothing on the values i get back from the joystick so the servos jitter somewhat. I will figure that out as i get to it.
But the key thing for me here is that when i sat down to do this last night i didnt expect that i would achieve a working model.
I am basically using a timer to check the values of the joystick every 50ms and then convert them to the pulse etc.
Is it possible to use an X or Y value change as an interupt and drive it that way?
Thanks Architect. I will look into that. I do need to work out how to smooth the values coming from the joystick, its really noisy and makes the servos jitter quite a lot. I am guessing a little avaraging algorithm might work or just taking the first set of digits i.e 0.5 (the range seems to run from 0 to 1)
When I did something similar I found I was getting noise from dodgy connections due to trying to clip the servo connector onto the ‘short end’ of breakaway header pins plugged into the breadboard, once I got myself double-sided header pins (long on both sides) I got a much better connection with less noise. Also make sure to incorporate a ‘dead zone’ around the 0.5 centre values so that anything between, say, 0.45 and 0.55 gets treated as dead-on 0.5, in order to prevent any jitter while you’re not touching the stick.
@ RorschachUK, thats a good idea. A dead zone would actually solve the problem nicely. Im not sure the noise is comming from the connections as i am debug.printing the X and Y positions comming from the Joystick and you are right they float between around 0.45 and 0.55.
@ Swestcott, as soon as i have it working nicley i will post the code.