Siemens STL code does not work curious why?

Tommycai

Member
Join Date
Aug 2011
Location
KY
Posts
120
so the code I am trying to do loads two different values and then I try and tell if the value subtracted from the other value is less than 15 and if it is then jump to NRG, and if it is not then jump to GUD1; however, my STA was set to 0 how does this happen? I know that if the STA is zero then it checks for the FC bit and then it just copies over the STA.

L db30.dbd30 //loads value into accu 1
L db30.dbd34 //loads value into accu 1 and pushes acc1 to acc2
-D //subtracts accu 2 from accu 1
L 15 //loads value 15 into accu 1
<D //if acc2 is less than accu 1 then rlo = 1
JC NRG // Jump if RLO =1 to NRG
JCN GUD1 //Jump to GUD1 if RLO = 0
 
It also works as you wrote, but I prefer to save the data before
comparison.When you compare two type of double int/words, it should be put in front
L#15.
Here is my example:
L MD 300
L MD 304
-D
T MD 308
JM Min //Jmp if negative

L MD 308
L L#15
<D
JC Tru
NOT
JCN Fls

Min: NOP 0
JU exit

Tru: NOP 1
JU exit

Fls: NOP 1
JU exit

exit: SET
SAVE
BE
 
Last edited:
The RLO in the line with JC does not show if jump is executed does it? Is there anything that corresponds with JC or JCN in STL?
 
Yes I know that JC jumps if the RLO = 1 and the JCN jumps if RLO does not equal one but is there something that states if the RLO is executing or not because using JC at the end set RLO to 1 even though it does not jump.
 
1148_1253230725640.jpg
 
This thread makes me laugh.
Tommycai, you should have done this in ladder and then looked at what code the ladder generated. You would have been done two days ago.
Tommycai, assume the PLC does the right thing given you did the right thing. In other words if the RLO=1 assume the JC jumps and doesn't if RLO=0. If the RLO is changing quickly it is very hard to for the screen to keep up with the changes to see what is happening. There would be lots of people looking like that picture above if Siemens couldn't get a simple jump on condition to work.

TurpoUrpo found a way to get around the obscenity filter.
 
This thread makes me laugh.
Tommycai, you should have done this in ladder and then looked at what code the ladder generated. You would have been done two days ago.
Tommycai, assume the PLC does the right thing given you did the right thing. In other words if the RLO=1 assume the JC jumps and doesn't if RLO=0. If the RLO is changing quickly it is very hard to for the screen to keep up with the changes to see what is happening. There would be lots of people looking like that picture above if Siemens couldn't get a simple jump on condition to work.

TurpoUrpo found a way to get around the obscenity filter.



I started the code in ladder; however, it compares 60 bytes of data from one to the next each block in data is a CMP, Sub_I, and then another CMP 3 blocks times 60 bytes of data. This is why I did it in STL.
 
L MD 300
L MD 304
-D
T MD 308
JM Min //Jmp if negative

L MD 308
L L#15
<D
JC Tru
JU Fls

Min: NOP 0
JU exit

Tru: NOP 1
JU exit

Fls: NOP 1
JU exit

exit: SET
SAVE
BE

Fixed it.

This thread is lols indeed.
People need to stop focussing on how they think it should work and look at how it actually works.
 

Similar Topics

IS it possible to write this on a better way: L #db_Num2 L 121 ==I JNB _02 CALL "CONT_C" , "DB_reg_igla1"...
Replies
3
Views
2,626
Hello I am incrementing db8.dbw0 by one in another fb and comparing it to acc1 whenever m199.7 is set would there be cleaner way to do this. I'm...
Replies
5
Views
2,673
I have just started out coding in STL and i have been given this piece of code to decipher L DIW [AR2,P#8.0] //LOAD DEST DB#...
Replies
9
Views
15,597
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
667
I'm having trouble trying to convert this code to ladder, anyone able to help me? A M4.0 A M4.1 A M117.0 AN M17.7 A ( A I38.6 AN I3.7 O ( A M4.5...
Replies
8
Views
1,206
Back
Top Bottom