STEP 7 : STL, the LOOP, JC and JCN instructions ...

buhnen

Member
Join Date
May 2008
Location
Somewhereland
Posts
131
Hi all!

I'm testing a routine that I've just written under STL and I would appreciate some help from someone else more experienced than me with this, as I've just come recently from LAD language.

Either I like it or not, indirect adressing,looping, pointers...are to be implemented under STL in Siemens..And here it comes my sweet honeymoon with STL ...

The case is as it follows: I've 8 DBs, instances of a same UDT, this is, with the same structure for them all. DBs are numbered like this DB100, DB101, DB 102 .... DB108

1) My first testing attempt is very simple and it works out fair enough: By means of the LOOP instruction I call an FC several times (the well known FC105 for scaling an analog input) and asign the right parametres from each of the DB's.
This is the code, which I've succesfully tested:


L 100
T #DBINDEX
L 8
META: T #COUNT
OPN DB [#DBINDEX]

CALL "SCALE"
IN :=DBW16
HI_LIM :=1.000000e+002
LO_LIM :=0.000000e+000
BIPOLAR:=FALSE
RET_VAL:=DBW20
OUT :=DBD8

L #DBINDEX
L 1
+I
T #DBINDEX
L #COUNT
LOOP META



2) Now I want to bypass the scaling operation for two of the DBs included within the range from DB100 to DB108. Let's say I want to bypass DB104 and DB105.
So I've modified the code posted above to turn it into what follows:


L 100
T #DBINDEX
L 8
META: T #COUNT

L #DBINDEX
L 103
<=I
OPN DB [#DBINDEX]
JC A


L #DBINDEX
L 106
>=I
L #DBINDEX
L 108
<=I
OPN DB [#DBINDEX]
JC A

JCN B



A: CALL "SCALE"
IN :=DBW16
HI_LIM :=1.000000e+002
LO_LIM :=0.000000e+000
BIPOLAR:=FALSE
RET_VAL:=DBW20
OUT :=DBD8

B: L #DBINDEX
L 1
+I
T #DBINDEX
L #COUNT
LOOP META




...but here it comes the problem. When I try to test it I can't update the simulation values on my VAT ...It doesn't work...and as far as my fair knowledge on STL allows me to see, this routine makes sense to me

Any hint please?what am I missing out here?

Thanks in advance
 
Last edited:
...ok, the reason why I couldn't update the variables was because of an issue with double assignment, but that's solved now.

Still my loop doesn't work...It is like the RLO jumps always to the label "A" :(

I've "fixed" the code adding a L #DBINDEX

before
OPN DB [#DBINDEX]

so now it remains like this:

L     100
T #DBINDEX
L 9
META: T #COUNT

L #DBINDEX
L 103
<=I
JC A


L #DBINDEX
L 105
>=I
L #DBINDEX
L 108
<=I
JC A
JCN B


A: L #DBINDEX
OPN DB [#DBINDEX]
CALL "SCALE"
IN :=DBW16
HI_LIM :=1.000000e+002
LO_LIM :=0.000000e+000
BIPOLAR:=FALSE
RET_VAL:=DBW20
OUT :=DBD8

B: L #DBINDEX
L 1
+I
T #DBINDEX
L #COUNT
LOOP META




 
2) Now I want to bypass the scaling operation for two of the DBs included within the range from DB100 to DB108. Let's say I want to bypass DB104 and DB105.
So I've modified the code posted above to turn it into what follows:


L 100
T #DBINDEX
L 8
META: T #COUNT

A(
L 103
L #DBINDEX // If 103 is less than INDEX
<I
)
A( // AND
L 106 // INDEX less than 106 (i.e. 104 or 105)
<I
)
JC B // Jump over

OPN DB [#DBINDEX]


CALL "SCALE"
IN :=DBW16
HI_LIM :=1.000000e+002
LO_LIM :=0.000000e+000
BIPOLAR:=FALSE
RET_VAL:=DBW20
OUT :=DBD8

B: L #DBINDEX
L 1
+I
T #DBINDEX
L #COUNT
LOOP META




...but here it comes the problem. When I try to test it I can't update the simulation values on my VAT ...It doesn't work...and as far as my fair knowledge on STL allows me to see, this routine makes sense to me

Any hint please?what am I missing out here?

Thanks in advance


I would use AND for the conditions
 
Last edited:
L #DBINDEX
L 105
>=I
L #DBINDEX
L 108
<=I
JC A
JCN B

these are not linked, the first comparator does nothing it needs A( or O( with a ) to link them together.
 
ahaaa ....I understand it now ! :p

I see I'll have to try harder with STL..o_O

Thanks a lot Peter (y), I'm going to test the code again and see how it goes
 

Similar Topics

Good day. I have a device on profibus that I am reading data from using SFC14. This data is written into an array within a DB. The array is 128...
Replies
6
Views
3,739
Hi Siemens Experts, I am hoping someone can shed some light on my issue. I have uploaded the code from a S7-300 (317-2PN/DP) using Step 7...
Replies
9
Views
688
I really struggle with STL in Siemens Step 7 Classic. I'll learn chunks, but then I don't use it enough to retain and build on the knowledge. When...
Replies
17
Views
3,226
Hi all, I have been asked to make some modifications to a Siemens S7-300 which is programmed entirely in STL and commented entirely in Italian...
Replies
10
Views
3,639
Hello everyone! I've just stared with programming on STL and I have problem which I can't understand. I'm writing programs on Step 7 and I'm...
Replies
2
Views
2,184
Back
Top Bottom