Is it possable to control a servos speed with only using the Bot board II and Atom?
If so, can someone post some example code.
Bane
Is it possable to control a servos speed with only using the Bot board II and Atom?
If so, can someone post some example code.
Bane
What servo are you wanting to control the speed of? A regular +/- 90 degree analog servo such as the HS-475HB or HS-645MG, a continuous rotation servo like the Hitec HSR-1422CR, or something else?
8-Dale
I have HS-475HB standard servos 180 degrees total range. Right now my servos just run at full speed and jerk my bot around. I need to control the servo speed to its destination.
Bane
There are probably others that can answer this better for the Atom than I can, but I will take a shot at it.
You have not provided enough information to give you a complete answer. For example do you simply want to move 1 servo or are there multiple servos. If multiple do you want to move 1 at a time or all of them as a group? Are you using the servo command?
Now if your question is something like: If my servo position is currently at lets say -1000 and if I enter a new servo command to go to position 1000, it runs at full speed and jerks your robot, then you may wish to break up this change in position from doing it all at once, to doing it in steps. There are many different ways to do this. A simple way may be something like:
oldPos var SWORD
newPos var SWORD
TempPos var SWORD
if NewPos > OldPos then
TempPos = OldPos + 50
While TempPos < NewPos
servo pin, TempPos
pause 25 ; Play around with how much to pause between moves?
TempPos = TempPos + 50
WEND
else
TempPos = oldPos - 50
While TempPos > NewPos
servo pin, TempPos
pause 25 ; Play around with how much to pause between moves?
TempPos = TempPos - 50
WEND
Servo pin, NewPos
Please note, that I did not try to compile this. Also there are ways to combine the two loops, etc. But hopefully this gives you something to experiment with. Also you might try calculating the pause depending on how long you want the whole transistion to take.
This type of code can also be expanded to try handle multiple servos, by calculating deltas from the old position to the new desired position for each servo and finding the maximum delta. Than factor the difference given to each servo per iteration by the maximum. Example is if you have two servos. One wants to move 200 units and the other wants to move 500 units. Lets say you want to complete the operation in 10 steps. The first servo you would change its postion by 20 units per iteration and the second one by 50 units. Sorry if I did not explain this overly well.
Good Luck
hey thanks, what i want is like servo 1 go 1000 to 500 in 500us or something
Iβm using the ATOM software that came with the Basic Atom 28 pin. What is the β50β your added or substracting? Sorry, if you canβt tell im a nube
Bane
50 is just a number. The idea is to simply break up your changes of servo position into mutliple smaller deltas. You should try experimenting. Maybe only delta by 1 pre call to servo. Try without any pauses. If this takes longer than you want so then you could try 2β¦ If it is too fast, then pause between, or call servo N times for each value, or add/chage the repeat parameter to servo. I think it defaults to 30 times and each iteration takes about 20ms.
So Jump in and experiment until you get the move you want!
If you get the Atom Pro processor you can grab the code from the Autonomous BRAT project. It has an SSC-32 emulation (with fewer channels) that will allow you to make group moves.
lynxmotion.com/images/html/build130.htm