DIY_SERVO.bas (1588Bytes)
(If Google video is down, video is here)
I like servos!
However, sometimes you want what a servo does, but you need one that is special: Very strong, very fast, takes more voltage, does not need a servo controller etc.. And you are not going to buy one for a trillion dollar and wait for it to arrive.. So you build it yourself :)
It is quite easy: A motor hooked up to a motor controller so it can turn both ways has a potmeter on it, and the potmeter tells the microcontroller where the motor is, and there you go!
You can make the fastest servo in the world by using a low or no-geared motor. Or you can make it huge and strong enough to lift you..
In my case I just needed a servo that would not mind being kicked back to another position really fast when power was off.
Not much more to say? Potmeter has 3 pins. Middle goes to analouge in, the 2 other goes to G & V. If you switch them, your reading will just be reversed.
The potmeter is very light to move, so you can easely just make something with hot-glue-art, as I did, to make it follow the wheel.
Some geared motors has the axle sticking out at the other side, making it even more easy to mount the potmeter.
The potmeter I have used actually comes from an old servo.
Here is a sample program (To Picaxe) of one way to use the setup, it is what is running the homemade servo on the video: (Also attached)
' Set this up to match your hardware:
symbol PotmeterPin = 1' The analouge pin connected to the potmeter
' The lines marked with (M) should match your motor driver, in my setup below, it is output 6&7 ("B" on the picaxe 28 board)
'**************
symbol ServoPuls = w0' Word variable to calculate the puls to send to the motor
symbol DesiredPosition = b2' The variable used in the main routines to set servo at a position. 127 is middle.
symbol CurrentPosition = b3' The value returned from the potmeter
'**************
main:' Example program; If Pin7 is 1 then go to one position, else go to another..
if pin7 = 1 then
DesiredPosition = 70 gosub setservo 'this line is instead of the usual "servo pin,position" - 127 is middle
else
DesiredPosition = 210 gosub setservo 'this line is instead of the usual "servo pin,position" - 127 is middle
endif
goto main
'**************
setservo:' a subroutine that takes care of positioning the "servo"
readadc PotmeterPin, CurrentPosition
if CurrentPosition < DesiredPosition then
ServoPuls = DesiredPosition - CurrentPosition
' if ServoPuls < 2 then return end if ' Optional, to prevent jitter and buzzing, but getting less accuracy
ServoPuls = ServoPuls * 100
low 6 pulsout 7, ServoPuls ' (M)
end if
if CurrentPosition > DesiredPosition then
ServoPuls = CurrentPosition - DesiredPosition
' if ServoPuls < 2 then return end if ' Optional, to prevent jitter and buzzing, but getting less accuracy
ServoPuls = ServoPuls * 100
low 7 pulsout 6, ServoPuls ' (M)
end if
return