Siemens Statement Logic

ControlsDude17

Supporting Member
Join Date
Apr 2021
Location
Toledo, OH
Posts
19
Hello Everyone,

I am not proficient with STL so I wanted to get another opinion on this big of logic.

A(
L #MaxPos //maximum position [mm] greater than...
L DBD [AR1,P#2.0] //...absolute pane position [mm]...
>=D
)
A(
L DBD [AR1,P#2.0] //...absolute pane position [mm]...
L #MinPos //...and minimal position [mm]...
>=D //...less than absolute pane position [mm]...
)
JCN N1Lo

I read this as my DBD[AR1,P#2.0] both has to be Larger or equal to #MaxPos and Less than or equal to #MinPos in order to execute JCN N1Lo.

Is this correct or am I misreading this?
 
https://support.industry.siemens.co...-s7-300-and-s7-400-programming?dti=0&lc=en-WW


I think OP's interpretation might be backwards; I think it is evaluating
#MaxPos >= DBD [AR1,P#2.0]
AND
DBD [AR1,P#2.0] >= #MaxPos
>=D is (ACCU 2 >= ACCU 1) where ACCU 2 and ACCU1 are both double integers. ACCU 1 is the most recent L argument; ACCU 2 is the next most recent L argument, so in the first [AND with Nesting Open] A( ... ), when the close paren is reached, #MaxPos is in ACCU 2 and DBD [AR1,P#2.0] is in ACCU 1.

The L (Load) shifts the accumulator stack up and "pushes" it argument onto the at ACCU 1.

========================================================================
4.3 L Load Current Counter Value into ACCU 1
Format
L <counter>
[...]
Description
L <counter> loads the current count of the addressed counter as an integer into ACCU 1-L after the contents of ACCU 1 have been saved into ACCU 2.
========================================================================
2.3 ? D Compare Double Integer (32-Bit)

Format
==D, <>D, >D, <D, >=D, <=D
Description of instruction
The Compare Double Integer (32-bit) instructions compare the contents of ACCU 2 with the contents of ACCU 1 .The contents of ACCU 2 and ACCU 1 are interpreted as 32-bit integer numbers. The result of the comparison is indicated by the RLO and the setting of the relevant status word bits. RLO = 1 indicates that the result of the comparison is true; RLO = 0 indicates that the result of the comparison is false. The status word bits CC 1 and CC 0 indicate the relations ‘’less,’’ ‘’equal,’’ or ‘’greater.”​
 
Last edited:
Also note that, if OP's original interpretaion was correct, and if #MaxPos is less than #MinPos, then routine [N1Lo] can never be executed.
 
STL Logic

It is a limit test, must be <=MaxPos and >=MinPos.

#MaxPos >= DBD [AR1,P#2.0]
AND
DBD [AR1,P#2.0] >= #MinPos

This makes more sense to me, it was just that in trying to interpret the STL logic, I had twisted it around. Basically, it states that if DBD [AR1,P#2.0] is between #MaxPos and #MinPos, then RLO = 1?
 
Last edited:
Yes, if the value is within limits, RLO would = 1, and the JUMP would not occur.
Because JCN = JUMP if RLO=0.

So the full version of the code.

A(
L #MaxPos //maximum position [mm] greater than...
L DBD [AR1,P#2.0] //...absolute pane position [mm]...
>=D
)
A(
L DBD [AR1,P#2.0] //...absolute pane position [mm]...
L #MinPos //...and minimal position [mm]...
>=D //...less than absolute pane position [mm]...
)
JCN N1Lo
L #Count
T #TPane
N1Lo: L #Count
LOOP skn1

If I am between Max Pos and Min Pos, then RLO = 1 and I move #Count into #Tpane. If RLO = 1, jump to N1Lo?

Just want to verify because if so, this is opposite of the outcome I want and I would want to change that "JCN" to "JC".
 
Last edited:
If between MaxPos and MinPos, RLO = 1, do not jump, move #Count to #TPane, then load #Count, then loop.
If outside of MaxPos / MinPos, RLO = 0, jump (Do not move #Count to #TPane), then load #Count, then loop.
 
Additional

Can I get some help with is part too?

Trying to isolate why we are faulting when it appears that our Value is within the limits.

L #MaxNoPane //maximum number of panes
skn1: T #Count
L 1
-I
L #S_PaneData //length of pane data array
*I
L #P_PaneData //start of pane data array
+I
SLD 3
LAR1

A(
L #MaxPos //maximum position [mm] greater than...
L DBD [AR1,P#2.0] //...absolute pane position [mm]...
>=D
)
A(
L DBD [AR1,P#2.0] //...absolute pane position [mm]...
L #MinPos //...and minimal position [mm]...
>=D //...less than absolute pane position [mm]...
)
JCN N1Lo
L #Count //... -> save pane number!
T #TPane
N1Lo: L #Count //...otherwise: check next pane!
LOOP skn1


L 0 //if no pane was found...
L #TPane //...between the parametrised position...
==I
S #DevFlt //...-> set fault
JC NotF //...-> goto: no pane found
L #TPane //...otherwise:
+ -1
L #S_PaneData //length of pane data array
*I
L #P_PaneData //start of pane data array
+I
SLD 3
LAR1

L #NewPos //get deviation
L DBD [AR1,P#2.0]
-D
T #ActDev

L #NewPos //copy the absolute plant position [mm]...
T DBD [AR1,P#2.0]

JU IniB
 
Can I get some help with is part too?

Trying to isolate why we are faulting when it appears that our Value is within the limits.

L #MaxNoPane //maximum number of panes
skn1: T #Count
L 1
-I
L #S_PaneData //length of pane data array
*I
L #P_PaneData //start of pane data array
+I
SLD 3
LAR1

A(
L #MaxPos //maximum position [mm] greater than...
L DBD [AR1,P#2.0] //...absolute pane position [mm]...
>=D
)
A(
L DBD [AR1,P#2.0] //...absolute pane position [mm]...
L #MinPos //...and minimal position [mm]...
>=D //...less than absolute pane position [mm]...
)
JCN N1Lo
L #Count //... -> save pane number!
T #TPane
N1Lo: L #Count //...otherwise: check next pane!
LOOP skn1


L 0 //if no pane was found...
L #TPane //...between the parametrised position...
==I
S #DevFlt //...-> set fault
JC NotF //...-> goto: no pane found
L #TPane //...otherwise:
+ -1
L #S_PaneData //length of pane data array
*I
L #P_PaneData //start of pane data array
+I
SLD 3
LAR1

L #NewPos //get deviation
L DBD [AR1,P#2.0]
-D
T #ActDev

L #NewPos //copy the absolute plant position [mm]...
T DBD [AR1,P#2.0]

JU IniB

Essentially what is going on in these lines, How do I determine what AR1 is, etc.
 
AR1 is an address register and can be used to access data down to the bit level. When accessing data at the byte level you have to multiply the byte number by 8, hence the SLD 3 instructions.
Your code is looping through an array where the start byte location of the array is specified in P_PaneData and the size of the array structure is specified in S_PaneData. The dint value for your comparison is located at byte 2 in the structure.
 

Similar Topics

Kindly assist with the meaning of the following functions calls: CALL FC 122 IN0 :=P#DB121.DBX 336.0 IN30 :=DB121 IN31...
Replies
9
Views
3,280
Hello all, I am Confusing with below equation. i express with blue color .Please kindly explain me below FOR ..., Where can i find good SCL...
Replies
7
Views
2,552
I am interpreting STL for the first time for a Siemens S5 PLC. In the STL, I often see !=F in the code. What is this? Thanks.
Replies
4
Views
8,151
R
Is there any utility that converts Siemens Step 5 Statement list program to Ladder logic. I am new to Statement list and also siemens PLC. I find...
Replies
9
Views
16,753
This is the first time I am working with Simatic Manager Step7 as I started my siemens journey with TIA which is pretty easy and do a lot of stuff...
Replies
1
Views
12
Back
Top Bottom