Difference between revisions of "DIO protocol"
Line 4: | Line 4: | ||
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. |
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 DIO board is 0x84. |
|||
The default address of the 7FETS board is 0x88. |
|||
The default address of the 3FETS board is 0x8A. |
|||
= write ports = |
= write ports = |
Revision as of 16:27, 11 May 2012
Introduction
The protocol for the DIO, 3FETs and FETs will be explained on this page. Most functions apply to all three boards, but some don't.
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 DIO board is 0x84. The default address of the 7FETS board is 0x88. The default address of the 3FETS board is 0x8A.
write ports
On the DIO and related boards all ports just set a single value. So writing more than one byte to such a port is redundant. The last value is the one used. The DIO boards don't have any ports that are logically a stream of bytes. So writing more than one or two bytes is not encouraged.
The DIO, 3FETS and 7FETS boards define several ports:
port | function |
---|---|
0x10 | set all outputs (bit 0 is output 0, etc). |
0x20 .. 0x27 | set one output (0x20 for output 0, 0x21 for output 1 etc) |
0x30 | define pins as inputs or outputs. 0 means input, 1 means output. |
0x40 | set current position. (only DIOand 7FETS) |
0x41 | set target position. (only DIO and 7FETS) |
0x42 | set relative position. (only DIO and 7FETS) |
0x43 | set stepdelay. (in tenths of a microsecond, default 200: 20ms between steps). (only DIO and 7FETS) |
0xf0 | change address. |
All the above ports are read/write. I.e. if you read from that port, you will get the current value.
read ports
The DIO, 3FETS, and 7FETS boards support the following read ports:
port | function |
---|---|
0x01 | identification string. (terminated with 0). |
0x02 | read eeprom (serial number). |
0x10 | read all inputs |
0x20 .. 0x27 | read one input (0x20 for input 0, 0x21 for input 1 etc) |
0x40 | read current position. (only DIO and 7FETS) |
0x41 | read target position. (only DIO and 7FETS) |
0x43 | read stepdelay. (in tenths of a microsecond, default 200: 20ms between steps). (only DIO and 7FETS) |
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_DIO)
data sent | data received | explanation |
---|---|---|
0x85 | xx | select destination with address 0x84 for READ. |
0x01 | xx | identify |
xx | 0x73 | 's' |
xx | 0x70 | 'p' |
xx | 0x69 | 'i' |
xx | ... | etc. |
turn on all outputs
data sent | data recieved | explanation |
---|---|---|
0x88 | xx | select destination with address 0x88 for WRITE |
0x10 | xx | set outputs as in bitpattern (next byte) |
0xff | xx | All outputs active. |
turn on output 4
data sent | data recieved | explanation |
---|---|---|
0x88 | xx | select destination with address 0x88 for WRITE |
0x24 | xx | port 0x24: output 4... |
0xff | xx | ... active. |
move stepper to step 0x1234
data sent | data recieved | explanation |
---|---|---|
0x88 | xx | select destination with address 0x88 for WRITE |
0x41 | xx | port 0x41: set target position |
0x34 | xx | low byte |
0x12 | xx | high byte. |