![]() ![]() ![]() ![]() ![]() ![]() |
||
![]() |
||
![]() ![]() ![]() ![]() This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. |
||
![]() |
![]() |
#1 |
Member
![]() ![]() Join Date: Sep 2010
Location: Vancouver
Posts: 127
|
Step 7 SCL DB Addressing
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 by AlecTek; January 13th, 2021 at 02:38 PM. |
![]() |
![]() |
#2 |
Lifetime Supporting Member
![]() ![]() Join Date: Nov 2006
Location: UK
Posts: 6,141
|
plc - s7-300 or s7-1500/1200?
__________________
S7-300 to 1500 conversions done - email to s7conversions@hotmail.com |
![]() |
![]() |
#3 |
Member
![]() ![]() Join Date: Sep 2010
Location: Vancouver
Posts: 127
|
S7-1500, TIA POrtal 15.1
Thanks |
![]() |
![]() |
#4 |
Lifetime Supporting Member
![]() ![]() Join Date: Nov 2006
Location: UK
Posts: 6,141
|
Here's my preference over using poke:
__________________
S7-300 to 1500 conversions done - email to s7conversions@hotmail.com |
![]() |
![]() |
#5 |
Lifetime Supporting Member
![]() ![]() Join Date: Nov 2006
Location: UK
Posts: 6,141
|
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?
__________________
S7-300 to 1500 conversions done - email to s7conversions@hotmail.com |
![]() |
![]() |
#6 |
Member
![]() ![]() Join Date: Sep 2010
Location: Vancouver
Posts: 127
|
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! |
![]() |
![]() |
#7 |
Lifetime Supporting Member
![]() ![]() Join Date: Nov 2006
Location: UK
Posts: 6,141
|
? I'm not doing a poke.
__________________
S7-300 to 1500 conversions done - email to s7conversions@hotmail.com |
![]() |
![]() |
#8 |
Lifetime Supporting Member
![]() ![]() Join Date: Jun 2013
Location: MI
Posts: 2,655
|
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. |
![]() |
![]() |
#9 |
Member
![]() ![]() Join Date: Sep 2010
Location: Vancouver
Posts: 127
|
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!! |
![]() |
![]() |
#10 | ||
Lifetime Supporting Member
![]() ![]() Join Date: Jun 2013
Location: MI
Posts: 2,655
|
Quote:
Quote:
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.../view/57374718 |
||
![]() |
![]() |
#11 |
Member
![]() ![]() Join Date: Sep 2010
Location: Vancouver
Posts: 127
|
How do we extract bits of word in WinCC Advanced if not using scripts? (TIA Portal 15.1)
Last edited by AlecTek; January 14th, 2021 at 05:04 PM. |
![]() |
![]() |
#12 | |
Lifetime Supporting Member
![]() ![]() Join Date: Jun 2013
Location: MI
Posts: 2,655
|
Quote:
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? |
|
![]() |
![]() |
#13 |
Member
![]() ![]() Join Date: Sep 2010
Location: Vancouver
Posts: 127
|
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 by AlecTek; January 15th, 2021 at 12:10 PM. |
![]() |
![]() |
#14 |
Lifetime Supporting Member
|
|
![]() |
![]() |
#15 |
Member
![]() ![]() Join Date: Sep 2010
Location: Vancouver
Posts: 127
|
OMG
b2 = CBool(SmartTags("Properties\status") And 2) Thanks drbitboy! |
![]() |
![]() |
Bookmarks |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
indirect addressing to instance db in step7 SCL | italo2008 | LIVE PLC Questions And Answers | 15 | July 27th, 2015 03:08 AM |
Matlab - Step 7 DB / VAR Logger Code | KealanOCarroll | LIVE PLC Questions And Answers | 0 | October 31st, 2013 09:01 AM |
DB indirect addressing with parameters | jormaga | LIVE PLC Questions And Answers | 4 | September 2nd, 2010 05:31 AM |
Help with SCL | STL??? | LIVE PLC Questions And Answers | 8 | June 18th, 2008 03:04 AM |
step 5 program help request | srik | LIVE PLC Questions And Answers | 1 | February 26th, 2007 05:49 AM |