I fought with the blocking serin problem for a long time for servo controllers. Finally there is a simple solution for making a picaxe based serial servo controller.(08m in this case) Use an interrupt and trigger the interrupt from your serial source as part of the stream. This idea is really simple, but I hadn't seen it written up before.
<code>
'Serial servo program
main:
setint %00010000,%00010000 'Set an Interrupt on pin 4 to look for the pin to go high
servo 2,b0 'update the servos
servo 1,b1
pause 20
goto main
interrupt: 'If the interrupt goes high this means that there is serial data waiting
serin 4,N2400,b0,b1 'Get the bytes of serial data
return
</code>
There are several limitations. I can only seem to make it work for 2 servos and the maximum update rate is around 10Hz.
When transmitting from the pc, I start each stream with a %00000001 to trigger the interrupt and then send ascii values which are written to the servos.
For more info and video of servos under control from the serial port see:
http://profmason.com/?p=766
Now, how to improve this? Would it be better to pull each servo low when the interrupt is called? Ideas on how to get more servos. Any experience with servos at 8mhz on an 08m?Worth trying, but I am for bed.
have fun,
mmason
<code>
'Serial servo program
main:
setint %00010000,%00010000 'Set an Interrupt on pin 4 to look for the pin to go high
servo 2,b0 'update the servos
servo 1,b1
pause 20
goto main
interrupt: 'If the interrupt goes high this means that there is serial data waiting
serin 4,N2400,b0,b1 'Get the bytes of serial data
return
</code>
There are several limitations. I can only seem to make it work for 2 servos and the maximum update rate is around 10Hz.
When transmitting from the pc, I start each stream with a %00000001 to trigger the interrupt and then send ascii values which are written to the servos.
For more info and video of servos under control from the serial port see:
http://profmason.com/?p=766
Now, how to improve this? Would it be better to pull each servo low when the interrupt is called? Ideas on how to get more servos. Any experience with servos at 8mhz on an 08m?Worth trying, but I am for bed.
have fun,
mmason