Modbus Register And Bit Value


ledbelly2142

Recommended Posts

I have a modbus registry value that is the status of 5 relays in bit representation... the bit values indicate the on/off stat of the relays in order (e.g. 1, 2, 3, 4 ,5).

The variable value component reads the binary notation and converts it into a number, which I think is normal. So when some of the relays are on, I get a value of "9".

How can I display the registry value in bit representation, and how can I make it useable for logging relay run time?

I would like to log relay 1 runtime, relay 2 runtime, etc...

Thanks

Link to comment
Share on other sites

I'm not doing something right. The bits are not accurate and some are -0...

Here is what I have in the channel (channel=RelayStatus) event:

private bits = to.Bit(RelayStatus[0])

Relay1.addvalue(bits[0][0])

Relay2.addvalue(bits[0][1])

Relay3.addvalue(bits[0][2])

Relay4.addvalue(bits[0][3])

Relay5.addvalue(bits[0][4])

I am think that the second [0] in the Relay.addvalue lines identifies the bit (sequentially) in the registry value. But I also thought that using [0][0] together was identifying a two dimensional array.

Thanks

Link to comment
Share on other sites

Just reread the documentation, the bit order is from the LSB (least significant bit)... so the first relay (I think) should be

Relay1.addvalue(bits[0][7])

Relay1.addvalue(bits[0][6])

but this does not work either. I have some formatting issue, the bit values seem random with -1, -0, 0, and 1.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.