0% found this document useful (0 votes)
6 views1 page

Structure Text Programming - Codesys 14

The document outlines a traffic light control subroutine for the AB ControlLogix platform, detailing the state transitions and timer enable conditions for green and yellow lights in both east-west (EW) and north-south (NS) directions. It describes the logic flow using a state machine, where each state corresponds to a specific light configuration. The subroutine includes timer functions and boolean aliases for controlling the traffic lights based on the current state.

Uploaded by

edlistianto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views1 page

Structure Text Programming - Codesys 14

The document outlines a traffic light control subroutine for the AB ControlLogix platform, detailing the state transitions and timer enable conditions for green and yellow lights in both east-west (EW) and north-south (NS) directions. It describes the logic flow using a state machine, where each state corresponds to a specific light configuration. The subroutine includes timer functions and boolean aliases for controlling the traffic lights based on the current state.

Uploaded by

edlistianto
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

342

SBR();
IF S:FS THEN
state := 0;
green_EW.TimerEnable := 1;
yellow_EW.TimerEnable := 0;
green_NS.TimerEnable := 0;
yellow_NS.TimerEnable := 0; Note: This example is for the AB
END_IF; ControlLogix platform, so it
does not show the normal
TONR(green_EW); TONR(yellow_EW); function and tag definitions.
TONR(green_NS); TONR(yellow_NS); These are done separately in
the tag editor.
CASE state OF
0: IF green_EW.DN THEN state : DINT
state :=1; green_EW : FBD_TIMER
green_EW.TimerEnable := 0; yellow_EW : FBD_TIMER
yellow_EW.TimerEnable := 1; green_NS : FBD_TIMER
END_IF yellow_NS : FBD_TIMER
1: IF yellow_EW.DN THEN light_EW_green : BOOL alias =
state :=2; rack:1:O.Data.0
yellow_EW.TimerEnable := 0; light_EW_yellow : BOOL alias =
green_NS.TimerEnable := 1; rack:1:O.Data.1
END_IF light_EW_red : BOOL alias =
2: IF green_NS.DN THEN rack:1:O.Data.2
state :=3; light_NS_green : BOOL alias =
green_NS.TimerEnable := 0; rack:1:O.Data.3
yellow_NS.TimerEnable := 1; light_NS_yellow : BOOL alias =
END_IF rack:1:O.Data.4
3: IF yellow_NS.DN THEN light_NS_red : BOOL alias =
state :=0; rack:1:O.Data.5
yellow_NS.TimerEnable := 0;
green_EW.TimerEnable := 1;
END_IF

light_EW_green := (state = 0);


light_EW_yellow := (state = 1);
light_EW_red := (state = 2) OR (state = 3);
light_NS_green := (state = 2);
light_NS_yellow := (state = 3);
light_NS_red := (state = 0) OR (state = 1);

RET();

Figure 284 Traffic Light Subroutine

You might also like