Technical Forum

SIMATIC WinCC flexible

Integer word: High byte and low byte

Thread Starter: DRA_Employee   Started: 9/17/2008 3:00 PM   Replies: 8

« Previous thread Next thread »
Page 1 of 1 (9 items)
  9/17/2008, 3:00 PM
Joined 9/17/2008
Last visit: 8/31/2011
Posts: 25
Rating:
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
I've been trying to make a textlist for a faceplate using the textlisteditor inside the faceplate.
The textlist looks at an integer word for it's value.
First of all, my high byte and low byte of the word get switched.

(example: the word is db140.dbw0 in the plc. In flex byte 0 is db140.dbb1.0 ...)

If anybody knows how to convert this back my problem would be solved also.

Otherwise, the integer is signed (byte 15= 1 => negative value) is there a way to make it unsigned?
Top
  9/17/2008, 4:56 PM
Joined 11/30/2006
Last visit: 10/23/2014
Posts: 118
Rating:
Rated: Excellent [4.25 out of 5 / rated 8 time(s)]. (8) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
DRA_Employee wrote:
I've been trying to make a textlist for a faceplate using the textlisteditor inside the faceplate.
The textlist looks at an integer word for it's value.
First of all, my high byte and low byte of the word get switched.

(example: the word is db140.dbw0 in the plc. In flex byte 0 is db140.dbb1.0 ...)

If anybody knows how to convert this back my problem would be solved also.

Otherwise, the integer is signed (byte 15= 1 => negative value) is there a way to make it unsigned?


Hi DRA_Employee
I could not understood completely what you are tring to ask.
Since you are going use Integer Values you dont need to do any conversion .
The problem will come only if you are tring to use bits out of INT or Word.In this case you need to be carefully for using bits since Bytes will be swaped in HMI .
 
Top
  9/17/2008, 9:50 PM
Joined 10/17/2006
Last visit: 12/18/2013
Posts: 105
Rating:
Rated: Outstanding [3.29 out of 5 / rated 7 time(s)]. (7) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
It seems you may just have the tag defined incorrectly in the WinCC Flex project. If you have an INT on a plc (I am making the assumption that you are getting the value from a plc) and are definining it as a WORD in the project than you would have the problem that you described. If this is the case just re-define the HMI WORD to an INT and the byte swap will no longer be an issue.
Top
  9/18/2008, 8:28 AM
Joined 9/17/2008
Last visit: 8/31/2011
Posts: 25
Rating:
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 

Okey, I see I need to explain it a bit better.

First of all, i'm using WinCC flex 2007 and Step 7.

I got a function from a Co-worker wich has been made the standard for my company, so adjusting the PLC program is not an option. Now the function uses 1 word: db140.dbx 0.0 to db140.dbx1.7


I have tagged this in WinCC flex as an integer, WinCC flex swapps bytes making db140.dbx0.7 the 15th bit.


Now the problem is, this bit is used in the program so it affects the integer value I use in WinCC flex. When the bit goes high, the integer value goes negative (because WinCC uses signed integers). But when that bit goes high, my other bits can form around 5 other values I should put in my textlist (all negative because bit 15, db140.dbx 0.7 is high), but I cannot enter negative values in a textlist. 
So is their a way to make the tag an unsigned integer.

Another way to solve my problem would be If I can swap the bytes again. DB140.dbx1.7 is the alarm, If i can make this bit 15, I could make it the default value so from the moment the integer goes negative I'll have my alarm but I don't know if this is possible either.

I hope I explained it better this time, if their are other questions please just ask.

Top
  9/19/2008, 2:32 AM
Joined 11/30/2006
Last visit: 10/23/2014
Posts: 118
Rating:
Rated: Excellent [4.25 out of 5 / rated 8 time(s)]. (8) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
DRA_Employee wrote:

Now the problem is, this bit is used in the program so it affects the integer value I use in WinCC flex. When the bit goes high, the integer value goes negative (because WinCC uses signed integers). But when that bit goes high, my other bits can form around 5 other values I should put in my textlist (all negative because bit 15, db140.dbx 0.7 is high), but I cannot enter negative values in a textlist. 
So is their a way to make the tag an unsigned integer.
Another way to solve my problem would be If I can swap the bytes again. DB140.dbx1.7 is the alarm, If i can make this bit 15, I could make it the default value so from the moment the integer goes negative I'll have my alarm but I don't know if this is possible either.
I hope I explained it better this time, if their are other questions please just ask.



You can try following things 
If you have only option to do changes in HMI ,what you can do is make the Textlist  for the individual bits  by selecting option of Bit number (0 - 31) instead of using Integer Ranges .
In this case you dont have to  worry  about the negative values.
It doesnt matter how many bits you use from (0 - 31) , you can use anything between 0 - 31)

I hope this works for you.

Top
  9/19/2008, 8:45 AM
Joined 9/17/2008
Last visit: 8/31/2011
Posts: 25
Rating:
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
No I'm afraid that wouldnt work, more then one bit in the word will be active at the same time.

(Looking at: Automatic, manual, disabled, alarm and simulation. Alarm, simulation and one of the others can be active at the same time)

I tried it and once more then one bit becomes active the textlist goes blanc.
Top
  9/19/2008, 9:37 AM
Joined 5/22/2006
Last visit: 10/29/2014
Posts: 204
Rating:
Rated: Outstanding [3.75 out of 5 / rated 20 time(s)]. (20) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
DRA_Employee wrote:

Okey, I see I need to explain it a bit better.

First of all, i'm using WinCC flex 2007 and Step 7.

I got a function from a Co-worker wich has been made the standard for my company, so adjusting the PLC program is not an option. Now the function uses 1 word: db140.dbx 0.0 to db140.dbx1.7


I have tagged this in WinCC flex as an integer, WinCC flex swapps bytes making db140.dbx0.7 the 15th bit.



Hi,

What you are seeing is the internal PLC use of bytes in words. WinCC has absolutely nothing to do with this.

  [7..0]   [7..0]
|Byte 0||Byte 1|
{     Word 0    }
     [15..0]

Thats a very short description of how S7 PLC's organize bytes in words.

If you really really really want to swap the bytes, there are a few possibilities, some more dirty then the next.

But I don't quite follow the problem.
I just created a Test project, created a textlist and according to the help, you can enter any number between -2147483648 and 2147483647, which I tried and it accepted it.
This on WinCC 2007 HF4

Could u maybe post screenshots of the problems/errors WinCC gives?

Jeebs
Top
  9/19/2008, 10:17 AM
Joined 9/17/2008
Last visit: 8/31/2011
Posts: 25
Rating:
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
Rated: no ratings [0 out of 5 / rated 0 time(s)]. (0) 
I just tried entering a negative value and now it works :s
I tried it before and it didnt work it just made the values positive. Must have done something wrong, probably put in -16000 - -32000 and it has to be -32000 - -16000.
Don't know what else I could have done wrong...

But thank you for clearing it up for me. (yeah ... feel pretty stupid now ...)



=== Edited by DRA_Employee @ 9/19/2008 10:21 AM [GMT ] ===


Top
  9/19/2008, 1:31 PM
Joined 5/22/2006
Last visit: 10/29/2014
Posts: 204
Rating:
Rated: Outstanding [3.75 out of 5 / rated 20 time(s)]. (20) 
Rated: Outstanding [4 out of 5 / rated 1 time(s)]. (1) 
Hi,

Yeah, putting it that way will give errors..:D

Don't worry about it, we all have our days. Good thing is u won't forget this anytime soon...:D

Glad to hear it works..


Jeebs
Top
Page 1 of 1 (9 items)
Actions