Servo/Programming help please
ur5pointos2slo
Posts: 19
I have written a code and I am having problems with the servo. I have written other posts regarding what I am trying to get the bot to do, I have finally got everything to work the way I want. Now I am having problems getting the servo to turn correctly. It is a standard servo(180 degree movement). I am starting on a line with qti sensors.I also have an IR sensor hooked to the bot. So the bot follows the line until it sees the wall or whatever it may be. Then the servo will rotate the full 180 degrees(WHICH I CANNOT GET TO WORK), Rotate -180 degrees, then turn around and continue following the line until it sees something. Then on and on from there in the same way. So my problem is under the Dump_balls subroutine I cannot get the dumpservo to actually turn 180 degrees it seems like it makes a simple pulse then pauses makes a simple pulse(split second) then turns around follows line and on and on. How can I make the servo turn for the whole 180 degree it is allowed. I have tried all different numbers and nothing seems to help it. I have attached a copy of the code any help would be appreciated. Thank you
bs2
3K
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
The standard servo will move from one extreme to another as the pulse width changes from 1ms to 2ms. You would also need to refresh it every 20 ms to hold it in position. You should add a line during your main loop to hold it in the running position:
PULSOUT Dumpservo, 500 'Assuming that the extreme corresponding to 1ms is the running position.
Then to have it rotate 180 degrees, increse its pulse to 2 ms
FOR counter = 1 TO 100
PULSOUT Dumpservo, 500 + ( 5 * counter)
PAUSE 20
NEXT
Post Edited (ur5pointos2slo) : 12/6/2008 6:32:26 PM GMT
Write a 4 line program to position the servo to some position and just modify, download, and run the program repeatedly until you've found all the servo positions of interest to you and the pulse width to go there. With a BS2, the extremes are somewhere on the order of 1.0ms (PULSOUT <pin>,500) to 2.0ms (PULSOUT <pin>,1000). Your test program would just be
where <pin> is the pin number being used and <pulseWidth> is the pulse width in units of 2us (1.5ms = 750)
Dump_Balls:
FOR counter = 1 TO 100
· PULSOUT Dumpservo,1000
·· PAUSE 20
NEXT
FOR counter = 1 TO 100
· PULSOUT Dumpservo,(Need this value to spin the servo in the opposite direction?)
·· PAUSE 20
NEXT
GOSUB Turn_around
RETURN
Post Edited (ur5pointos2slo) : 12/6/2008 7:17:58 PM GMT