Modbus swapped float registers

shrirampendse

Member
Join Date
Dec 2006
Location
Pune, India
Posts
157
Hello,

I am trying to connect Rish Energy meter on Modbus RTU 9600 , 8 , N ,2 to M340 PLC or Delta PLC. PLC can read the data but it cannot be utilised in logic as every incoming data is four bytes (two consecutive registers e.g. 40071 and 40072 etc) in SWAPPED FLOATING POINT format. How do I convert these two registers to real value in PLC?
As a temporary measure I hooked EM to VijeoCitct SCADA using its byte swapping function. But that is only quick fix, Energymeter must connect to PLC only. Rish EnergyMeter support help is of no use as they know only this format and cannot give data on any other format.
Any solutions? Thanks.
 
Mudbus RTU just supports 16 bits data transmission , So when transmitting float point,the data must be divided into two consecutive registers,it's modbus's rule.
I think your PLC should have the function what can link 2 ints to be a float.
 
I assume that with M340 you mean Telemecanique/Schneider's Unity M340 PLC.

Copy integers to two consecutive register first, but swap register when you use move command. (Eg. move register 40071 to 40180 and 40070 to 40181.)

After that use dint to real conversion to register 40180 & 40181. (registers 40180 % 40181 = %MD180 on Unity PLC


p.s.

You can also use int as dint and dint to real conversions. If you use this method, you don't need move integers to different register area...


Lare

swap_integers.jpg
 
Last edited:
Struck at the same point in Delta PLC

Hi seniors,

I'm also working on the same kind of application to read Current from a digital meter thorugh RS485 modbus which supports only FLOATING point data.,

I could able to read the values in PLC, but the values are like swapped., I tried the above steps my moving it to vice versa registers and tried FLT & DFLT instructions (integere to float)conversion.. But it's unsuccessful..

I'm really missing out something..

I've attached my program for your reference..

Please provide your suggestions..

Screenshot of Program
 
Last edited:
Dear MageshBhai,
It seems you are working on Delta PLC. If you have DOP HMI it is very simple to hook Rishabh to it. Just select datatype as real .
shriramdotpendseatyahoodotcom
 
I found way around to configure the energymeter to send data in real instead of swapped float. This solves the problem of conversion from swapped to normal.
 
If the energy meter has a little endian/big endian bit turn it on or off - voila!
The other method is to use either a SWAP or MOVE command in the PLC - just did that last week as I was away and did not have the gear with me to get into the energy meter and change the endian bit - had to move everything into the right order - it is pretty easy - just time consuming.
I have had one worse than just swapped words - it had swapped bytes as well - spend days coding that lot!
 
Rish swapped float

This Modbus device has a special register to set byte order, I dont remember , it might be 40021 (pls refer its manual).
If you write value 2141.0 into this register , device automatically sets its float format as per master format (your format). Power off and then on. Now onwards you receive float data as per float format in master.

Can you tell us what that 'way around' is?
 
Just byte swapping might not help.You may need word swapping too.
Try a b c d , b a d c , c d a b , d c b a one should match masters byte pattern.
In VijeoCitect we can select such byte order, take a try one should match your format .
 
[rant] Modbus is a kludge and wasn't designed for sending floating point. However, Modicon does have a standard way that they send floating point and that is the standard that should be used. There should be NO options to swap bytes or words necessary. The device designers should design the Modbus devices to work with Modicon PLCs. [/rant]

The word data is always sent big endian. The high byte is sent first. However, word in a REAL are sent little endian with the low word sent first. I know it doesn't make sense and is confusing but that is the way it is.
 
Thank you BobB, Shriram and Peter Nachtwey.,,

Will check it again in PLC for the swap function...

Just for reference this is the Modbus address table for my Energy meter.,
 
Last edited:
You may find MOV is appropriate move the first word to a second register and move the second word to a first register - that is all I normally do when working with this as many devices do not even have a little/big endian bit..

All very well to have a rant Peter, and I do not disagree with you, - you just have to learn to live with the facts of life - manufacturers implement this differently. I have to work with Crompton, Woodward, Schneider, Terasaki, Carlo Gavazzi and probably 20-30 others. Very few are the same.

Then most manufacturers will allow 8, 1, none - , Schneider stick to the rules and it has to be 8, 2, none. Or with parity you can usually get away with 1 stop bit with Schneider.

And then there is the devilish CAN J1939 where you have a value, precision and offset and have to do the lot in floating point! Used by most of the diesel engine manufacturers.

Then there is my least favorite horror - BACnet! Half the 'tested' BACnet devices will not even talk to each other!!!!!

Another day in the life of a systems integrator.
 
Atlast solved the problem today at 1:15AM ;).,

Since there are totally four bytes of data,

I combined the first two bytes with swap and last two bytes data with swap ., Now I got two 16bits data..All this can be done with a single instruction "DTM" - Data transform and move.

Again this data is swapped and now I got the format of the data matching the Energy meter..

The result is a floating point data,but floating values are not directly visible in registers through online mode .,Whereas it shows correctly in the watch window..

So gave it a multiplication factor of 1000 and converted the floating point data to Integer for easy handling of data..

Bang ,the headache is over now..

I sincerely thank everyone for their kind support and spending their valuable time to educate me..

Thanks to Shriram, BobB, Peter and everyone..

 

Similar Topics

Hello, fellow PLC enthusiasts, I’m a newbie in PLC and am currently on a project that involves connecting an Omron CP1E (CP1W-CIF11) PLC to an...
Replies
1
Views
34
I am new to this forum and would need your help. I am looking for the Modbus FBs for the S5 95U for communication with the CP521. These FBs...
Replies
0
Views
15
Hello Everyone, I am using a raC_Opr_NetModbusTCPClient AOI module, as below,. So, I need some assistance to restrict in reducing the poling...
Replies
2
Views
152
I want to communicate my Q series PLC with Factory IO using GX works 2 software, I want to use modbus as server and the ips are as follows plc...
Replies
0
Views
103
Hi folks, I have a Controllogix in communication with a zigbee coordinator using Logix AIO for modbus tcp. This zigbee coordinator have 3 slaves...
Replies
10
Views
387
Back
Top Bottom