Technical Forum

SIMATIC WinCC

WinCC to S7 Byte Swap

Thread Starter: BWS   Started: 2/13/2008 9:10 PM   Replies: 3

« Previous thread Next thread »
Page 1 of 1 (4 items)
  2/13/2008, 9:10 PM
Joined 2/13/2008
Last visit: 10/8/2008
Posts: 22
Rating:
Rated: Outstanding [4 out of 5 / rated 1 time(s)]. (1) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
I am trying to read alarms from the S7 PLC via 32bit Double words.  Each bit in the word represents an alarm.  When the word is read in WinCC, the bits do not match the bits in the PLC.  I have compared the two and the bytes are being swapped. 

Example:  Consider I have four bytes named 1, 2, 3, & 4.  If the PLC sends them in this order 1234, WinCC reads 2143. 

How can I remedy this problem?  I know I could just read individual bytes, but this will increase the number of tags I have to input into WinCC and PLC.  Is this problem on the WinCC side or the S7 side?  Thanks for any help!!
Top
  2/14/2008, 1:00 PM
Joined 10/11/2006
Last visit: 10/20/2014
Posts: 1775
Rating:
Rated: Outstanding [3.42 out of 5 / rated 81 time(s)]. (81) 
Users with special expertise supervising conferences
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Hi,

maybe this FAQ helps

http://support.automation.siemens.com/WW/view/en/22127697
Top
  2/14/2008, 1:33 PM
Joined 2/13/2008
Last visit: 10/8/2008
Posts: 22
Rating:
Rated: Outstanding [4 out of 5 / rated 1 time(s)]. (1) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
I am assuming that the dialog box shown in the FAQ is from the Step 7 software.  It appears that this checkbox only changes from Big Endian to Little Endian and vice versa.  This is not the problem that I am seeing in the communication b/w the S7 and WinCC.  The most significan bit in a double word would be bit 31.  However, when I read a double word from S7 to WinCC, the most significant bit is actually bit 23.  The communications is swapping the first and second byte positions as well as the 3rd and 4th byte positions.  It is not change the order from 1234 to 4321 is is changing it from 1234 to 2143.  Any ideas?
Top
  2/20/2008, 12:40 PM
Joined 4/19/2006
Last visit: 4/17/2014
Posts: 1275
Rating:
Rated: Outstanding [3.99 out of 5 / rated 113 time(s)]. (113) 
Users with special expertise supervising conferences
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
  Hi,

   Unfortunately, there isn't a "fix", since this isn't a problem, it's only the communication driver doing it's job.. This happens due to Siemens' memory allocation. When you declare a double word, bytes are swapped just like that internally.
  You said you've declared a Double Word in WinCC to read the data. If the Double Word contains alarm bits, I'm assuming you've used either bits or UDT's in S7. So Step7 has bits, WinCC has a Double Word. The communication driver sends the data from Step7 without swapping the bytes, since as far as S7 knows, they're just bits (UDT's are considered bits when it comes to byte swapping). However, when WinCC reads the data, it assumes that, since it's a double word, the bytes had been swapped before, so while trying to read the data correctly, it messes it up. To fix this you should either read the data as bytes (words also have byte swapping), or send the data as a double word on the PLC side.

  Best regards,

  Danielle



=== Edited by Danielle @ 20.02.2008 12:41 [GMT ] ===



Danielle Crespo Cavalcanti

Simatec Tecnologia em Automação
Belo Horizonte - MG - Brazil
www.simatec.com.br
Top
Page 1 of 1 (4 items)
Actions