DIO protocol

From BitWizard Wiki
Jump to navigation Jump to search

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.

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 spi_dio, spi_3fets and spi_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 spi_dio and spi_7fets)
0x41 read target position. (only spi_dio and spi_7fets)
0x43 read stepdelay. (in tenths of a microsecond, default 200: 20ms between steps). (only spi_dio and spi_7fets)

examples

read identification

read the identification string of the board. (spi_dio)

data sent data recieved explanation
0x85 xx select destination with address 0x82 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.