Siemens - STL to SCL

STL to SCL

Hello!

Could you please help to convert STL to SCL code?

I'm stuck on this part:

Code:
L     #Adr_Param_In;  // load Adr_Param_In to ACCU1
T     LW     2;      // copy ACCU1 to LW2 but why I don't understand
A     L      0.1;    // RLO AND L0.1 where L0.1 is used is it some pre-defined local bit?
SAVE  ; 
L     DW#16#10020008;  // this line is a mystery for me, what 10020008 means?

The code below is a generated source code of FB400 which was originally written in SCL before, but source code is lost now.
Code:
FUNCTION_BLOCK FB400
TITLE =
VERSION : 0.0


VAR_INPUT
  Adr_Param_In : INT ;	
  Adr_Param_Out : INT ;	
  Read : BOOL ;	
  Write : BOOL ;	
  Parameter : WORD ;	
  Param_Set : BYTE ;	
  Value_Write : DINT ;	
END_VAR
VAR_OUTPUT
  Done : BOOL ;	
  Value_Read : DINT ;	
  Error : BOOL ;	
  ErrorCode : DWORD ;	
END_VAR
VAR
  Edge_Read : BOOL ;	
  HM_Edge_Read : BOOL ;	
  Edge_Write : BOOL ;	
  HM_Edge_Write : BOOL ;	
  Status : INT ;	
  ParamChannel : STRUCT 	
   Control : BYTE ;	
   Set : BYTE ;	
   Param : WORD ;	
   Data : DWORD ;	
  END_STRUCT ;	
  Handshake : BYTE ;	
  Time_Out_Counter : INT ;	
  Temp : INT ;	
END_VAR
BEGIN
NETWORK
TITLE =SCL Netzwerk
//generiert vom SCL Ьbersetzer Version:  SCLCOMP K05.03.05.00_01.03.00.01 release
      SET   ; 
      SAVE  ; 
      =     L      0.1; 
      CLR   ; 
      =     #Done; 
      A     #HM_Edge_Read; 
      NOT   ; 
      A     #Read; 
      =     #Edge_Read; 
      A     #Read; 
      =     #HM_Edge_Read; 
      A     #HM_Edge_Write; 
      NOT   ; 
      A     #Write; 
      =     #Edge_Write; 
      A     #Write; 
      =     #HM_Edge_Write; 
      L     #Status; 
      L     0; 
      ==I   ; 
      A     #Edge_Read; 
      JCN   A7d0; 
      L     1; 
      T     #Status; 
      L     L#0; 
      T     #Value_Read; 
      CLR   ; 
      =     #Error; 
      L     DW#16#0; 
      T     #ErrorCode; 
A7d0: L     #Status; 
      L     0; 
      ==I   ; 
      A     #Edge_Write; 
      JCN   A7d1; 
      L     2; 
      T     #Status; 
      L     L#0; 
      T     #Value_Read; 
      CLR   ; 
      =     #Error; 
      L     DW#16#0; 
      T     #ErrorCode; 
A7d1: L     #Status; 
      L     0; 
      ==I   ; 
      JCN   A7d2; 
      A     L      0.1; 
      SAVE  ; 
      BEU   ; 
A7d2: L     #Status; 
      L     1; 
      ==I   ; 
      L     #Status; 
      L     2; 
      =     L      0.2; 
      ==I   ; 
      O     L      0.2; 
      JCN   A7d3; 
      L     #Adr_Param_In; 
      T     LW     2; 
      A     L      0.1; 
      SAVE  ; 
      L     DW#16#10020008; 
      T     LD     4; 
      L     DINO; 
      T     LW     8; 
      TAR2  ; 
      +     L#240; 
      T     LD    10; 
      TAR2  LD    14; 
      UC    SFC   14 {
            P#L 2.0,
            P#L 18.0,
            P#L 4.0};
      LAR2  LD    14;
      L     LW    18; 
      T     #Temp; 
      L     #Temp; 
      L     0; 
      <>I   ; 
      JCN   A7d4; 
      L     #Temp; 
      A     L      0.1; 
      SAVE  ; 
      AD    DW#16#FFFF; 
      T     #ErrorCode; 
      SET   ; 
      =     #Error; 
      TAK   ; 
      T     #Status; 
      L     L#0; 
      T     #Value_Read; 
      A     L      0.1; 
      SAVE  ; 
      BEU   ; 
A7d4: L     #ParamChannel.Control; 
      L     B#16#40; 
      AW    ; 
      L     B#16#40; 
      ==I   ; 
      JCN   A7d5; 
      L     B#16#0; 
      T     #ParamChannel.Control; 
      JU    A7d6; 
A7d5: L     B#16#40; 
      T     #ParamChannel.Control; 
A7d6: L     #Parameter; 
      CLR   ; 
      A     L      0.1; 
      SAVE  ; 
      L     8192; 
      +I    ; 
      JO    I007; 
      JU    I008; 
I007: CLR   ; 
      =     L      0.1; 
I008: T     #Temp; 
      L     #Temp; 
      CLR   ; 
      A     L      0.1; 
      SAVE  ; 
      T     #ParamChannel.Param; 
      L     #Param_Set; 
      T     #ParamChannel.Set; 
      L     #Status; 
      L     1; 
      ==I   ; 
      JCN   A7d7; 
      L     DW#16#0; 
      T     #ParamChannel.Data; 
      L     #ParamChannel.Control; 
      L     B#16#1; 
      OW    ; 
      T     #ParamChannel.Control; 
      JU    A7d8; 
A7d7: L     #Value_Write; 
      CLR   ; 
      A     L      0.1; 
      SAVE  ; 
      T     #ParamChannel.Data; 
      L     #ParamChannel.Control; 
      L     B#16#32; 
      OW    ; 
      T     #ParamChannel.Control; 
A7d8: L     #Adr_Param_Out; 
      T     LW     2; 
      CLR   ; 
      A     L      0.1; 
      SAVE  ; 
      L     DW#16#10020008; 
      T     LD     4; 
      L     DINO; 
      T     LW     8; 
      TAR2  ; 
      +     L#240; 
      T     LD    10; 
      TAR2  LD    14; 
      UC    SFC   15 {
            P#L 2.0,
            P#L 4.0,
            P#L 18.0};
      LAR2  LD    14;
      L     LW    18; 
      T     #Temp; 
      L     #Temp; 
      L     0; 
      <>I   ; 
      JCN   A7d9; 
      L     #Temp; 
      A     L      0.1; 
      SAVE  ; 
      AD    DW#16#FFFF; 
      T     #ErrorCode; 
      SET   ; 
      =     #Error; 
      TAK   ; 
      T     #Status; 
      L     L#0; 
      T     #Value_Read; 
      A     L      0.1; 
      SAVE  ; 
      BEU   ; 
A7d9: L     #ParamChannel.Control; 
      L     B#16#40; 
      AW    ; 
      T     #Handshake; 
      L     0; 
      T     #Time_Out_Counter; 
      L     #Status; 
      L     2; 
      +I    ; 
      JO    I009; 
      JU    I00a; 
I009: CLR   ; 
      =     L      0.1; 
I00a: T     #Status; 
A7d3: L     #Status; 
      L     3; 
      ==I   ; 
      L     #Status; 
      L     4; 
      =     L      0.2; 
      ==I   ; 
      O     L      0.2; 
      JCN   A7da; 
      L     #Adr_Param_In; 
      T     LW     2; 
      A     L      0.1; 
      SAVE  ; 
      L     DW#16#10020008; 
      T     LD     4; 
      L     DINO; 
      T     LW     8; 
      TAR2  ; 
      +     L#240; 
      T     LD    10; 
      TAR2  LD    14; 
      UC    SFC   14 {
            P#L 2.0,
            P#L 18.0,
            P#L 4.0};
      LAR2  LD    14;
      L     LW    18; 
      T     #Temp; 
      L     #Temp; 
      L     0; 
      <>I   ; 
      JCN   A7db; 
      L     #Temp; 
      A     L      0.1; 
      SAVE  ; 
      AD    DW#16#FFFF; 
      T     #ErrorCode; 
      SET   ; 
      =     #Error; 
      TAK   ; 
      T     #Status; 
      A     L      0.1; 
      SAVE  ; 
      BEU   ; 
A7db: L     #Time_Out_Counter; 
      L     1; 
      +I    ; 
      JO    I00b; 
      JU    I00c; 
I00b: CLR   ; 
      =     L      0.1; 
I00c: T     #Time_Out_Counter; 
      L     #Time_Out_Counter; 
      L     1000; 
      >I    ; 
      JCN   A7dc; 
      L     DW#16#FFFFFFFF; 
      T     #ErrorCode; 
      SET   ; 
      =     #Error; 
      L     0; 
      T     #Status; 
      A     L      0.1; 
      SAVE  ; 
      BEU   ; 
A7dc: L     #ParamChannel.Control; 
      L     B#16#40; 
      AW    ; 
      L     #Handshake; 
      <>I   ; 
      JCN   A7dd; 
      A     L      0.1; 
      SAVE  ; 
      BEU   ; 
A7dd: L     #ParamChannel.Control; 
      L     B#16#80; 
      AW    ; 
      L     B#16#0; 
      <>I   ; 
      JCN   A7de; 
      L     #ParamChannel.Data; 
      T     #ErrorCode; 
      SET   ; 
      =     #Error; 
      L     0; 
      T     #Status; 
      A     L      0.1; 
      SAVE  ; 
      BEU   ; 
A7de: L     #Status; 
      L     3; 
      ==I   ; 
      JCN   A7df; 
      L     #ParamChannel.Data; 
      T     #Value_Read; 
      A     L      0.1; 
      SAVE  ; 
A7df: L     0; 
      T     #Status; 
      SET   ; 
      =     #Done; 
A7da: CLR   ; 
      A     L      0.1; 
      SAVE  ; 
      BE    ; 
END_FUNCTION_BLOCK
 
For your mystery question, the 1002008 is used to form the anypointer (10) for the RECORD parameter for SFC14, which consists of 8 (0008) bytes (02).
 
If you look at a call to SFC14 in SCL and the corresponding STL, all should become clear. All parameters passed to FCs and SFCs are passed by pointer and the local data area is used for this purpose.

scl.jpg
 
Save

If you look at a call to SFC14 in SCL and the corresponding STL, all should become clear. All parameters passed to FCs and SFCs are passed by pointer and the local data area is used for this purpose.

L D[AR2,P#0.0], can you help with this part please?

Code:
...
L     #Adr_Param_In; 
T     LW     2; 
[B][COLOR="Red"]A     L      0.1; 
SAVE  ;[/COLOR] [/B]
L     DW#16#10020008; 
...

and

Code:
...
JCN   A7d4; 
L     #Temp; 
[B][COLOR="Red"]A     L      0.1; 
SAVE  ;[/COLOR][/B] 
AD    DW#16#FFFF; 
T     #ErrorCode;
...

How to convert red lines to SCL?

I found that

Code:
SAVE  
BEU

it is RETURN in SCL.
 
I haven't had a chance to look it it yet, but you absolutely sure about that?

I don't know how to make the compiler to generate these instructions, but when I enabled the "Set OK Flag" the SCL compiler generated most of these lines itself.
I almost completely restored the original SCL source code, there are still minor differences e.g. jump label names, but I think it's because of compiler versions mismatch.

I posted the SCL code here https://pastebin.com/xn1Ntwfv
because forum gives me the error that text is too long.

L D[AR2,P#0.0], Can you please try to compile my SCL code and compare?
 

Similar Topics

Could someone help me to convert following from STL to SCL? AN #PV_EXT_S JC MEAS L #PV_EXT L 1.000000e+000...
Replies
9
Views
2,674
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...
Replies
15
Views
6,751
Hi all, i recently purchased a second hand copy of hans bergers scl/stl book,but unfortunately the floppy disc supplied with the...
Replies
2
Views
4,114
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
639
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,200
Back
Top Bottom