Controlling servo speed with 18X / SD21

It looks like the SD21 has a built in speed ramping function. According to the datasheet it is a matter of putting values in spcific registers.
I've since looked at the data sheet and agree. To alter speed it's just a matter of setting the speed register for the appropriate servo -

- I2cWrite 0,(speed) ' Set servo 1 speed

The bigger the number, the faster it moves.

Use of the "More Registers!" registers took a couple of readings to fully understand what was going on there. It would have been better IMHO to have duplicated the BS2 version of code for the PICAXE ...

- SYMBOL Speed = 0 ' maximum speed <-- Adjust this 0..255
- SYMBOL Servo1p = 1800 ' Right position
- SYMBOL Servo1n = 1200 ' Left position
-
- SYMBOL Servo = w0
- SYMBOL ServoLOWBYTE = b0
- SYMBOL ServoHIGHBYTE = b1
-
- Loop:
- Servo = Servo1p
- I2CWRITE Servo1, (Speed, ServoLOWBYTE, ServoHIGHBYTE)
- PAUSE 300
- Servo = Servo1n
- I2WRITE Servo1, (Speed, ServoLOWBYTE, ServoHIGHBYTE)
- PAUSE 300
- GOTO Loop
 
Top