Search code examples
c#serial-portmodbusplc

NModbus4 startAddress is more than ushort can handle


I'm programming a PLC with a C# application with NModbus4. (RS232)
I can read data with master.ReadCoils(device, 8192, 1).

Now i've an address like 149153. This is to long for a ushort so i can't pass it as a parameter to ReadCoils.

How can i do this?


Solution

  • The PLC is using a very common address notation for Modbus (although not standard), where the first digit defines the register's data type:

    • 0 (coils)
    • 1 (discrete inputs)
    • 3 (input registers)
    • 4 (holding registers)

    So, data at address 149153 is actually the discrete input at address 49153.