Hello,
I do a lot of work with servo's and I am coming up against a wall with synchronizing them. I usually do the following:
portb.0 = 1
pauseus (servo1 * 4) + 960 ; scaling factor to give me 2.0ms full scale.
portb.0 = 0
If I repeat the above 4 or more times I am going to see the signals staggered in time. 1ms at the least and 2ms at the most between each routine. The picaxe seems to be able to start all servo's at once and update on the fly each servo (8 servos). Has anyone tried to do this?
I am thinking about using a 20ms interrupt to seed ADC values, synchronously start low to high output on 8 pins and decrement variables in main. Like the following:
intMe: ; interrupt every 20ms
asm
portb = 1
load ADC0 into counter 1
load ADC1 into counter 2
etc
etc
return from interrupt
end asm
Main:
if servo1 > 0 then
servo1 = servo1 - 1
else
portb.0 = 0
endif
if servo2 > 0 then
servo2 = servo2 - 1
else
portb.1 = 0
endif
etc
servo3 ~ servo8
pauseus 100
goto main
Is there a better way of doing the above mentioned? I can't shake the feeling that it seems too brute force and there should be a more elegant way of doing this.
Nick