Unexpected number when reading PLC using pymodbus
<p><a href="http://i.stack.imgur.com/rYMVB.png" rel="nofollow"><img src="http://i.stack.imgur.com/rYMVB.png" alt="enter image description here"></a>I am using pymodbus to read a register on a Wago 750-881 PLC. I am also reading the same register on the Modbus Poll utility, as well as, an HMI. The Modbus Poll and HMI are reading correctly, but the pymodbus program is not. </p>

<p>Here is the code:</p>

<pre><code>from pymodbus.client.sync import ModbusTcpClient

c = ModbusTcpClient(host="192.168.1.20")
chk = c.read_holding_registers(257, 1, unit = 1)
response = c.execute(chk)        
print response.getRegister(0)
</code></pre>

<p>Here is the response from running the code:</p>

<pre><code>&gt;&gt;&gt; runfile('C:/Users/Mike/modbustest2.py', wdir='C:/Users/Mike')
18283
</code></pre>

<p>The correct output should be 2043. It also reads the same number "18283" on the other registers. I know the problem must be code related since I can read the register from other programs/devices. Any help is appreciated. </p>

<p>You may be reading the wrong register, or from the wrong unit ID, or some combination of both.</p>

<p>If you use Wireshark to capture what the 3rd party software and your own software is doing you should be able to spot the difference pretty quickly.</p>

python python-2.7 modbus modbus-tcp