Main Site Documentation

Relay x16 Board


#1

Hi,

Relay x16 Board has several registers that can be read using I2C, so according to manual it should be possible to read current relays status. Can anyone help how to do it?

Basically the goal is to:

  1. Read current status of relays
  2. Set up relays according to previously read status

Regards,
Jack


#2

I suggest you lookup the part number of the port expander used on the board, find the datasheet and there will be all details.

The way I would do tit is simple keep flags in my code of what is the current relay state is.


#3

The thing is that I would like to read state after Panda II reset.

According to manual (in attachement) this should be achieved by reading Data Port Registers GP0 and GP1 or Ouput Latch Registers OLAT0 and OLAT1.

None of them are presenting expected values. Maybe something is wrong with my code.


I2CDevice I2C = new I2CDevice(new I2CDevice.Configuration(0x20, 100));
I2CDevice.I2CTransaction[] xaction = new I2CDevice.I2CTransaction[2];
xaction[0] = I2CDevice.CreateReadTransaction(new byte[] { 0x00 });
xaction[1] = I2CDevice.CreateReadTransaction(new byte[] { 0x01 });
if (I2C.Execute(xaction, 100) == 2)
{
    Debug.Print(xaction[0].Buffer[0].ToString()); // GP0
    Debug.Print(xaction[1].Buffer[0].ToString()); // GP1
}

Should IODIR0 and IODIR1 set to input before reading, and then to output before writing?

Thanks for help in advance.


#4

Manual ZX-Relay16.pdf
http://www.sendspace.com/file/xcptny