I’m a newby and raise to call for help for my pololu 12 channels servo controller.
My friend help me to write this script and as I know that servo 0 will run with servo 1 simultaneously from 0-7500 and 0-15000 respectively.
If my intention is that servo 0 run with servo 1 simultaneously from 0-9000 and 0-15000 respectively, how to make this script?
If servo 0 run with servo 1 simultaneously from 9000-0 and 15000-0 respectively, how to make this script too?
#My Script
0
begin
dup 15001 less_than while
dup 2 divide 0 servo
5 plus
40 delay
dup 1 servo
5 plus
40 delay
repeat
drop return
I’ve modified your script to make it slightly simpler and illuminate how it works:
0 begin dup 15001 less_than while # We loop from time=0 to time=15000, where "time" is a variable on the top of the stack.
dup 2 divide 0 servo # Servo0 target = Time/2.
dup 1 servo # Servo1 target = Time.
10 plus 80 delay # Increment "time" and delay. This means that "time" has units of 8 ms.
repeat
drop
return
By changing the 2nd and 3rd lines of this script, you should be able set Servo0 and Servo1 to any function of time that you want. For example if you want servo 0 to go 0 to 9000, you can replace the 2nd line with this:
dup 5 divide 3 times 0 servo
When doing arithmetic on the Maestro, be careful that you don’t ever go over 32767 or below -32768.