Scl Output Problem

userxyz

Member
Join Date
May 2002
Location
any
Posts
2,768
The following code does some weird things with my outputs... is it just like in Lad, or stl not permitted to use outputs more the once ??

And if u see other thing that can be written more shortly, please let me know,

thanks in forward

FUNCTION_BLOCK FB95
// PROCESSING CENERPRO

VAR_INPUT
RUN: BOOL;
Auto_Seq: BOOL;
Voorloper: BOOL;
Tapijt: BOOL;
INDS_1_Up: BOOL;
INDS_2_Down: BOOL;
Start_Stop_Vac_1: BOOL;
Start_Stop_Vac_2: BOOL;
Onderdruk_Voorafz: REAL;
Start_Stop_Hydr_Pump: BOOL;
END_VAR

VAR_OUTPUT
Background_Voorloper: INT;
Background_Tapijt: INT;
Zoemer: BOOL;
Vacuumpompen: BOOL;
Hydraulic_Pump_Trommel: BOOL;
Trommel_Up: BOOL;
Trommel_Down: BOOL;
END_VAR

VAR
Membit_1: BOOL;
Membit_2: BOOL;
Flank_Voorloper: BOOL;
Flank_Tapijt: BOOL;
END_VAR


BEGIN

IF Auto_Seq = TRUE THEN

Flank_Voorloper:= Voorloper AND (NOT Membit_1);
Flank_Tapijt:= (NOT Tapijt) AND Membit_2;

IF Flank_Voorloper AND INDS_2_Down = TRUE AND RUN = TRUE THEN
Background_Voorloper:= 4; // 1 = Grijs, 4 = Groen, 7 = Groen Blinken
Background_Tapijt:= 1;
Start_Stop_Vac_1:= FALSE;
Start_Stop_Vac_2:= FALSE;
Hydraulic_Pump_Trommel:= TRUE;
Trommel_Up:= TRUE;
END_IF;

IF Flank_Tapijt THEN
IF INDS_1_Up = TRUE AND RUN = TRUE THEN // Klaarzetten voor overgang naar Tapijt
Background_Voorloper:= 1;
Background_Tapijt:= 7;
Start_Stop_Vac_1:= TRUE;
Start_Stop_Vac_2:= TRUE;
Start_Stop_Hydr_Pump:= TRUE;
Trommel_Down:= TRUE;
END_IF;
IF Background_Tapijt = 7 AND Onderdruk_Voorafz > 0.25 AND INDS_2_Down = TRUE AND RUN = TRUE THEN // Overgang naar Tapijt
Background_Tapijt:= 4;
END_IF;
END_IF;

IF INDS_2_Down = TRUE THEN // Trommel is beneden
Trommel_Down:= FALSE;
Start_Stop_Hydr_Pump:= FALSE;
END_IF;

IF INDS_1_Up = TRUE THEN // Trommel is boven
Trommel_Up:= FALSE;
Start_Stop_Hydr_Pump:= FALSE;
END_IF;

IF Background_Tapijt = 7 THEN // Zoemer tijdens opstartfase
Zoemer:= TRUE;
ELSE
Zoemer:= FALSE;
END_IF;

Membit_1:= Voorloper; // Flanken wegschrijven
Membit_2:= Tapijt;

ELSE
Background_Voorloper:= 1;
Background_Tapijt:= 1;
Start_Stop_Vac_1:= FALSE;
Start_Stop_Vac_2:= FALSE;
Start_Stop_Hydr_Pump:= FALSE;
Trommel_Down:= FALSE;
Trommel_Up:= FALSE;
END_IF;

END_FUNCTION_BLOCK
[/QUOTE]
 
Just a question and I know this is part to do with personal preferences.

Why do you write machine controlling apps in SCL?

I've noticed all your apps are SCL these days.

If I was a customer, I would go banana's if I was supplied a piece of equipment written totally in SCL.

Simple code in ladder, more complex in STL.

I was totally against SCL, simply because I dumped on site a few times expected to commission someone elses code, who wrote almost exclusively in SCL and I didn't have the SCL package, gave me nightmares.

I have been persuaded that there are cases where SCL is preferred, handling arrays and probably mass data manipulation, I'm sure there's more.

The simplest methods are usually the best and this includes using the best tool for the job.

If your reasons are because the client will never see the code and SCL is what your best at, then fair enough I suppose.
 
is it just like in Lad,

Handling of outputs is not just like in ladder.

With a ladder instruction there are are two possible states for the output, ON or OFF.

If the ladder solves to true, the control turns the output ON, if the ladder solves to false, teh control turns the output OFF.

To duplicate this functionality, for every output instruction you put in an IF block, you have to put the opposite in an ELSE block.

You do this here:
IF Background_Tapijt = 7 THEN // Zoemer tijdens opstartfase
Zoemer:= TRUE;
ELSE
Zoemer:= FALSE;
END_IF;

But not in many other places. I suspect that is what your problem is.

The other way to handle this is to have all your ON/OFF conditions in the code and then AND & OR them together in a statement that is outside of any IF/THEN constructs. So you could also write the above as:

Zoemer := (Background_Tapijt = 7);

In general, always be warry of an IF-THEN without an ELSE !
 
ndzied1 said:
Handling of outputs is not just like in ladder.

With a ladder instruction there are are two possible states for the output, ON or OFF.

If the ladder solves to true, the control turns the output ON, if the ladder solves to false, teh control turns the output OFF.

You have overlooked the SET/RESET instructions available in ladder.
 
You have overlooked the SET/RESET instructions available in ladder.
Good point. However, I only use those instructions for a few specific tasks where they make sense for me and otherwise avoid them like the plague.

They suffer the same issues as the IF without the ELSE scenario...
 
Hey

I think I have to agree,

things that I did with arrays are well placed with SCL. But now writing the logic sequences in SCL is just stupid of me



PeterW said:
Just a question and I know this is part to do with personal preferences.

Why do you write machine controlling apps in SCL?

I've noticed all your apps are SCL these days.

If I was a customer, I would go banana's if I was supplied a piece of equipment written totally in SCL.

Simple code in ladder, more complex in STL.

I was totally against SCL, simply because I dumped on site a few times expected to commission someone elses code, who wrote almost exclusively in SCL and I didn't have the SCL package, gave me nightmares.

I have been persuaded that there are cases where SCL is preferred, handling arrays and probably mass data manipulation, I'm sure there's more.

The simplest methods are usually the best and this includes using the best tool for the job.

If your reasons are because the client will never see the code and SCL is what your best at, then fair enough I suppose.
 
It seems that everyone agree that logic programming is best done in LAD/FBD/STL.
I just want to add another argument to support that.

When you troubleshoot a program online, in SCL there are two panes, one pane is with the full code, the other pane is with the online values only.
So, to digest the current logic status, you have to combine the information from these two panes.
It will look something like this:
Left pane                                                                         Right pane
Start_cmd := (((Start_Cmd OR Start_button) AND NOT Stop_button) OR Man_start) ; TRUE, TRUE, FALSE, FALSE, FALSE

It is all text - very hard to follow. It is not like in LAD where you can graphically see the logical result by the color of each variable.
It is OK to put a little logic here and there, but dont write a complete logic program in SCL.
 
Jesper

There is nothing in the SCL editor or compiler that says a 'line' of code has to be written on one line. You could take the one line you've written and re-write it as -
Code:
Start_cmd :=					True
(
((Start_Cmd OR Start_button)			True, False
AND NOT
Stop_button)					False
OR
Man_start					False
);
or any other pattern you require.

And PeterW, to blame SCL for your dissatisfaction when you said
I was totally against SCL, simply because I dumped on site a few times expected to commission someone elses code, who wrote almost exclusively in SCL and I didn't have the SCL package, gave me nightmares.
is like blaming screws for not being nails when the only tool you had at the time was a hammer!

I feel like I should be going to ST Anonymous. "My name's Ken, and I like Structured Text."
 
Ken, yes that would partly fix the problem with the online display. It is still nowhere as easy to interpret visually as LAD or FBD.

And writing the code in several lines like you suggest will make the code bloom up. It will just be another way to write STL, only the result will be in the 1st line of the code.

I feel like I should be going to ST Anonymous. "My name's Ken, and I like Structured Text."
You are not alone. I find that I write more and more in SCL. I really like SCL actually.
When I started with SCL I began to also write logic in SCL (just like Combo), but found that it was not the right tool for this part of my projects.
Sidetracking comment:
What would be REALLY nice, would be to be able to switch language freely within the same code block. Then you write some logic in LAD, switch to SCL for some array code and some complex math, and then to STL and then to LAD again etc.
But it will never happen.
 
Last edited:
JesperMP said:
Sidetracking comment:
What would be REALLY nice, would be to be able to switch language freely within the same code block. Then you write some logic in LAD, switch to SCL for some array code and some complex math, and then to STL and then to LAD again etc.
But it will never happen.

This is already possible with CoDeSys using somethign called an Action. Within one POU you can have many actions each using a different one of the IEC 61131 languages.

Indeed, Very Useful,
http://www.3s-software.com/
 
ndzied1 said:
This is already possible with CoDeSys using somethign called an Action. Within one POU you can have many actions each using a different one of the IEC 61131 languages.
Does it looke like this:

[network 1 - LAD] 

|---|/|-------| |----( )
| |
| |
|---| |---|

[network 2 - ST]
IF biStart THEN
rOut:= (rIn * rFactor + rOffset) + rArrayLib[iIndex] ;
ELSE
rOut:= 0 ;
biDone := FALSE ;
END_IF ;

[network 3 - IL]
L rOut
T MW500
INC MW502

etc...

Then that is what I would like to have !
I doubt that we will ever see this in an S7.
 
Ken M said:
And PeterW, to blame SCL for your dissatisfaction when you said is like blaming screws for not being nails when the only tool you had at the time was a hammer!

I feel like I should be going to ST Anonymous. "My name's Ken, and I like Structured Text."


:)

I do agree with you Ken, as I said I have been persuaded otherwise with examples of where best to use it.

One major problem though, is the fact that I was enabled to be in that position. SCL is not a part of the standard S7 package, you have to pay more for it. The company I was with at the time would not pay for it for me to have. (It converts into the worse STL I have seen, with no comments of course)

I'm sure others have been in the same situation, so I waould ensure that SCL is acceptable to the customer first.
 
JesperMP said:
Does it looke like this:

[network 1 - LAD] 

|---|/|-------| |----( )
| |
| |
|---| |---|

[network 2 - ST]
IF biStart THEN
rOut:= (rIn * rFactor + rOffset) + rArrayLib[iIndex] ;
ELSE
rOut:= 0 ;
biDone := FALSE ;
END_IF ;

[network 3 - IL]
L rOut
T MW500
INC MW502

etc...

Then that is what I would like to have !
I doubt that we will ever see this in an S7.

No it´s still a blockcall from inside your POU, sort of same as in Step7 but in Codesys I think you get a better overview of the block/actions being called in your POU.
Note:You still declare the variables in your POUT where you call your actions.
 
coded

I wrote the array-data and comparisions in SCL

And the main sequence in LAD:

vdxvxc.JPG
 

Similar Topics

Hello all, trying to write a FB to handle cam outputs, and my typical method of "do what I would do in VBA" isn't working this time. I was...
Replies
1
Views
1,553
I'm currently investigating the usage of a Siemens S7-315 PLC to control a row of "shift registers". I would use one data signal and one clock...
Replies
10
Views
4,192
HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
71
Hi, I have an intermediate-advance knowledge of programming with TIA Porta in Ladder, would you recommend me to start learning SCL for it to...
Replies
11
Views
558
Hello nice to meet you, im new in here, I'm currently trying to convert code written in STL for a S7-400 to SCL for an S7-1500, because when i run...
Replies
5
Views
316
Back
Top Bottom