Transition to Siemens

bobwithdana are you programming this machine, or just mainly looking for tips with siemens. Do you know which languages the machine is using if is already programmmed?
 
Last edited:
My understanding is that he is supporting a finished system. If the system is coming from Germany, chances are very high that it is written in STL. Portal is pretty good to use, but if you're coming from RSLogix 5000 ladder to TIA Portal STL, expect a steep learning curve. As they say, ladder is ladder. But STL is not ladder.
 
My understanding is that he is supporting a finished system. If the system is coming from Germany, chances are very high that it is written in STL. Portal is pretty good to use, but if you're coming from RSLogix 5000 ladder to TIA Portal STL, expect a steep learning curve. As they say, ladder is ladder. But STL is not ladder.

Well in any case it doesn't hurt to suggest Hans Berger books I have the physical copy of Automating with STL and SCL great book it covers lots of topics not just programming. I believe he also wrote some other books for TIA if I am not mistaken.
 
Why STL?

In S5 and S7-300/400 environments STL is, effectively, the native language of the system (MC5 and MC7) and higher level languages such as Ladder, FBD, SCL etc. compiled to STL. For this reason, programming directly in STL was therefore more efficient. Those of us with grandchildren and no hair remember a time when processing power was very limited so efficiency was very important. Another common reason, historically, for writing in STL is that STL allows access to the more complex functions such as indirect addressing.

In TIA Portal STL no longer seems to be the native language. I don't do much programming these days but the last I did was a text based interface to laboratory instrument over RS232. All the sequencing and logic was done in ladder but the string handling was all done in SCL but no STL was used. For anyone that thinks "you can do anything in ladder", try some string manipulation and array handling.

Nick
 
In S7-1500 you can handle strings and arrays in Ladder.
For sure it is more cumbersome than SCL since you can do one thing in one "box" at a time. But you can do it.
This image will give you an idea. You can do the same with much more complex structures if you want.

Again, for someone coming from Ladder in AB, Ladder in TIA will be very similar and immediately familiar.

TIA_strings_and_arrays.png
 
Uh, by the way. Structured Text in AB is basically the same as SCL in TIA.
So, if you have an AB Ladder program or an AB ST program, you can essentially recreate it in TIA with little fuss.
 
TIA portal has definitely brought great advantages and added instructions that AB users have benefited from for years such as Compute blocks etc. I think that the transition from AB to Siemens is easier now than it ever has been.

If anyone is bored, have a go at re-coding the following in ladder for me.

Nick

Code:
FUNCTION_BLOCK "Decode_PTP_Message"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_INPUT 
      Length : UInt := 10;
      Message_Number : UInt;
   END_VAR

   VAR_OUTPUT 
      ReturnCode : Int;
      o_ReturnString : String;
   END_VAR

   VAR_IN_OUT 
      Recv_Buffer : Array[1..511] of Byte;
      IL150_Data : "IL150_Data";
   END_VAR

   VAR 
      Current_String : Int;
      Strings : Array[1..6] of String;
      Return_String : String;
      Delimiter_Char : Char;
      Delimiter_Int : Int;
   END_VAR

   VAR_TEMP 
      iTemp : Int;   // Temp
   END_VAR

   VAR CONSTANT 
      Do_Nothing : Int;
      Check_Analogue : Int := 1;
      Check_Material : Int := 2;
      Check_Rate : Int := 3;
      Check_Shutter : Int := 4;
      Check_Thickness : Int := 5;
      Check_Version : Int := 6;
      Check_Crystal : Int := 7;
      Lock_Keyboard : Int := 8;
      Reset_Unit : Int := 9;
      Shutter_Close : Int := 10;
      Program_Material : Int := 11;
      Select_Material : Int := 12;
      Program_Analogue : Int := 13;
      Thickness_Look : Int := 14;
      Thickness_Change : Int := 15;
      Max_String : Int := 6;
   END_VAR


BEGIN
	(**************************************************************************************************
	//Name:   Decode_IL150
	//Author: Nick Maclean
	//Date:   11/2016
	//
	// Read through the recieve buffer, check the return code, Create strings of the result
	//  
	//**************************************************************************************************)
	//initialise the data fields
	FOR #Current_String := 1 TO #Max_String DO
	    #Strings[#Current_String]:= '';
	    ;
	END_FOR;
	//Start at 1
	#Current_String := 1;
	#Return_String := '';
	#iTemp := 1;
	
	#Delimiter_Char := #Recv_Buffer[2];
	#Delimiter_Int := CHAR_TO_INT(IN := #Recv_Buffer[2]);
	
	// Find the return code as string delimited by first CR (0D)
	WHILE CHAR_TO_INT(#Recv_Buffer[#iTemp])<> 13 AND #iTemp <= #Length DO // Look for Carriage return (0D)
	
	    #Return_String:= CONCAT_STRING(IN1:=#Return_String,
	                  IN2:= CHAR_TO_STRING(IN:=#Recv_Buffer[#iTemp]));
	#iTemp := #iTemp + 1;
	
	END_WHILE;
	
	// Evaluate the return code
	#ReturnCode := STRING_TO_INT(IN:= #Return_String);
	CASE #ReturnCode OF
	    0:
	        #o_ReturnString := 'Command OK';
	    1:
	        #o_ReturnString := 'Unknown Command';
	    2:
	        #o_ReturnString := 'Command Not OK Shutter Open';
	    3:
	        #o_ReturnString := 'Command Not OK Shutter Closed';
	    4:
	        #o_ReturnString := 'Error Converting Command to Real Value';
	    5:
	        #o_ReturnString := 'Command Parameter exceeds allowed range';
	    6:
	        #o_ReturnString := 'Command String Exceeds 15 Chars';
	    7:
	        #o_ReturnString := 'Parameter String Exceeds 15 Chars';
	    8:
	        #o_ReturnString := 'Internal Error';
	    9:
	        #o_ReturnString := 'Input Buffer Full';
	    ELSE  // Statement section ELSE
	        #o_ReturnString := 'Comms Error';
	END_CASE;
	
	
	IF #ReturnCode = 0 THEN;
	    //decode
	    //#iTemp := #iTemp + 1; // point to next character in the buffer
	    FOR #iTemp := #iTemp +1 TO UINT_TO_INT(IN:= #Length) DO
	        IF #Recv_Buffer[#iTemp] = '$R' THEN; //Check for string delimiter
	            #Current_String := #Current_String + 1; //point to next string
	            IF #Current_String > #Max_String THEN
	                ;
	                #Current_String := #Max_String; //range check
	            END_IF;
	        ELSE
	            #Strings[#Current_String] := CONCAT_STRING(IN1 := #Strings[#Current_String],
	                                                       IN2 := CHAR_TO_STRING(IN := #Recv_Buffer[#iTemp]));
	        END_IF;
	        
	    END_FOR;
	    
	    CASE UINT_TO_INT(IN:= #Message_Number) OF
	        #Check_Analogue:  // Statement section case 1
	            #IL150_Data.Analogue_Mode := STRING_TO_INT(IN := #Strings[1]);
	            ;
	        #Check_Material:  // Statement section case 2
	            IF #Current_String = 6 THEN  // Full message recieved?
	                
	                #IL150_Data.Material_Data.Density := STRING_TO_REAL(IN := #Strings[2]);
	                #IL150_Data.Material_Data.Z_Value := STRING_TO_REAL(IN := #Strings[3]);
	                #IL150_Data.Material_Data.Temination_Thickness := STRING_TO_REAL(IN := #Strings[4]);
	                #IL150_Data.Material_Data.Tooling := STRING_TO_REAL(IN := #Strings[5]);
	                #IL150_Data.Material_Data.Crystal_Number := STRING_TO_UINT(IN := #Strings[6]);
	                ;
	                #iTemp := STRING_TO_INT(IN := #Strings[1]);
	                IF #iTemp > 0 AND #iTemp <= 8 THEN
	                    #IL150_Data.Material[#iTemp].Density := STRING_TO_REAL(IN := #Strings[2]);
	                    #IL150_Data.Material[#iTemp].Z_Value := STRING_TO_REAL(IN := #Strings[3]);
	                    #IL150_Data.Material[#iTemp].Temination_Thickness := STRING_TO_REAL(IN := #Strings[4]);
	                    #IL150_Data.Material[#iTemp].Tooling := STRING_TO_REAL(IN := #Strings[5]);
	                    #IL150_Data.Material[#iTemp].Crystal_Number := STRING_TO_UINT(IN := #Strings[6]);
	                END_IF;
	            END_IF;
	            
	        #Check_Rate:  // Statement section case 3
	            #IL150_Data.Current_Rate:=STRING_TO_REAL(IN := #Strings[1]);
	            ;
	        #Check_Shutter:  // Statement section case 4
	            #iTemp := STRING_TO_INT(IN := #Strings[1]);
	            IF #iTemp = 1 THEN
	                #IL150_Data.Shutter_Is_Open := true;
	            ELSE
	                #IL150_Data.Shutter_Is_Open := false;
	            END_IF
	                ;
	        #Check_Thickness:  // Statement section case 5
	            #IL150_Data.Current_Thickness:= STRING_TO_REAL(IN := #Strings[1]);
	            ;
	        #Check_Version:  // Statement section case 6
	            #IL150_Data.Version_Number := #Strings[1];
	            ;
	        #Check_Crystal:  // Statement section case 7
	            #IL150_Data.Crystal_Number:=STRING_TO_INT(IN := #Strings[1]);
	            #IL150_Data.Crystal_Hz:=STRING_TO_DINT(IN := #Strings[2]);
	            ;
	        #Lock_Keyboard:  // Statement section case 8
	            #IL150_Data.Lock_Keyboard := false;
	            ;
	        #Reset_Unit:  // Statement section case 9
	            #IL150_Data.Reset := false;
	            ;
	        #Shutter_Close:  // Statement section case 10
	            #IL150_Data.Close_Shutter := false;
	            ;
	        #Program_Material:  // Statement section case 11
	            #IL150_Data.Program_Material := false;
	            ;
	        #Select_Material:  // Statement section case 12
	            #IL150_Data.Select_Material := false;
	            ;
	        #Program_Analogue:  // Statement section case 13
	            #IL150_Data.Program_Analogue := false;
	            ;
	        #Thickness_Look:  // Statement section case 14
	            #IL150_Data.Thickness_Look := false;
	            ;
	        #Thickness_Change:  // Statement section case 15
	            #IL150_Data.Thickness_Change := false;
	            ;
	        ELSE  // Statement section ELSE
	            ;
	    END_CASE;
	    
	    
	    
	END_IF;
	
	
	    
	    
END_FUNCTION_BLOCK
 
I think the goal is to keep the program readable for maintenance yes I agree, but that doesn't mean stick only to ladder. As system designers one must question if over complicating something is worth it by doing it strictly in ladder. STL is not even that hard to learn in my opinion but I'm a bit biased since I knew computer programming prior.

Of course you can encapsulate all the stl/scl logic you want in FB's and still use ladder in the program and still make a readable program.
 
I think this entire thread has been derailed from the original topic.
I apologize if I am partially guilty of this, by responding to fredz0003's post #3.
(I try to explain that it is not absolutely necessary to learn STL, especially for S7-1500).
 
"You vill do it ze Siemens vay! No other vays is permitted!"

And this is the biggest problem I have with Siemens and other German companies.

Other issues:
- The Germans tend to have all programming done by engineers, not technicians or trades. The result is that they favor "high level" languages at the expense of the more user friendly ladder logic.

- The documentation is terrible, and there are few examples, if any.

- The entire system seems set up to encourage the customer to just pay Siemens to do the programming, and once they have you by the short hairs they have a revenue stream in perpetuity.

Having whined about all that, they can do (eventually) anything AB can do, and the hardware is all but bullet proof. When I made the migration I found that instead of trying to find equivalent instructions (Example: Where is their TON command?) to think in terms of function (Example: How do I delay this operation?)

Our local rep provided some excellent training - superior to anything Siemens offered. If your rep has similar I suggest it is worth the investment.
 
I would also like to apologise for contributing to the off-topic discussion about ladder vs STL.

As JesperMP points out, learning STL is no longer necessary. STL isn't as hard as you might imagine but an understanding of accumulators and registers helps with understanding. In the future, we will see less and less code written in STL because there is little need for it in TIA Portal.

Nick
 
"Learning STL is no longer necessary"

For new projects, this is correct. If the OP is receiving equipment already programmed in STL that he has to support, on the other hand...
 

Similar Topics

Hi Guys, I have been offered a job with a very good multinational company to maintain and troubleshoot their automated equipment. This is a...
Replies
7
Views
3,896
How difficult is the transition from Automation direct Click to Allen Bradley 800 series of plc and CCW software? Also, can you use C-More HMI’s...
Replies
11
Views
2,300
I have gotten help with some issues in the past on this forum, and I'm hoping someone can help me again. My company is an OEM that used the...
Replies
1
Views
960
For nearly 20 years, my employer (an OEM) used the A1SJH in a portable testing machine that required calibration of several sensors. The...
Replies
2
Views
876
Hey All, Presently I am looking for transistion of S7 200 to 1500, I found out some transition manuals from 200 to 1200 which offers to use a...
Replies
2
Views
1,428
Back
Top Bottom