You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old June 15th, 2017, 12:42 PM   #1
ArthurDent
Member
Finland

ArthurDent is offline
 
Join Date: Jun 2017
Location: Iisalmi
Posts: 4
Siemens - STL to SCL

Could someone help me to convert following from STL to SCL?

AN #PV_EXT_S
JC MEAS
L #PV_EXT
L 1.000000e+000
*R
O OV
O OS
R #OKK
L #PV_EXT
JCN HYST
L #PV_U0
JU HYST

MEAS: L #U_PEW100
L #U_PEW_0
-R
L 2.000000e-002
*R
RND
T #PEW_HYST

HYST: T #PV_U0

Thank You!

AD
  Reply With Quote
Old June 15th, 2017, 03:11 PM   #2
L D[AR2,P#0.0]
Lifetime Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 5,359
Can you sort out the data types first?

For example, PV_EXT is first used as a real number, but is also used to transfer to PV_U0 which appears to be an int or dint based on the fact that the preceding code uses the RND instruction.
  Reply With Quote
Old June 15th, 2017, 03:53 PM   #3
ArthurDent
Member
Finland

ArthurDent is offline
 
Join Date: Jun 2017
Location: Iisalmi
Posts: 4
Ok.


#PV_EXT_S Bool In
#PV_EXT Real In
#OKK Bool Stat
#PV_U0 Real Stat
#U_PEW100 Real In
#U_PEW0 Real In
#PEW_HYST Int Temp

The original network continues, but for me the hardest part is

L #PV_EXT
L 1.000000e+000
*R
O OV
O OS
R #OKK
L #PV_EXT
JCN HYST
L #PV_U0
JU HYST

And those O OV and O OS. I have readed that OV = Overflow and OS = Overflow stored, but how to do these to SCL?

AD
  Reply With Quote
Old June 15th, 2017, 04:38 PM   #4
Lare
Member
Finland

Lare is offline
 
Join Date: Jan 2006
Location: Finland
Posts: 851
You can try to check status of EN0 output of block

https://support.industry.siemens.com...dti=0&lc=en-WW

Also using mix of STL and SCL
http://www.plctalk.net/qanda/showthread.php?t=8120

But why you need to change it?

Last edited by Lare; June 15th, 2017 at 04:41 PM.
  Reply With Quote
Old June 15th, 2017, 05:29 PM   #5
L D[AR2,P#0.0]
Lifetime Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 5,359
Here's my implementation.
Code:
FUNCTION FC2 : VOID
{
SCL_SetOKFlag:= 'y';
SCL_OptimizeObjectCode:='n'
}
VAR_INPUT
  PV_EXT_S : BOOL ;    
  PV_EXT : REAL ;    
  U_PEW100 : REAL ;    
  U_PEW_0 : REAL ;    
END_VAR

VAR_TEMP
 x:REAL;   
 rData:REAL;
 PEW_HYST : INT ;    
 PV_U0 : INT ;    
 OKK : BOOL ;       
END_VAR    

BEGIN
 x:=1.0;
 rData:=PV_EXT * x;
 IF OK THEN
  PV_U0:=REAL_TO_INT(PV_EXT);
 ELSE
  OKK:=False; 
  PV_U0:=PV_U0;        
 END_IF;   
END_FUNCTION
I've used x for the multiply as the compiler generates a load/transfer when multiplying by 1.0
  Reply With Quote
Old June 16th, 2017, 02:57 AM   #6
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 12,978
LD, I think you got some of the declarations wrong.
Original code:
Code:
#PV_EXT_S Bool In
#PV_EXT Real In
#OKK Bool Stat
#PV_U0 Real Stat
#U_PEW100 Real In
#U_PEW0 Real In
#PEW_HYST Int Temp
Quote:
Originally Posted by L D[AR2,P#0.0
Code:
VAR_INPUT
  PV_EXT_S : BOOL ;    
  PV_EXT : REAL ;    
  U_PEW100 : REAL ;    
  U_PEW_0 : REAL ;    
END_VAR

VAR_TEMP
 x:REAL;   
 rData:REAL;
 PEW_HYST : INT ;    
 PV_U0 : INT ;    
 OKK : BOOL ;       
END_VAR
Arthur has PV_U0 as a STAT REAL, you have PV_U0 as a TEMP INT.
Arthur has OKK as a STAT BOOL, you have OKK as a TEMP BOOL.

Quote:
Originally Posted by ArthurDent
And those O OV and O OS. I have readed that OV = Overflow and OS = Overflow stored, but how to do these to SCL?
You can evaluate the OK flag (not same as OV or OS but just one bit to cover all various error conditions). You have to set the SCL compiler to set the OK flag.
edit: Setting the compiler to set the OK flag, generates significantly bigger code. But it is probably worth it.
__________________
Jesper
3 strikes and you're out
  Reply With Quote
Old June 16th, 2017, 05:08 AM   #7
L D[AR2,P#0.0]
Lifetime Supporting Member
United Kingdom

L D[AR2,P#0.0] is offline
 
Join Date: Nov 2006
Location: UK
Posts: 5,359
The compiled SCL maintains it's own stored overflow if using arithmetic operations only:

Code:
{
SCL_SetOKFlag:= 'y';
SCL_OptimizeObjectCode:='n'
}

FUNCTION FC2 : bool
VAR_INPUT
rDataIn: REAL;    
END_VAR

VAR_TEMP
 x:REAL;   
 rData:REAL;
END_VAR    

BEGIN
x:=1.0;
rData:=rDataIn * x;
rData:=rDatain * x;
FC2:=OK;
END_FUNCTION
and compiled STL
Code:
      SET   
      SAVE  
      SET   
      =     L      8.1
      L     1.000000e+000
      T     #x
      L     #rDataIn
      L     #x
      *R    
      JO    I007
      JU    I008
I007: CLR   
      =     L      8.1
I008: T     #rData
      L     #rDataIn
      L     #x
      *R    
      JO    I009
      JU    I00a
I009: CLR   
      =     L      8.1
I00a: T     #rData
      CLR   
      A     L      8.1
      =     #RET_VAL
      A     L      8.1
      SAVE  
      BE
  Reply With Quote
Old June 16th, 2017, 07:08 AM   #8
ArthurDent
Member
Finland

ArthurDent is offline
 
Join Date: Jun 2017
Location: Iisalmi
Posts: 4
Thanks for the help.

I think that I got that now.

Next I have following so could you help me with this?

LAR1 P##STAT
L W [ AR1 , P#0.0 ]
T #STATUS


STAT is struct which consist 1 byte and 8 bools (instance db 92.0 - 93.7)
STATUS is word
Both are static.

AD
  Reply With Quote
Old June 16th, 2017, 07:35 AM   #9
JesperMP
Lifetime Supporting Member + Moderator
Denmark

JesperMP is offline
 
JesperMP's Avatar
 
Join Date: Feb 2003
Location: Copenhagen.
Posts: 12,978
To transfer data from structures with different definitions, but same size, is best done in SCL with the "AT" view.

Here is an example:
Code:
FUNCTION_BLOCK FB7

VAR
    STA : STRUCT
        byte_0 : BYTE ;
        bool_0 : BOOL ;
        bool_1 : BOOL ;
        bool_2 : BOOL ;
        bool_3 : BOOL ;
        bool_4 : BOOL ;
        bool_5 : BOOL ;
        bool_6 : BOOL ;
        bool_7 : BOOL ;
    END_STRUCT ;
    WORD_AT_STA AT STA : WORD ;
    STATUS : WORD ;
END_VAR

STATUS := WORD_AT_STA ;

END_FUNCTION_BLOCK
The above compiles to this STL code:
Code:
      L     DIW [AR2,P#0.0]
      T     #STATUS
But the functionality is the same as your original SLC code if the declarations are correct.
__________________
Jesper
3 strikes and you're out
  Reply With Quote
Old June 19th, 2017, 12:28 AM   #10
ArthurDent
Member
Finland

ArthurDent is offline
 
Join Date: Jun 2017
Location: Iisalmi
Posts: 4
Smile

Now I got it right.
Thanks for everyone who helped me.

AD
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Siemens TIA portal SCL view disassembly Hoffelhass LIVE PLC Questions And Answers 6 April 4th, 2015 01:41 AM
Siemens S7: How to: Multi instance offset in SCL inalvor1 LIVE PLC Questions And Answers 5 April 9th, 2013 07:07 AM
Siemens S7 STL Question(s) minerman LIVE PLC Questions And Answers 6 November 30th, 2012 12:55 AM
Help converting STL on Siemens S7-300 to ladder easingwm LIVE PLC Questions And Answers 13 July 30th, 2012 02:27 AM
Alternative Siemens SCL builder Mysil2 LIVE PLC Questions And Answers 1 March 16th, 2009 02:57 AM


All times are GMT -5. The time now is 02:18 AM.


.