6/1/2010 5:07 PM | |
Joined: 9/27/2006 Last visit: 12/4/2023 Posts: 12188 Rating:
|
Hello david; I believe that this is a common issue with Modbus drivers, called the Big-Endian problem. The name refers to Swift's Gulliver 's Travels, where a war is declared between Lilliput and its neighbor because of the end of the boilded egg that they chose to crack. In computer systems, Intel and Motorola processors chose to organise bytes in a different order, and cause some conversion issues; Modbus comms between 2 systems based on different microcontrollersare particularly subject to the issue. Have a look here for more technical details: http://en.wikipedia.org/wiki/Big_Endian Now, some Modbus masters on the market do have a byte swap command that can correctthe issue when it is discovered (Prosoft implements it on its Rockwell controllogixModbus masters), but the Siemens CPs do not. You have to do it by hand (note that often we also had to do it by hand on our controllogix, as the swap byte command did not seem to resolve issues with REAL tags, as they extend over 4 bytes). First I suggest that you try to echange one regiter between the CP 441-2 and your target slave, and see if what you recieve makes sense. If the value you read does not match what you expect, then proceed with the byte swaps. For example, you could use the following STL instructions: You can use the following Change Bit Sequence in Accumulator 1 instructions to reverse the order of bytes in the low word of accumulator 1 or in the entire accumulator: • CAD Change Byte Sequence in ACCU 1 (32-Bit) Do it word for word as you place data into your DB, or create a Loop that will go through your DB and exchage the bytes. Hope this helps, Daniel Chartier |
This contribution was helpful to
1 thankful Users |
6/1/2010 6:44 PM | |
Joined: 3/21/2006 Last visit: 12/4/2023 Posts: 10222 Rating:
|
Hello, Tomorrow morning (if wouldn't be so late), I'll attach one example source of function which move word plus swap it. As I promised. Look at attachment. Best regards, Hristo Mihalev AttachmentSwap.zip (156 Downloads) |
Last edited by: UMENCHO at: 6/2/2010 3:37 PM |
|
Follow us on