Parking Gate Controller
Parking gate controllers combine vehicle detection (inductive loops or photoeyes), gate actuator timing, and critical safety logic — the gate must NEVER close on a vehicle. This example shows the standard pattern with photoeye safety.
I/O list
| Tag | Type | Description |
|---|---|---|
| Loop_Approach | DI | Inductive loop in approach lane |
| Loop_Exit | DI | Inductive loop in exit lane (under gate) |
| Photoeye_Safety | DI | Light beam across gate (TRUE = clear) |
| ValidPass | DI | Valid RFID/ticket from reader |
| Gate_Open | DO | Open gate motor command |
| Gate_Close | DO | Close gate motor command |
| GateOpenLimit | DI | Gate fully open limit switch |
| GateClosedLimit | DI | Gate fully closed limit switch |
Structured Text code
PROGRAM main
VAR
State : INT := 0;
HoldTimer : TON;
END_VAR
Gate_Open := FALSE;
Gate_Close := FALSE;
CASE State OF
0: (* CLOSED IDLE *)
IF Loop_Approach AND ValidPass THEN State := 10; END_IF;
10: (* OPENING *)
Gate_Open := TRUE;
IF GateOpenLimit THEN State := 20; END_IF;
20: (* OPEN — wait for vehicle to clear *)
HoldTimer(IN := NOT Loop_Exit AND Photoeye_Safety, PT := T#3s);
IF HoldTimer.Q THEN
HoldTimer(IN := FALSE);
State := 30;
END_IF;
30: (* CLOSING — but only if photoeye clear and no vehicle in loop *)
IF Photoeye_Safety AND NOT Loop_Exit THEN
Gate_Close := TRUE;
IF GateClosedLimit THEN State := 0; END_IF;
ELSE
(* Photoeye blocked or vehicle in loop — open gate again *)
State := 10;
END_IF;
END_CASE;How it works
Approach loop + valid pass: gate opens only when both a vehicle is approaching AND a valid RFID/ticket has been presented.
Hold-open time: gate stays open for 3 seconds AFTER the vehicle clears the exit loop. Prevents the gate from closing too quickly behind a slow vehicle.
Photoeye safety override: in step 30 (closing), if the photoeye is broken or a vehicle is detected in the exit loop, the gate immediately reverses to step 10 (opening). This is the anti-pinch safety.
Production system: would add tailgating detection (loop + photoeye combination), backup safety contact strip on the gate arm, and emergency-open input from facility security.