Search code examples
c#modbusmodbus-tcp

Reading Different Elements from Modbus-TCP


I'm trying to figure out how to read different values from a modbus device (Powerscout 24) for different elements. There is a manual here which says

ADDRESSING AN ELEMENT

The PowerScout 24 has eight elements. Modbus and BACnet each use different ways to designate an element on the PS24. In Modbus mode, the decimal network switches set the base address for metering element “A.” Metering elements “B” through “H” will always have a Modbus address that is one higher than the element before. For example, if the rotary address switches are set to 001 then metering element “A” register values will be accessed at Modbus address 001, element “B” registers will be accessed at Modbus address 002, element “C” at address 003, and so on.

So from my understanding, if i wanted to read the value at register 4012 on Element A (or Slave 1) I would read the holding register at 4012.

If i wanted to read Element B, the register would be 4013? But how can this be, 4013 is used for a different value - Displacement PF System. (Check top of page 65)

I've tried using this library EasyModbusTCP

ModbusClient modbusClient = new ModbusClient("192.168.1.250", 502);    //Ip-Address and Port of Modbus-TCP-Server
modbusClient.Connect();                                                    
int[] readHoldingRegisters = modbusClient.ReadHoldingRegisters(4000,1);
//Read 10 Holding Registers from Server, starting with Address 1

I've tested this and it works in the sense that it can only read registers for element A (slave 1). I havent been able to figure out how to read registers for the other elements.

I checked the other part of the library (RTU - read from serial ports) and this defines a slave to read from, but I need to read the device over TCP not serial so I cant implement it this way.

Can anyone explain how I can read different elements via TCP?


Solution

  • So I found a solution to reading specific elements (Slaves). From the easy modbustcp you can change the UnitIdentifier of the modbus client.

    modbusClient.UnitIdentifier = 3;
    

    This will make any reads to the modbus client read from the 3rd element.