You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

Reply
 
Thread Tools Display Modes
Old January 13th, 2021, 02:27 PM   #1
AlecTek
Member
Canada

AlecTek is offline
 
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.
  Reply With Quote
Old January 13th, 2021, 02:45 PM   #2
L D[AR2,P#0.0]
Lifetime Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 6,144
plc - s7-300 or s7-1500/1200?
__________________
S7-300 to 1500 conversions done - email to s7conversions@hotmail.com
  Reply With Quote
Old January 13th, 2021, 02:46 PM   #3
AlecTek
Member
Canada

AlecTek is offline
 
Join Date: Sep 2010
Location: Vancouver
Posts: 127
S7-1500, TIA POrtal 15.1


Thanks
  Reply With Quote
Old January 13th, 2021, 02:51 PM   #4
L D[AR2,P#0.0]
Lifetime Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 6,144
Here's my preference over using poke:
Attached Images
File Type: jpg dbdb.jpg (93.3 KB, 75 views)
__________________
S7-300 to 1500 conversions done - email to s7conversions@hotmail.com
  Reply With Quote
Old January 13th, 2021, 03:02 PM   #5
L D[AR2,P#0.0]
Lifetime Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 6,144
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
  Reply With Quote
Old January 13th, 2021, 03:07 PM   #6
AlecTek
Member
Canada

AlecTek is offline
 
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!
  Reply With Quote
Old January 13th, 2021, 03:08 PM   #7
L D[AR2,P#0.0]
Lifetime Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 6,144
? I'm not doing a poke.
__________________
S7-300 to 1500 conversions done - email to s7conversions@hotmail.com
  Reply With Quote
Old January 13th, 2021, 03:35 PM   #8
mk42
Lifetime Supporting Member
United States

mk42 is offline
 
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.
  Reply With Quote
Old January 13th, 2021, 04:42 PM   #9
AlecTek
Member
Canada

AlecTek is offline
 
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!!
  Reply With Quote
Old January 13th, 2021, 11:10 PM   #10
mk42
Lifetime Supporting Member
United States

mk42 is offline
 
Join Date: Jun 2013
Location: MI
Posts: 2,655
Quote:
Originally Posted by AlecTek View Post
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.



Quote:
Originally Posted by AlecTek View Post
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.../view/57374718
  Reply With Quote
Old January 14th, 2021, 04:55 PM   #11
AlecTek
Member
Canada

AlecTek is offline
 
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.
  Reply With Quote
Old January 15th, 2021, 08:59 AM   #12
mk42
Lifetime Supporting Member
United States

mk42 is offline
 
Join Date: Jun 2013
Location: MI
Posts: 2,655
Quote:
Originally Posted by AlecTek View Post
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?
  Reply With Quote
Old January 15th, 2021, 12:04 PM   #13
AlecTek
Member
Canada

AlecTek is offline
 
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.
  Reply With Quote
Old January 15th, 2021, 12:21 PM   #14
drbitboy
Lifetime Supporting Member
United States

drbitboy is offline
 
drbitboy's Avatar
 
Join Date: Dec 2019
Location: Rochester, NY
Posts: 2,037
http://chris.wastedhalo.com/2010/10/...binary-in-asp/


?
  Reply With Quote
Old January 15th, 2021, 05:01 PM   #15
AlecTek
Member
Canada

AlecTek is offline
 
Join Date: Sep 2010
Location: Vancouver
Posts: 127
OMG

b2 = CBool(SmartTags("Properties\status") And 2)

Thanks drbitboy!
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Topics
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


All times are GMT -5. The time now is 12:57 AM.


.