I try to integrate our Dupline bus system. Reading boolean values is ok, as well as reading integer values.
But when trying to set a boolean value, an error message occurs (“An error was found in received data”).
The reason most likely lies in the fact that e.g. the address to write is HR4001 (Bit 6), while the corresponding address to read is HR4 (Bit 6). The PLC does not allow to read from the address to write to (and the function codes differ naturally).
Is there a way to solve this?
Equipment: iPad 2, Moxa Serial Device Server N5150
ScadaMobile (or Modbus Gem) use modbus function 22 (write mask register) to set individual bits of a modbus register to prevent altering the remaining ones. Not all PLC, and specially small RTUs do support this command.
For reading, the app uses register read functions that are supported by all modbus devices. Individual bits are then extracted form the registers.
For writes, if your PLC does not support modbus function 22, then individual writes of Bits on HR registers may not be possible with the SM app. You can alternatively use Coils for this purpose.
Either with coils or registers there is a way to write a register without ever being read. You must have a hidden row for that register (so that it is never read), and then you set values to it using a ‘value’ expression. For example
- First row will read and display HR4.6 in the usual way,
- Second row is hidden and will write HR4001.6 depending on the state of ‘the_bit’. This assumes that function 22 is supported on your PLC
- Third row creates a switch control for ‘the_bit’
If function 22 is not supported on your PLC, then you can replace the second row by this
write_only_register, INT, HR4001, “label=”"write only”"; hidden=1; value = the_bit*64;”
However, beware that using this may lead to inconsistencies if you are using other bits on the same register.
HOWEVER: The error you get: “An error was found in received data” implies an incorrect Modbus frame being received from the PLC. This triggers a network disconnection on the ScadaMobile side. All modbus slaves are supposed to return a well formed modbus error frame when they do not understand a command or when they are unable to execute a command. This means that all being OK, this error should never appear and therefore it almost surely implies some sort of bug at one side of the communicating devices (either the SM app or the RTU device). I am sending you a private message to discuss how we can look at this.