Example 7, Traffic Lights - CAI Networks WebControl PLC User Manual

Programmable logic controller
Table of Contents

Advertisement

AND OP1 RAM1
BZ l2
SET OP2 1
EMAIL EM1
l3:
TSTEQ OP2[1000] 1
BZ l3
SET OP4 1
SET OP1 0
END
Please note in this example, we assume the TTL input, analog input and temperature
reading are all perfect, no bouncing up and down. In reality, you have to add
consideration to it.

6.4.7 Example 7, Traffic Lights

This example will let pedestrian to push a button to change the light on a busy street,
so that he can cross the street safely. IP1 hooks up to the pedestrian crossing button.
If someone pushed cross button, the street will have amber light on for 10 seconds,
then red light to stop all the cars, allowing pedestrian to cross street in next 30
seconds. At the end of 30 seconds, it will flash the amber and red light for 5 seconds.
VAR1 in the main program will let the crossing light turn on every 100 seconds, does
not matter anybody push the crossing button or not.
OP1 Red + Pedestrian crossing light
OP2 Amber
OP3 Green
IP1 Pedestrian Push Button
START
CALLSUB LIGHTS_GO
loop:
SET VAR1[10000] 1
loop1:
TSTEQ IP1 1
BNZ sr
BZ VAR1 sr
GOTO loop1
sr:
CALLSUB STOP
GOTO loop
END
LIGHTS_ST:
Copyright(c) 2008,-2013 CAI Networks, Inc.
TM
WebControl
PLC User Guide Version 3.02.17f
35

Advertisement

Table of Contents
loading

Table of Contents