Difference between revisions of "POWER protocol"

From BitWizard WIKI
Jump to: navigation, search
(write ports)
(read ports)
 
Line 31: Line 31:
  
 
{| border=1
 
{| border=1
!rowspan="2"|port !!colspan="4"|available on !!rowspan="2"|function  
+
!port !! function  
 
|-
 
|-
! DIO !! 3/7FETs !! RELAY !! pushbutton
+
| 0x01 || identification string. (terminated with 0).
 
|-
 
|-
| 0x01 || X || X || X || X || identification string. (terminated with 0).
+
| 0x02 || read eeprom (serial number).  
|-
 
| 0x02 || X || X || X || X || read eeprom (serial number).  
 
 
|-
 
|-
 
| 0x20 || read  the turn-off-time left. 32-bits, in ms.
 
| 0x20 || read  the turn-off-time left. 32-bits, in ms.

Latest revision as of 17:13, 30 May 2014

Introduction

The protocol for the POWER board 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.

Please see this page for the default addresses.

write ports

The POWER boards define several ports:

port function
0x20 set the turn-off-time. 32-bits, in ms. This is an offset into the future. So specify 4000 to turn off in 4 seconds.
0x21 set the turn-on-time. 32-bits, in ms. Specify e.g. 600000 to turn the system back on in 10 minutes. This starts counting as soon as you set it.
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.

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).
0x20 read the turn-off-time left. 32-bits, in ms.
0x21 read the turn-on-time left. 32-bits, in ms.

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_POWER)

data sent data received explanation
0xa5 xx select destination with address 0x84 for READ.
0x01 xx identify
xx 0x73 's'
xx 0x70 'p'
xx 0x69 'i'
xx ... etc.

read the identification string of the board. (I2C_POSER)

I2C master I2C slave (i2c_dio) explanation
START -- start I2C transaction
0x84 -- select destination with address 0x84 for write (set port).
0x01 -- identify
STOP -- terminate I2C transaction.
START -- start I2C transaction
0x85 -- select destination with address 0x84 for READ.
-- 0x69 'i'
-- 0x32 '2'
-- 0x63 'c'
-- ... etc.

Note that in the SPI example, there is bidirectional datatransfer on every cycle, but the data is "don't care" or "must ignore" (indicated by xx), while in the I2C case, the other side cannot send as there is only one data-transfer direction (indicated by "--").

turn on ten minutes from now

data sent data recieved explanation
0xa4 xx select destination with address 0xa4 for WRITE
0x21 xx port address: set turn-on-time
0xc0 xx lowest byte of 600000 ms = 0x927c0 ms is 0xc0. - 0x27 xx

-

0x09 xx
0x00 xx MSB.

turn off four seconds from now

(on your raspberry pi you can do this from your /etc/init.d/halt script just before the "halt -d -f ..." command. )

data sent data recieved explanation
0xa4 xx select destination with address 0xa4 for WRITE
0x20 xx port address: set turn-on-time
0xa0 xx lowest byte of 4000 ms = 0xfa0 ms is 0xa0. - 0x0f xx

-

0x00 xx
0x00 xx MSB.