Society of Robots - Robot Forum
Software => Software => Topic started by: BANE on May 10, 2008, 08:46:26 PM
-
Hello, after speading about 5 hours scruwing around with my atom, I came up with a program that can take a value from a pot and rotate a servo in the direct as long as the pot is that specific value. Also, the servo stays at that position when the pot is back to 0 degrees. (check out code )
what my question is is that my program has the servo stop at my desired position but doesn't hold. If anyone has any idea how to get the servo value before it stops and have it hold that position instead of doing nothing.
'=========variables=============
yservo var sword
counter var sword
counter = 0
ttime var bit
ttime = 1
'=========maincode=============
loopit:
adin ax0,1,ad_ron,yservo
if yservo < 700 then
repeat
counter = (counter - 25)
servo p5, counter, ttime
adin ax0,1,ad_ron,yservo
until yservo > 700
elseif yservo > 710
repeat
adin ax0,1,ad_ron,yservo
counter = (counter + 25)
servo p5, counter, ttime
until yservo < 710
else
gosub nothing
endif
goto loopit
'===========subcommand==============
nothing:
pause 1
return
Bane
-
Send 1.5ms, for example, to the servo will make it go to that position and hold. If it doesn't hold, it means you are applying more force than its maximum output torque.
I haven't checked your source code, but remember, the signal must be sent 50 times per second (even if your pot - input, has not changed). Don't send the signal only when the input changes!
-
I haven't checked your source code, but remember, the signal must be sent 50 times per second (even if your pot - input, has not changed). Don't send the signal only when the input changes!
Thats exactly what i'm trying figure out. I have a three-way "if" statement regarding the pot input. (center of pot is 707) If x < 700 than add 15 to servo value and repeat until x >700. Vise versa when x > 700. If value is between 700 and 710 it does nothing. Instead of nothing i want the servo to hold the (last value received).
Oh wait ::), my servo variable doesn't reset its self being that i have it above the loop, so if i add or sub. from that value it should stay the same. So all i have to do is put a servo position in place of the "nothing"
Bane
-
Ha :D that was easy!
'=========variables=============
yservo var sword
counter var sword
counter = 0
ttime var bit
ttime = 1
'=========maincode=============
loopit:
adin ax0,1,ad_ron,yservo
if yservo < 700 then
repeat
counter = (counter - 25)
servo p5, counter, ttime
adin ax0,1,ad_ron,yservo
until yservo > 700
elseif yservo > 710
repeat
adin ax0,1,ad_ron,yservo
counter = (counter + 25)
servo p5, counter, ttime
until yservo < 710
else
gosub hold
endif
goto loopit
'===========subcommand==============
hold:
servo p5, counter, ttime
return
-
The really cool thing about this program is that you can control a servos position by add or sub. from a pot or two buttons, even hold ;D. (please tell me that this could be useful :o)
Bane
-
The really cool thing about this program is that you can control a servos position by add or sub.
This is very similar to how my Stampy robot controls the sharp IR servo, and how my ERP robot rotates it's head. ;D
-
The language u used is it BASCOM?
thanks.