| View previous topic :: View next topic |
| Author |
Message |
KevinEamon Junior

Joined: 21 Oct 2018 Posts: 2
|
Posted: 21/10/2018 21:58 Post subject: How to use the ET parameter in a timer. |
|
|
Hi guys
I'm new to the forum and structured text.
I'm just starting here - working on a traffic light system.
So I have created this piece of structured text, linked to a little animation on the operations screen:-
------------------------------------------------------------
Fb_Traffic_Timer(IN:=Button_4,PT:=T#10S);
IF Fb_Traffic_Timer.Q THEN
Light4_Red :=1;
ELSE
Light4_Red :=0;
END_IF;
----------------------------------------------
What I'd like to do instead is something like this:-
IF (Fb_Traffic_Timer.ET >= 5S) THEN... |
|
| Back to top |
|
 |
Qabbatty Junior

Joined: 19 Oct 2018 Posts: 3
|
Posted: 22/10/2018 18:56 Post subject: |
|
|
| What software do you use? |
|
| Back to top |
|
 |
KevinEamon Junior

Joined: 21 Oct 2018 Posts: 2
|
Posted: 26/10/2018 17:03 Post subject: |
|
|
| Unity Pro |
|
| Back to top |
|
 |
BetterIce Junior

Joined: 16 Oct 2018 Posts: 1
|
Posted: 26/10/2018 19:13 Post subject: |
|
|
you can use something like this..adapt to unity..
| Code: | FUNCTION_BLOCK ALTERNATOR
VAR_INPUT
IN: BOOL;
T1: TIME;
T2: TIME;
END_VAR
VAR_OUTPUT
Q1:BOOL;
Q2:BOOL;
END_VAR
VAR
tStart:TIME;
tET: TIME;
xM:BOOL;
END_VAR
IF IN THEN
IF NOT xM THEN
tStart := TIME();
END_IF
IF NOT Q1 AND NOT Q2 THEN
Q1 := TRUE;
END_IF
tET := TIME() - tStart;
IF Q1 AND tET >= T1 THEN
Q1 := FALSE;
Q2 := TRUE;
tStart := TIME();
tET := T#0s;
END_IF
IF Q2 AND tET >= T2 THEN
Q2 := FALSE;
Q1 := TRUE;
tStart := TIME();
tET := T#0s;
END_IF
ELSE
Q1 := FALSE;
Q2 := FALSE;
END_IF
xM := IN;
END_FUNCTION_BLOK |
and then call
| Code: | PROGRAM PLC_PRG
VAR
fbT: ALTERNATOR;
xStart: BOOL;
xOut1: BOOL;
xOut2: BOOL;
END_VAR
fbT(IN := xStart, T1 := T#2s, T2:= T#1s, Q1 => xOut1, Q2 => xOut2);
END_PROGRAM |
T1 and T2 can be set as you need.. |
|
| Back to top |
|
 |
|