Compiled by SCL compiler to STL in Siemens!

MOeZ

Lifetime Supporting Member
Join Date
Nov 2009
Location
singapore
Posts
101
Hi All,

In FB and FC that are compiled it to STL language.

When i open it those FB and FC, i have noticed that every start and End of code is written below.

SET
SAVE
= L 0.1

//
CODES
ARE
HERE
//
A L 0.1
SAVE
BE


So, my question is that, is it the good practice to write my own FC/FB to follow the same above? and as my understanding is correct, this L 0.1 is temp area of FB/FC and only can use inside FC/FB. Why compiler is start used this L 0.1 instead of using L 0.0 without declare anything in FC/FB? i am confused and I need suggestion from GURUs of forum. Thanks!
 
The code you are seeing is for the internal OK flag which is passed out as the block result. By default OK is true and can be set to false if required. Why the compiler writer used L0.1 is anyones guess.

Code:
FUNCTION FC2202: VOID
OK:=False;    
END_FUNCTION

Generates the following STL:

Code:
      SET   
      SAVE  
      =     L      0.1
      CLR   
      =     L      0.1
      SAVE  
      BE
 
In my opinion never good practice not using symbols when possible..

Declare in the temp area a variable named eno_out or something alike and use that instead..

Code:
SET
= #eno_out
//
CODES
ARE
HERE
//
A #eno_out
SAVE
BE

If you dont need to control the ENO output just do

Code:
//
CODES
ARE
HERE
//
SET
SAVE
BE

Or just ignore the SET SAVE..
 
Thanks LD and where can i see?

The code you are seeing is for the internal OK flag which is passed out as the block result. By default OK is true and can be set to false if required. Why the compiler writer used L0.1 is anyones guess.

Code:
FUNCTION FC2202: VOID
OK:=False;    
END_FUNCTION
Generates the following STL:

Code:
      SET   
      SAVE  
      =     L      0.1
      CLR   
      =     L      0.1
      SAVE  
      BE

Many Thanks for explanation with sample code LD 👨🏻‍🏫 again and Bara.
If i would like to know more, where can i see those meaning like L 0.0, L 0.1 ( internal OK Flag ), L 0.3 ....etc if possible. I want to use it by knowing meaning of those. I am using local data like below and is it OK to use? thanks!


L Alarm_Active // IN area of FB as Dword
T Alarm_Active_T // TEMP area of FB declare as Dword too

A L 0.0
= .....
A L 0.1
= .....
A L 0.3
= ....

:confused::confused::confused:
 
I am writing STL in S7 and ..

Hi LD,

I am Writing and Learning STL as well. To efficient my code (to be standard) , i am looking Compiled STL code and your sample code on forum for my reference. Sometimes i am confusing. Thanks!
 
You can refer to local data by it's absolute address but imagine what will happen if a new temp variable is added in front of the area you are referring to......

The solution is to use indirect addressing and AR1 to point to the named local variable. If a new temp is added no other code change is required.

Code:
      L     #Alarm_Active
      T     #Alarm_Active_T
      LAR1  P##Alarm_Active_T
      A      [AR1,P#0.0]
      =     #b00
      A      [AR1,P#0.1]
      =     #b01
//..
//... etc
//..
 
You can refer to local data by it's absolute address but imagine what will happen if a new temp variable is added in front of the area you are referring to......

The solution is to use indirect addressing and AR1 to point to the named local variable. If a new temp is added no other code change is required.

Code:
      L     #Alarm_Active
      T     #Alarm_Active_T
      LAR1  P##Alarm_Active_T
      A      [AR1,P#0.0]
      =     #b00
      A      [AR1,P#0.1]
      =     #b01
//..
//... etc
//..
Wouldnt it be much simpler to just define a symbolic name for the TEMP variable ? If a variable is added so that the variable in question gets pushed, the code will automatically update.
 
L "Some Value"
T #Some Temp Value // LW 0

A L 0.0
= ....

To prevent issues when you make #Some Other Temp Value LW0.
 
Just define TEMP symbols, and then use these symbolic names in stead of the absolute L0.0, L0.1 etc.

/bara_hence suggested this already in post #3.
 
Last edited:
OK, I see that you answer the additional question in post #4. I missed that. I love it when a thread starts with a new question midway through.
Your answer in post #7 is correct.
 

Similar Topics

Hi, I have on my plant uploaded program from from s7 315 but judging on many jumps with labels mxxx i think that is stl compiled scl. I do not...
Replies
9
Views
3,200
hi guys ! i m new to siemens SCL. Actually we have a PLC program given by our supplier who has done some programming in SCL. But he has not...
Replies
9
Views
10,305
T
Hi, I have an ABB AC500 PM-582 PLC, The question is... is it possible to get the compiled code out of the CPU, i need to have this as a backup...
Replies
7
Views
1,473
Hi. Question goes to the guys who works with ABB AC500 PLC's. Is it possible to upload the compiled code from a AC500 CPU ?. My case is that i...
Replies
1
Views
2,605
So after hours searching google and looking through everything I could find here, I have an issue that has stumped me for quite some time and was...
Replies
20
Views
10,621
Back
Top Bottom