learning function and data blocks (Step7)

Pandiani

Lifetime Supporting Member
Join Date
Apr 2005
Location
Tz
Posts
718
I'm learning about functions and data block. I "have" 2 pumps. When process is started pump1 works for 10 sec and then pump2 works for 5 sec. I made that in plain ladder without blocks, but since pumps have ssame interface I thought it is better to write it as function blocks and later just create instance data blocks. I use stat variable to store s5time (in order timer to work). I want to make 2 modes. First pump1 works 10 sec, pump2 5 sec and
second mode: pump1 works 20 sec, pump2 works 10 sec. I got advices to use MOVE block to store time in memory area MW10 which I declared as s5time data type. So memory address MW10 will store work time. Now I have problem when creating. It seems that step7 expects number example (s5t#10s) and not address MW10 on which value is stored.
Is there any way I can do this?
 
If you have defined two DBs for each pump instance (DB10, and DB11 fo example), and you have defined a STAT for the setpoint (looks like word 6 in your PDF file). Then you acces the actual values via DB10.DBW6 and DB11.DBW6.

1. You can load the setpoint into these two values directly:

L S5T#20S
T DB10.DBW6

L S5T#10S
T DB11.DBW6

2. You can also load from intermediary variables:

L MW10
T DB10.DBW6

L MW12
T DB11.DBW6

3. You can also change the Actual Values from an operator panel.

4. You can also change the Actual Values in each instance DB and use DOWNLOAD PARAMETER SET. Be warned though that this will create a timestamp conflict. That means in turn that STEP7 will like to recreate the DBs whereby the Actual Values will be reset to the Initial Values.
 
I'm afraid STL is totally unknown to me. How to do it in ladder diagrams? I decide to start learning STL after I become comfortable with LAD programming first.I'm trying to use (OPN) to pen data block and then (SS) to set time value, but still no succes
P.s. Sorry about that pdf...
Thanks
 
Last edited:
Brief example.

STL:
L S5T#20S
T DB10.DBW6

L MW10
T DB10.DBW6


LAD: ("ConstOn" is a variable that you set to TRUE somewhere else).
  ConstOn 
----||--------|MOVE|
S5T#20S--| |--DB10.DBW6

ConstOn
----||--------|MOVE|
MW10--| |--DB10.DBW6

 
Jesper, this looks like you are referencing instance data from outside the FB. If the FB interface changes, how do you maintain the references to the instance variables ? - re-compile each time ?

I would pass the values into the FB as parameters.
 
Simon, I do this all the time.
You are right that it is a problem if the FB variable declaration changes. The solution is to change the Adressing Priority from "Absolute" to "Symbolic". Obviously I cannot change an FB variable declaration on a running proces. When the proces has been started up I have to keep my fingers off all the standard FBs I have created.
edit: Passing the parameters as inputs and outputs, as you suggest, would result in the same "problem". You cannot change the variable declaration on an FC or FB "hot" so to speak.

Pandiani,
it just occurred to me that the next problem you will be facing is how to assign an individual S5Timer to each instance of the FB.
The solution is to pass the timer to the FB as an input parameter.
Here is a small example how to do it:
FBwS5Texample.GIF



edit:
Just added how the calling code looks like:
FBwS5Texample_2.GIF
 
Last edited:

Similar Topics

I've gotten to the learning curve where I can program a call for pump to come on at set point but I'm not sure how to turn the same pump off when...
Replies
1
Views
117
I want to pick up an Allen Bradley PLC so I can practice writing programs. I have 10 years as a maintenance tech and a good understanding of...
Replies
8
Views
228
Hi all, i have started a new chapter in my career with a local company. a lot of their plc's is omron and i have the cx version 9.75 software...
Replies
25
Views
4,195
Can you guys recommend a course or book for my son to start learning PLC programming? He’s telling me he’s thinking of taking some $100 course...
Replies
31
Views
7,090
Hello All, I have recently had the opportunity to dabble in TIA portal for the first time. Been working in automation for almost a decade now and...
Replies
18
Views
2,606
Back
Top Bottom