从 Modbus-TCP 读取不同的元素

Reading Different Elements from Modbus-TCP

我正在尝试找出如何从 modbus 设备 (Powerscout 24) 读取不同元素的不同值。有一个手册 here

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.

所以根据我的理解,如果我想读取元素 A(或从属 1)上寄存器 4012 的值,我会读取 4012 处的保持寄存器。

如果我想读取元素B,寄存器应该是4013?但这怎么可能,4013 用于不同的值 - Displacement PF System。 (查看第 65 页顶部)

我试过使用这个库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

我已经对此进行了测试,它的工作原理是它只能读取元素 A(从属 1)的寄存器。我还没弄清楚如何读取其他元素的寄存器。

我检查了库的另一部分(RTU - 从串行端口读取),这定义了一个从设备来读取,但我需要通过 TCP 而不是串行读取设备,所以我不能以这种方式实现它。

谁能解释一下我如何通过 TCP 读取不同的元素?

所以我找到了读取特定元素(奴隶)的解决方案。从简单的 modbustcp,您可以更改 modbus 客户端的 UnitIdentifier。

modbusClient.UnitIdentifier = 3;

这将使从第 3 个元素读取到 modbus 客户端的任何读取。