Difference between revisions of "Servo 1.0 protocol"

From BitWizard WIKI
Jump to: navigation, search
(Write ports)
 
(20 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The addresses on the SPI bus are 7 bits wide. The lower bit specifies if the transaction is to be a read or a write. Write transactions have the lower bit cleared (0), read transactions have the lower bit set (1).
 
  
Each transaction on the SPI bus starts with the address of the board. The spi_servo board will ignore any transactions on the SPI bus that do not start with its own address.
+
= Introduction =
  
After the address a single byte indicates the "port" on the board that the data is written to. The software can thus define 256 ports on each board.  
+
The protocol for the SERVO boards will be explained on this page.
 +
 
 +
This page describes both the SPI and the I2C version. See [[SPI versus I2C protocols]] for the explanation about how the protocols work in general.
  
 
The default address of the servo board is 0x86.  
 
The default address of the servo board is 0x86.  
  
= write ports =
+
= Write ports =
  
Some ports just set a single value. So writing more than one byte to such a port is redundant. Other ports are logically a stream of bytes. So writing more than one byte is encouraged.  
+
The ports on the servo board just set a single byte-value. So writing more than one byte to such a port is redundant.
  
 
The spi_servo board defines several ports.  
 
The spi_servo board defines several ports.  
Line 15: Line 16:
 
! port !! function  
 
! port !! function  
 
|-
 
|-
| 0x20 || Set servo 0 position
+
| 0x10-0x11 || 8 bit register. Reserved for debug. Do not write to these registers.
 
|-
 
|-
| 0x21 || Set servo 1 position
+
| 0x12 || 8 bit register. Each bit controls the enable of an output. If disabled (0) the output drops to zero. Some servos stop wiggling, become back-drivable and consume less power in this state.
 
|-
 
|-
| 0x22 || Set servo 2 position
+
| 0x20-0x26 || 8 bit register. Set servo 0-6 position. The pulse width changes from about 1.00ms for 0 to about 2.00ms for 0xff. To "overdrive" your servos you need to use 0x28-0x2e or adjust the offset and scaling using 0x58/0x59.
 
|-
 
|-
| 0x23 || Set servo 3 position
+
| 0x28-0x2e || (*) 16 bit register. Set servo 0-6 timing in microseconds. Don't set values larger than 2500. (if you do, funny things will happen if the total of all servos exceeds 20 miliseconds. Don't set the value too low. I expect you'll get pulses that are 20 miliseconds too long if you do.
 
|-
 
|-
| 0x24 || Set servo 4 position
+
| 0x30-0x36 || (*) 8 bit register. Set the default value for this servo. This value is used when the board is powered up. This value is stored in non volatile memory.
 
|-
 
|-
| 0x25 || Set servo 5 position
+
| 0x38-0x3e || (*) 8 bit register. Set the timeout value in tenths of a second. (5 = 0.5 seconds, 35=3.5 seconds). If no update of this servo is received within the timeout time, the servo will revert to the default value.
 
|-
 
|-
| 0x26 || Set servo 6 position
+
| 0x50 || (#) set servo values as an array. Write 1-7 servo position bytes (always starting at servo 0) in one transaction. 
 
|-
 
|-
| 0xf0 || change address.  
+
| 0x51 || (#) set servo values as an array. Write 1-7 servo timing values (16 bits/servo) in one transaction. 
 +
|-
 +
| 0x58 || (#) 8bit servo positions are converted to 16 bit timing values using tv = base + pos*mul; default base = 988 giving the normal 1000-2000 microsecond timing value range. This register is 16 bits and modifies the base.
 +
|-
 +
| 0x59 || (#) this changes the multiplication factor. See 0x58. 
 +
|-
 +
 
 +
| 0xf0 || Change address. Requires a write to 0xf1 and 0xf2 first.
 +
|-
 +
| 0xf1 || Write 0x55 here to start unlocking the change address register. 
 +
|-
 +
| 0xf2 || Write 0xaa here to unlock the change address register.  
 
|}
 
|}
 +
(*) From version 1.1 and up.
 +
 +
(#) From version 2.1 and up. (0x50 from 2.0)
  
= read ports =
+
= Read ports =
 
The spi_servo board supports two read ports:  
 
The spi_servo board supports two read ports:  
  
Line 40: Line 55:
 
| 0x01 || identification string. (terminated with 0).
 
| 0x01 || identification string. (terminated with 0).
 
|-
 
|-
| 0x20 || read servo 0 position
+
| 0x20-0x3e || read the corresponding write register.
|-
 
| 0x21 || read servo 1 position
 
|-
 
| 0x22 || read servo 2 position
 
|-
 
| 0x23 || read servo 3 position
 
|-
 
| 0x24 || read servo 4 position
 
|-
 
| 0x25 || read servo 5 position
 
|-
 
| 0x26 || read servo 6 position
 
 
|}
 
|}
= examples =
 
  
== read identification ==
+
= Examples =
 +
 
 +
For SPI in the examples below, "data sent" means the data on the MOSI line, while "data received" means the data on the MISO line. when MISO reads "xx" you should ignore the data. When MOSI reads "xx" it doesn't matter what you send.
 +
 
 +
For I2C in the examples below, you should first initiate a "write" transaction with the data in the "data sent column". Don't send the "xx" bytes. Then you initiate a "read" transaction, and you will get the data in the "data received" column (and again not the "xx" bytes).
 +
 
 +
== Read identification ==
  
 
read the identification string of the board. ('spi_servo 1.0').  
 
read the identification string of the board. ('spi_servo 1.0').  
Line 62: Line 70:
 
! data sent !! data recieved || explanation  
 
! data sent !! data recieved || explanation  
 
|-
 
|-
| 0x87 || xx || select destination with address 0x82 for READ.   
+
| 0x87 || xx || select destination with address 0x86 for READ.   
 
|-
 
|-
 
| 0x01 || xx || identify
 
| 0x01 || xx || identify

Latest revision as of 14:51, 16 November 2021

Introduction

The protocol for the SERVO boards will be explained on this page.

This page describes both the SPI and the I2C version. See SPI versus I2C protocols for the explanation about how the protocols work in general.

The default address of the servo board is 0x86.

Write ports

The ports on the servo board just set a single byte-value. So writing more than one byte to such a port is redundant.

The spi_servo board defines several ports.

port function
0x10-0x11 8 bit register. Reserved for debug. Do not write to these registers.
0x12 8 bit register. Each bit controls the enable of an output. If disabled (0) the output drops to zero. Some servos stop wiggling, become back-drivable and consume less power in this state.
0x20-0x26 8 bit register. Set servo 0-6 position. The pulse width changes from about 1.00ms for 0 to about 2.00ms for 0xff. To "overdrive" your servos you need to use 0x28-0x2e or adjust the offset and scaling using 0x58/0x59.
0x28-0x2e (*) 16 bit register. Set servo 0-6 timing in microseconds. Don't set values larger than 2500. (if you do, funny things will happen if the total of all servos exceeds 20 miliseconds. Don't set the value too low. I expect you'll get pulses that are 20 miliseconds too long if you do.
0x30-0x36 (*) 8 bit register. Set the default value for this servo. This value is used when the board is powered up. This value is stored in non volatile memory.
0x38-0x3e (*) 8 bit register. Set the timeout value in tenths of a second. (5 = 0.5 seconds, 35=3.5 seconds). If no update of this servo is received within the timeout time, the servo will revert to the default value.
0x50 (#) set servo values as an array. Write 1-7 servo position bytes (always starting at servo 0) in one transaction.
0x51 (#) set servo values as an array. Write 1-7 servo timing values (16 bits/servo) in one transaction.
0x58 (#) 8bit servo positions are converted to 16 bit timing values using tv = base + pos*mul; default base = 988 giving the normal 1000-2000 microsecond timing value range. This register is 16 bits and modifies the base.
0x59 (#) this changes the multiplication factor. See 0x58.
0xf0 Change address. Requires a write to 0xf1 and 0xf2 first.
0xf1 Write 0x55 here to start unlocking the change address register.
0xf2 Write 0xaa here to unlock the change address register.

(*) From version 1.1 and up.

(#) From version 2.1 and up. (0x50 from 2.0)

Read ports

The spi_servo board supports two read ports:

port function
0x01 identification string. (terminated with 0).
0x20-0x3e read the corresponding write register.

Examples

For SPI in the examples below, "data sent" means the data on the MOSI line, while "data received" means the data on the MISO line. when MISO reads "xx" you should ignore the data. When MOSI reads "xx" it doesn't matter what you send.

For I2C in the examples below, you should first initiate a "write" transaction with the data in the "data sent column". Don't send the "xx" bytes. Then you initiate a "read" transaction, and you will get the data in the "data received" column (and again not the "xx" bytes).

Read identification

read the identification string of the board. ('spi_servo 1.0').

data sent data recieved explanation
0x87 xx select destination with address 0x86 for READ.
0x01 xx identify
xx 0x73 's'
xx 0x70 'p'
xx 0x69 'i'
xx ... etc.