Modbus Holding Register Bit Read/Write

I’m trying to read/write the bits out of holding register with the following format:

[PLC]1.40581.1

I get errors of “Bad Quality”. Is there something I am missing? Is the bit level read not supported in Ignition?

Thanks

Well, ‘40581’ isn’t a valid address, unless you’ve set up a mapping that happens to have a ‘40’ prefix…

I did - I read the bit just fine - can’t write.

The ability to write to the bit is entirely dependent on whether the device you’re talking to supports the Mask Writer Register (0x16) function code.

There’s probably an error message in your gateway console about the function not being supported, or if you’re less lucky, the device simply doesn’t respond and you have a message about a request timing out.

Would illegal function be a pretty good indication that it is not supported?

A very good indication, yes :slight_smile:

As a work-around you can make a writeBit() scripting function and put it in an app.* module for re-use.

This may be a good place to start:
viewtopic.php?f=71&t=5556&p=32760&hilit=writeBit#p32760

Hi Kevin,

This thread describes a problem I am currently experiencing. Since the last post is over 3 years old I’m wondering if there are any updated solutions or if I should go the scripting route you described in the previous post? We are on version 7.8.3.

Thanks

[quote=“Nate.Olson”]Hi Kevin,

This thread describes a problem I am currently experiencing. Since the last post is over 3 years old I’m wondering if there are any updated solutions or if I should go the scripting route you described in the previous post? We are on version 7.8.3.

Thanks[/quote]

Yes, if you’re certain the device does not support function code 0x16 (MaskedWriteRegister) then you need to do it via scripting.

Kevin,

I was able to find some documentation that does indicate the device supports function code 0x16 (see attachment). I also included the error I am seeing in the console. And for a little more information I attached a conversation from Moxa tech support. We are using the device to go TCP to the PLC.

I’m wondering if there are some additional diagnostics or configuration options you could point me to in Ignition?

Another thing that is strange is we are using a different product on the serial side of the Moxa and that is writing to the same point using function code 0x6. I’m wondering why that is using a different code?

Thanks,
Nate

MaskWriteRegister (0x16) is the only function code you can use to safely write to a bit within a register.

0x06 is WriteSingleRegister. If the other software is writing to a bit using this code it’s doing it by reading the current value, twiddling the bit in question, then writing that new value back down, which is obviously a non-atomic and non-safe operation.

Our driver won’t do this for you, but you can do the same thing yourself in scripting (there’s a couple threads on this topic).

I couldn’t say with any certainty whether your device or the Moxa is the one that doesn’t support function 0x16, but there’s not really any room to dispute or otherwise diagnose that response on the Ignition side.