Modbus Data (Double Word, Byte Swap?)

Andy6

Member
Join Date
Apr 2011
Location
In the garage.
Posts
140
Hi guys

I'm having some weird data conversion issue over modbus happening. And I found a post here before that is similar to what I'm seeing but no solution was found. http://www.plctalk.net/qanda/archive/index.php/t-76329.html

I have a GE Quickpanel talking to a Schneider M340. Booleans are transmitting properly. The problem comes up when I'm moving DINT and LREAL back and forth.
A value of 1(1.0) in the PLC comes in as 16256 on the HMI.
2(2.0) = 16384
3(3.0) = 16448
10(10.0) = 16672

I've seen mention online about Double Word, but I don't believe you can address double word in the M340?

Anybody have any ideas?

Thanks,
 
I'm pretty sure that you can do either DWORDs or DINTs in the M340. I'd check that again.

I've never used one of those GE displays, but with Red Lion displays it is possible to switch the word order in a double. For example, instead of using the bytes in the order 1234, you can use they bytes in the order 3412. This makes it simple to rearrange the order that it pulls the information. Come to think of it, this is probably mainly an issue of how the GE is interpreting the data it is getting.
 
Hi guys

I'm having some weird data conversion issue over modbus happening. And I found a post here before that is similar to what I'm seeing but no solution was found. http://www.plctalk.net/qanda/archive/index.php/t-76329.html

I have a GE Quickpanel talking to a Schneider M340. Booleans are transmitting properly. The problem comes up when I'm moving DINT and LREAL back and forth.
A value of 1(1.0) in the PLC comes in as 16256 on the HMI.
2(2.0) = 16384
3(3.0) = 16448
10(10.0) = 16672

I've seen mention online about Double Word, but I don't believe you can address double word in the M340?

Anybody have any ideas?

Thanks,

The M340 will return whatever you ask it to, Modbus doesn't know anything about REAL or DINT its your driver or the HMI end that will do the work, %MW in the M340 are just 4xxxx registers.

So if you had a DINT or REAL declared in the M340 on %MW10 it would be %MW10 and 11, set that as a DINT or REAL in the HMI and and all should be good.

Can't remember the word order off the top of my head though but a quick check with ModPoll would confirm that.

Or you could just use a Schneider Panel :whistle:
 
In the Quick Panel, use the OPC driver instead of the native Modbus driver. The OPC driver gives you more options for interpreting the data. Under the "Settings" tab of the driver properties, there are check boxes for how you want to order the bytes you receive from the Modbus device for 32-bit variables.
 
Hi Andy6,

Have you found out what is the reason behind your question? Because I seem to have a the exact problem. I am transferring via Profibus from a Wago controller to the Siemens controller and when I sent a real number in Wago of 1.0, the Siemens PLC reads it as 16256 and so on, similar to yours.

Thank you
 
I have seen cases were byte order was an issue in modbus communication. Also word order within DWORD, meaning one side is expecting an order of W1 W2 whereas the other does W2 W1. A real is typically 4 bytes, two words, so passing a real in the context of modbus communication means a DWORD is passed.

For these cases you could assign your real value to a DWORD, then swap the words by performing a bitwise rotation over 16 bits, which is effectively the same as swapping the words. For this you could create and use the following function in your Wago controller (it is ST).

Code:
FUNCTION SWAP_WORD : DWORD
VAR_INPUT
    IN : DWORD;
END_VAR

SWAP_WORD := ROL(IN, 16);
(similar to function SWAP_BYTE in the Oscat library for swapping the two bytes in a word value)
 

Similar Topics

I have 9 field devices, three METSEPM5110 power meters and six ACE949-2 rs285 interface modules. I want to read this Modbus rtu data through rs485...
Replies
8
Views
315
Hey all, I am trying to find a way to get data from a local device webpage into a modbus server for a customers SCADA. The customer was hoping...
Replies
3
Views
433
I am using a Beckhoff PLC and trying to convert a REAL to 2 WORDS to send over Modbus. Does anyone know how to do this? Also how would I convert...
Replies
5
Views
794
I am working on a project, inside an AB CLX, I implemented the Modbus TCP Client AOI published on AB website, to interreact with a Modbus ASCII...
Replies
7
Views
3,557
I've got 16-bit data at address 40200 on a Schneider Scapack 350. I can grab the data over Modbus TCP using Kepware at IP 172.16.1.100. When I...
Replies
8
Views
2,494
Back
Top Bottom