Never done Modbus before, so bear with me. Reading a power meter over Modbus TCP into a CPU 1214C, TIA V17, MB_CLIENT, for the compressor room energy screen.
The meter manual says voltage L1 is at register 3000 and current L1 at 3002, both 32 bit float. I set MB_MODE 0, MB_DATA_ADDR 43000, MB_DATA_LEN 4, into an array of 4 words. No error, STATUS 0, data arrives every second.
But the values are wrong. Voltage shows a huge number or zero and current shows something around 230, which looks like the voltage, as if the whole lot is shifted by a register, so I swapped the byte order in the conversion and that did nothing, and MB_DATA_LEN 6 did nothing either. Meter display says 231 V and 4.2 A.
What am I doing wrong with the address? I think the 3000 in the manual and the 43000 I typed aren't the same thing, but I can't see where the extra one goes.
Before the block, prove the meter. With a laptop Modbus tool, read holding register 3000 and see what comes back. If the tool shows 231 V at 3000 and the PLC doesn't, the problem is in how the block counts, not in the meter.
Did it with a Modbus tool on the laptop. If I type 3000 in the tool with the base set to 0, I get the float for 231 V. With base 1 I have to type 3001 for the same value.
So the manual is 0 based? Stuck on what that means for MB_CLIENT though.
Off by one, the oldest Modbus problem there is and I have lost days to it myself.
The manual's 3000 is the protocol address, counting from 0. MB_CLIENT's MB_DATA_ADDR uses the 4xxxx convention, which counts from 1, so holding register 0 is 40001. Your 43000 asks for protocol address 2999, one below the voltage, and everything lands one register early. Set MB_DATA_ADDR to 43001 and the voltage comes in at word 0 and 1, current at 2 and 3.
Then check the word order for the floats separately, the meter's manual says which half comes first. That is a different setting from the byte swap.
Longer version with the register map is here: https://plctr.com/understanding-the-communication-protocols-for-plc-and-scada-systems/
Changed MB_DATA_ADDR to 43001, voltage reads 231.4 and current 4.2 now, same as the meter display. Manual counts from 0, block counts from 1, add one to the address. That's all it was.
I had it backwards, I thought 40001 meant register 1. The word order was already right by luck, the meter sends the high word first.
Energy counter at 3100 is a 64 bit value and I've no idea how to put four words together yet, might be another thread. Thanks marcob and marekw.
Prove the meter first. Every time.