A Gate Controller to keep out the ravening hordes (of daytrippers and holiday makers)
So, here’s the problem. Having a big entrance, a long drive and formal gardens acts like a magnet to Sunday trippers. I mean, it’s not as if we don’t have a PRIVATE KEEP OUT sign. In fact I put up a BEWARE OF THE WIFE sign on the drive at one point but, oddly, it disappeared. I really wanted a BEWARE OF THE WEREWOLF sign, but Rickarbys in Alnwick were all sold out (strangely, that’s where I got the WIFE sign, though, which says it all)
So, on a nice, sunny weekend, we’d get anything upwards of 2 or 3 groups of people would bring their cars up the drive and disgorge a bunch of people who’d then proceed to have a picnic on our front lawn and maybe play a little football. On the odd occasion, we’d get folk wandering into the house like it was some National Trust property! Cheeky little beggars.
The solution? Electric gates, of course. The existing gates were removed and taken away to be chemically stripped and shot blasted then galvanised and, finally, powder coated…at Omega Towers, we don’t do things by half measures. I mean, these buggers will outlast us.
Then, two motor pits were excavated below the hinges and a pair of highly geared motors were installed. There’s no mains power supply anywhere near the gates, so the obvious solution was to install some large batteries (2 x 100AH, 12V) charged by a set of 40W solar panels. By and large, this worked fine. However, in winter we found that there was often insufficient sun to properly charge the batteries, so this year I eventually resorted to a 24V, 250W panel. We’ll see what happens later in the year.
All of this seemed to work well and we had a radio key-fob to trigger the gate opening cycle. The motors and associated sensors were very reliable, however, the electronics were another thing. Relays kept on burning out, the gates would jam on leaf mold and would have to be manually reset, etc, etc. The whole thing became a real pain and not the convenience that we’d hoped for.
Enter Gate Controller 2.0
I eventually caved and designed my own circuit. So, what does an electric gate controller need? Well, mainly it needs to know when the gates are open or closed and this is achieved by a pair of Hall sensors on the motor housing. It needs to know if there’s anything blocking the path of the gates and this is done by an infra red beam sensor. It also needs to know if the gates are jamming on something. This was the problem with the old design, it simply tripped out the power if the gates jammed. So, the obvious solution was to fit a current detector to each of the gates motor power supplies and do something a bit more clever.
I ordered a pair of 30A, ACS712-based current sensors from China at a couple of pounds each. These give out a voltage from 0-5V depending upon the current detected. 0V = -30A and 5V=+30A. A voltage of 2.5V means zero current. This means that you can also confirm which direction the gates are going if need be. My software calibrates these every time the gate cycle is triggered.
In the picture, you can see the new controller installed (grey plastic box). Behind it is all of the old gubbins and wiring associated with the original controller. I spent a miserable afternoon in the rain tracing out the signals to indicate gate open/closed, barrier detect, motor supplies and the charging cables from the solar panels. You can also see the two 100AH, 12V batteries that are hooked up as a single 24V source to run the motors.
As this picture shows, I used a 4 line, 20 character display to indicate the status of all of the signals coming into the unit so that I could check what they did when the gates moved. On the bench, I simulated all of this using a few switches and some LEDs so that I could write the software. The program is a fairly straightforward state machine that sequences through the necessary steps to cycle the gates. There’s an interrupt routine that reads all of the sensor 100 times per seconds and takes care of the emergency STOP over-ride if the infra-red barrier beam is broken, mainly to stop folk being crushed if they are dumb enough to stand in front of the gates when they’re closing.
The main processor is an ATMEL AVR ATMEAG1284 chip which has plenty of port pins, 128K of code space, 16K of RAM and 8K of FLASH memory – total over-kill for the use but, hey, at £3 who cares.
At the end of the day, rather than mess around, I put in the ability to change the sense of each of the signals so that it could be setup to respond to, eg, gate open = signal HIGH or LOW. I can also program the stall current for each gate so that the controller knows if there’s a a jam. If there’s a problem, it waggles the gates back and forth a few times to see if it can clear the problem and it not, it returns to the previous condition such as opened or closed. I’ve actually ended up with a generic electric gate controller for the next time I install one.
There’s also an indication to show if the RF signal from the gate opening transmitters located in each of the cars is being received.
I wanted to achieve a sort of luxury feel to the gates so that we could sweep up to them in either direction and they’d open automatically. There’s an existing keypad on both sides of the gates so that delivery drivers can get in and out if they have the access code.
In the transmitter, I used an ATMEL AVR chip, the old favourite the ATMEGA328 used in the standard Arduino Uno boards. This is hooked to a high powered RF module based on the Nordic NRF24L01+ 2.4GHz device. This is a wonderful little unit that, technically, has a range of up to 1000m. In my case, I only needed maybe 50m from inside a steel box to under the bonnet of a car. At non-racing speeds coming down the drive, the gate control receiver picks up the encrypted OPEN command and triggers off the sequence. One more little item I added to the configuration settings was the ability to open the gates in a staggered fashion. This is handy to stop the gates jamming when they close. In my case, I’ve set it to open the left hand gate 5 seconds before the right hand one and the reverse when they are closing…which works pretty well!
The transmitters take about 100mA for a fraction of a second and then go to sleep taking just a few micro amps. So, I’m confident enough to connect them directly to the car battery and leave them running the whole time. The gate controller keeps the gates open so long as it receives an incoming signal, so there’s no chance of the gates closing too early.
All-in-all, a successful little project and a happy Mrs Omega Man who got the first of the transmitters installed in her new Range Rover!