Electronic gate controller
Electronic controller for an electrically operated gate.

This project is a microcontroller-based controller for an electrically operated gate. It provides manual and automatic modes, input monitoring, optical safety beam handling, relay outputs for the drive and signalling, and fault indication. The original construction was published in Praktická elektronika 4/2011.

Technical Parameters

Power supply230 V AC.
Remote receiver supply12 V DC, unregulated.
FuseF0.1 A glass fuse.
InputsOptically isolated.
OutputsRelay outputs.
ControllerPIC16F630 or PIC16F676.
PCBSingle-sided 100 x 75 mm PCB with one wire jumper.

Inputs and Outputs

SignalPortTypeDescriptionActive state
S1RA0InputGate closed sensor.LOG 0
S2RA1InputGate open sensor.LOG 0
S3RA2InputMotor rotation / gate movement sensor.LOG 0
OPTZRA4InputOptical safety beam.LOG 0
TLACRA5InputControl button and remote-control input.LOG 0
VIPRA3InputManual / automatic mode switch.Automatic in LOG 0
RE1RC0OutputGate closing relay.LOG 1
RE2RC1OutputGate opening relay.LOG 1
RE3RC2OutputGate-in-motion signalling relay.LOG 1

Operation

In automatic mode the controller checks the current gate position. If the gate is open or in an undefined position and the optical safety beam is clear, it automatically closes after about 30 seconds. If the beam is interrupted, the controller waits for it to clear; a longer interruption is reported as a minor fault and must be acknowledged. During movement, the controller monitors the motor movement sensor, the safety beam and the relevant end-position sensor.

In manual mode the controller ignores the optical beam and automatic timers. The gate is controlled only by the button or remote control. If the position is undefined, the first command opens the gate for safety reasons. Movement reversal is allowed only after reaching an end position.

Fault Indication

Red LED onMinor fault, such as interrupted optical beam or missing pulses from the movement sensor S3.
Red LED flashingSerious fault, such as S1 and S2 active at the same time or the control button held during power-up.

Hardware

The controller is built on a single-sided PCB and is powered directly from 230 V AC. The logic supply for the PIC16F630/PIC16F676 is derived through a transformer, bridge rectifier and 78L05 regulator. Relay outputs RE1 and RE2 drive the open/close directions and should be used to drive suitable contactors for the actual motor. RE3 is intended for a beacon or other optical signalling.

Schematic

Gate controller schematic
Gate controller schematic.

PCB and Assembly

Gate controller PCB
PCB layout.
Gate controller component placement
Component placement.

The PCB is a 100 x 75 mm single-sided board. With careful assembly the device should work on the first power-up and does not require adjustment. Do not forget the wire jumper.

Processor Configuration

ItemSetting
OscillatorInternal oscillator.
WatchdogOFF.
MCLREOFF.
Code protectionAs required.

Documentation

The documentation package contains construction files, Eagle project files and firmware for the processor. An additional ZIP archive contains the VIP modification that allows closing the gate in automatic mode using the button.

Disclaimer

This is an author project intended for personal use. The author does not accept responsibility for device behaviour or any damage caused by its use. The microcontroller program is copyrighted and may be used free of charge for personal use only.