plc.myforum.ro Forum Index plc.myforum.ro
PLCs users www.plc.myforum.ro!
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to use the ET parameter in a timer.

 
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> Programming
View previous topic :: View next topic  
Author Message
KevinEamon
Junior
Junior


Joined: 21 Oct 2018
Posts: 2

PostPosted: 21/10/2018 21:58    Post subject: How to use the ET parameter in a timer. Reply with quote

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
View user's profile Send private message
Qabbatty
Junior
Junior


Joined: 19 Oct 2018
Posts: 3

PostPosted: 22/10/2018 18:56    Post subject: Reply with quote

What software do you use?
Back to top
View user's profile Send private message
KevinEamon
Junior
Junior


Joined: 21 Oct 2018
Posts: 2

PostPosted: 26/10/2018 17:03    Post subject: Reply with quote

Unity Pro
Back to top
View user's profile Send private message
BetterIce
Junior
Junior


Joined: 16 Oct 2018
Posts: 1

PostPosted: 26/10/2018 19:13    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    plc.myforum.ro Forum Index -> Programming All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro