S7 TIA Convert STL to SCL

barryoc

Lifetime Supporting Member
Join Date
Nov 2009
Location
Kilkenny
Posts
148
Hi all,


I'm currently trying to convert code written in STL for a S7-300 to SCL for an S7-1200. I'm getting stuck trying to address inputs in SCL and assign the offset like I have done in STL. I would be grateful if ye can point me in the right direction on how to convert this code to SCL. Do I need to declare variables to access the inputs and outputs?



Regards,
Barry.

FC3.png
 
Declare your inputs as a UDT of an array of bools and likewise your bits in the DB, then the code becomes trivial:

switch2.jpg
 
Last edited:
Thanks LD,


My current DB has an array of [1..18 1..8] of integer and then 40 bools. These relates to 18 switches with each switch having 8 physical switches and 40 different lights that can be switched on. The integer value in the array (0 - 39) corresponds to the actual light that I want to switch on. I'm totally new to SCL so any further help is greatly appreciated.


Many Tahnks,
Barry.

db17.png
 
Last edited:
I think that if you have 1200 CPU with FW4.1 or later then you can use serialize and deserialize commands for copying array of [1..18 1..8] of integer to new array 1...144 of integer.

Then loop these 1..144 integer value as you have done STL and SET bool outputs according of values.


https://support.industry.siemens.com/cs/ww/en/view/42603881




Pseudo code after this new 1..144 integer array would be something



(Not tested and limit integer values so that CPU not go to error if lamb_number is not between 0 and 39.)


FOR #i := 0 to 39 DO
lamp_outpus = false;
END_FOR;


FOR #j := 1 TO 144 DO
lamp_numb := Switches_1_144_array[#j];
lamp_outputs[#lamb_numb] = true;
END_FOR;
 
LD/Lare


With your help I finally managed to replicate my STL function in SCL. I needed to and a third array of 144 bools for the physical switch. I must admit my description of what I required was not the best. Attached is my final code, commented which hopefully explains what i was trying to achieve.


Thanks again,
Barry.


FB1 SCL.png
 

Similar Topics

I need to convert some Siemens PLC logic using Siemens TIA V16 to Modicon M580 logic. Is there a tool out there that will get me started? How...
Replies
3
Views
2,691
First time I have used an absolute encoder and it is definitely:banghead:. I have a Siemens 6FX2001-5FN25...
Replies
21
Views
6,070
i need a little help, i got a project file from one of my friends this project file is belonging to him for one of his projects, he sent it to me...
Replies
16
Views
5,077
Hi,I created a project in TIA V12 and started programming.Recently i received a request to migrate this project to Step7 and continue the...
Replies
3
Views
4,851
Helo I have a FB-Libary in Step 7 v5.4 i want to use in TIA-Portal V11 Sp2. How can i convert this?
Replies
5
Views
5,159
Back
Top Bottom