Can you control a standard servo speed? If so what would the program look like with BASIC MICRON using the Basic Atom? All i can do is tell it to go to a position but not how fast. Please help.:mrgreen:
bane
If you use an ssc-32 servo controller, then it can control servo movement speed from one point to another. Check the ssc-32 user manual for info.
but i don’t have a SSC controller , only the BOT BOARD II with BASIC Atom 28 pin. This is how i’m currently programming it.
I’ve really been needing a sequencer lately, it seems to solve most of my programming problems
Bane
Unfortunately there is no easy way to add speed to the Atom servo control scheme. It amounts to you needing to wrap every serout in a for next loop, but this takes a lot of variables and really taxes the cpu. That’s what makes servo controllers a worthwhile investment.
Yeah back when I needed to control the servo speed because it was whipping the load around when it was stopping at a position, I’d use a while loop (a for loop works the same) and pause it ever so slightly between “ticks” and increment the servo position by 1 after every pause. Longer the pause, longer the time it takes to get to the position. Shorter the pause (the closer to 0.00s it is), the faster it takes to travel.
In reality, the speed isnt really changing because the servo travels 1 degree at the same time as it always did. The difference is how long it takes to get to its final destination.
Pseudocode?
currentPositionofServo = 128;
desiredPositionofServo = 180; // long names lol
while (currentPositionofServo < desiredPositionofServo) {
pause here 0.01 seconds; // 0.000001 would be faster, 0.5 would be hella slower
currentPositionofServo++; // increment the position counter by one.
then set servo position to currentPositionofServo; // set servo pos to new position ... go back up and repeat loop
}
Something of the sort.
Ok, now do it on a Basic Atom (not a PC), and do it for 6 servos, don’t break the 20mS refresh limit, and try and squeeze in a way to parse out position sequences.
If it were me I would try to make the transisition to the next location in smaller steps. I have not used my Atom in awhile and I never did any servo stuff directly. It was used earler on my Hex talking to the SSC32. But I quickly hacked up some of your code to allow for transisitions from one move to the next. I made it do a real simple transistion where you specify the number of steps, but this could easily could be expanded to calculate the maximum differences and calculate the number of steps, etc.
Please note, I have not tried downloading it, let alone try to run it… But it might give you a jump start…
Good Luck
Kurt
[code]Pulses var word(6)
NewPulses var word(6)
DeltaP var sword(6)
Steps var word ’ how many steps do we want to take to get to the new position…
i var word
sp1 var word
counter var word
‘ROBOTIC ARM POSE (FOLD AND TRAVEL)’
main:
pulses = 1300,2200,1500,600,1600,2300
FOR counter = 1 TO 150
gosub DoPulses
PAUSE 5
NEXT
‘ABOVE BRICK POSE’
NewPulses = 900,2000,1200,1100,600,1900
steps = 10 ’ could change this for each transistion…
gosub TransistionToNewPulse
FOR counter = 1 TO 150
gosub DoPulses
PAUSE 3
NEXT
‘OVER BRICK’
NewPulses = 800,1950, 1200, 1100, 600, 1900
gosub TransistionToNewPulse
FOR counter = 1 TO 150
gosub DoPulses
PAUSE 1
NEXT
‘GRAB BRICK’
NewPulses = 800, 2100, 1000, 1100, 1000, 1900
gosub TransistionToNewPulse
FOR counter = 1 TO 150
gosub doPulses
PAUSE 1
NEXT
'… removed rest of moves, but same stuff…
‘MOVE BRICK’
goto main
TransistionToNewPulse:
for i = 0 to 5
DeltaP(i) = (NewPulses(i) - pulses(i))/steps ’ calculate how much difference we want for each move
gosub DoPulses ’ Make sure we do it often enough to hold position…
next
' ok now lets move to new position... One increment at a time
for counter = 1 to steps
for i = 0 to 5
pulses(i) = pulses(i) + DeltaP(i)
gosub DoPulses
next
next
return
DoPulses:
PULSOUT p0, pulses(0)
PULSOUT P1, pulses(1)
PULSOUT p2, pulses(2)
PULSOUT P3, pulses(3)
PULSOUT p4, pulses(4)
PULSOUT P5, pulses(5)
return[/code]