Step 7 SCL DB Addressing

AlecTek

Member
Join Date
Sep 2010
Location
Vancouver
Posts
155
Hello,

what is wrong with the program like below to write 100 to DB81.DW24?
%DB81.DW(IDX :=24) := 100;

Or how should I write the program?

Thanks!

db81 is not an array, it is a structure of different type of data, I would like to access the word at the offset 24 of db.
 
Last edited:
A better solution might be to read the structure element, modify it to what you want and then write it back - any reason why not to do that?
 
You saved my day!

I am doing some supplements to an existing system, so your poke is the best solution to me.

Thanks a lot!
 
1500's & SCL generally work with the tags of a structure, instead of the addresses that the structure resides in. The "should" is to restructure the code so you can do it with tags.



If you can't (and there are very few reasons that I've seen that don't boil down to "I don't want to do things the new way"), you can only use absolute address if you make it a non-optimized OB. Peek/Poke instructions are the best way to make it a variable offset to a DB.
 
Sorry L D, when you said your preference over poke, I just read as poke. I don't really know poke, but your way is pretty simply to me.

mk42, I am trying not to touch any existing stuff unless have to, I don't want to go to site and troubleshooting a whole day for a minor change.

BTW, I don't understand why siemens not making simple things simple. 10 years ago I was spending a day to find the way to set bits in a word, and after 10 years I spend another day to recall the way i did it. Anyway, thanks for all the help!!
 
mk42, I am trying not to touch any existing stuff unless have to, I don't want to go to site and troubleshooting a whole day for a minor change.

Fair enough, I guess. Legacy stuff is what legacy stuff does.



BTW, I don't understand why siemens not making simple things simple. 10 years ago I was spending a day to find the way to set bits in a word, and after 10 years I spend another day to recall the way i did it. Anyway, thanks for all the help!!


For what it's worth, the new stuff does have an easy way to do it, if you're saying what I think you are. To change a bit in a word in 1200/1500, use slice based addressing: #TagName.%X0 for bit 0 as an example.



https://support.industry.siemens.com/cs/ww/en/view/57374718
 
How do we extract bits of word in WinCC Advanced if not using scripts? (TIA Portal 15.1)


Most of the animations let you animate based on a single bit in a tag. There are system functions to read/write a single bit in a tag. Alarms can only be set up that way.


What were you trying to do?
 
Thanks mk,

I got a status word, each bit means something, and I would display some status for example Moving = b1. I made a faceplate properties\status will interface the status word.

I tried something like status.%X1 but not work.

So then I try the VBscripts (this is WinCC advanced). I made a faceplate tag b1:bool. and I tied the followings:

SmartTags("b1") = ((SmartTags("Properties\status") And 2) = 2)
b1 = SmartTags("Properties\status") And 2
b1 = ((SmartTags("Properties\status") & 2) = 2)
If SmartTags("Properties\status") And 2 Then
b1 = True
Else
b1 = False
End If

and none of above work neither. Really weird, because I did similar faceplate long ago using wincc flexible.
 
Last edited:

Similar Topics

Hi, Can someone translate this for me please, or at least help to explain what the instructions mean? SET SAVE =...
Replies
17
Views
4,557
I have made a small FB in SCL, in this blok i have to transfer to an array in a certan position, but I can't get it to work. It goes as follows...
Replies
6
Views
6,496
Help!! From reading previous threads, I know that the best way to index an array is using SCL. I have the SCL editor, I'm just not sure where to...
Replies
3
Views
4,206
I am logging real numbers into arrays in SCL. I am using these for buffer bit trends in WinCC Flexible. I need to cut some digits out. Some of the...
Replies
15
Views
13,150
Hi guys, i was trying to make a program in simatic step 7 with which i could with the useing of a switch choose between automatic, manual and step...
Replies
0
Views
4,638
Back
Top Bottom