I have some measurements coming in from over Modbus TCP/IP and I have successfully identified the values that I'm trying to measure.
However the values all differ by some amount from the measurements.
For example the voltage should be at 232 V, but the value I am getting is 17256.
The current at 0.04 A is sent as the value 15646.
I also have a measurement of a current at 0 A, but due to noise it is hard to say which value is the correct one. It seems to be around 14860.
Real power at around 4.55 W is sent as 16530.
Is there something about modbus that I don't understand or is there a pattern that somebody can identify?
Thank you!
It is commun to see some PLC or slaves that returns a value with a special byte order. I would recommend you to check the datasheet about that. For example Sofrel slaves sometimes have a byte order of B3B2B1B0 but I already experienced some slaves with a byte order of B1B2B3B0.(B3 is the MSB B0 the LSB)
Which is really not conveniant when you are reading with a sofware that is not allowing byte order changes.
For this I would recommend you to use ModBus Doctor. ModbusDoctor Swap Bytes
And if you want to quickly check this, here is a usefull site that I usualy use : https://www.scadacore.com/tools/programming-calculators/online-hex-converter/
It shows all the possibilities from a value.
NB: Sometimes there are also some calculations to do, it is usually written on datasheet of the PLC. But you didn't put any clue about the slaves that you are reading. If you want some help please include it.
So maybe in your case both have to be made : swap orders + calculations to have the correct value.
I hope that i might help you a bit. Good luck, if you can read data you've done the hardest part ! Just make sure that you are reading the correct register with the code function code (Input, Holding register etc.) This is a commun mistake.
All ModBus Function codes : https://ozeki.hu/p_5873-modbus-function-codes.html
Edit :
Solution : Yes found it ! You are on a Big Endian format
Proof of Concept : "The current at 0.04 A is sent as the value 15646."
15646 is hexa = 3D1E
3D1E in Big Endian Float -> 0.03857422. Sounds correct to me.
Same thing with "For example the voltage should be at 232 V, but the value I am getting is 17256."
17256 in hexa : 4368
4368 in Big Endian Float is 232 !
I think you are getting float as a result in Big Endian.
Here is a quick note about Big Endian :
https://chortle.ccsu.edu/AssemblyTutorial/Chapter-15/ass15_3.html
Looking forward to seeing your answer :)