Set the OpenServo position
You can command the OpenServo to a position using a basic 16 bit data register. The position of the servo is 10 bit, so it allows for a range of 0 to 1023. In reality the servo position will be limited by the physical range of the servo used. A typical servo will move in the range of ~270 degrees, or OpenServo positions 120 to 980.
A standard I2C transaction at the byte level is simple. First you send the device slave address, and then you send the register to read/write to. After the start conditions are sent you can write the 16 bit position register.
For example, to set a servo position of 980 (which is the max value I can get from a Stell Servo) you would send this command sequence.
Assuming device address = 0x10
I2C communicates using hex bytes, so position 980 translates to 0x03D4
Set position
16 bit precision
V2/3 |
V3-dev |
|
|
|
0x10 |
0x20 |
SEEK_HI |
Read/Write |
Seek position high byte |
0x11 |
0x21 |
SEEK_LO |
Read/Write |
Seek position low byte |
As with any I2C transaction, this 16 bit value must be split into 2 8 bit bytes. All that is required, is to send the upper and lower nibbles of the byte.
The value SEEK_LO is not explicitly sent as it is implied by writing 16 bit data to the address SEEK_HI.
SEEK_HI = 0x10 SEEK_LO = 0x11 device = 0x10
pseudo code: [device SEEK_HI {seek_position_hi} {seek_position_lo}]
raw I2C packet: [0x10 0x10 0x03 0xD4]
Once this is written, the OpenServo will immediately start to move to the new position.
