Although the gate itself is pretty much done, the project itself isn't quite finished yet. I'm planning on using some of the left-over wood to make a safety fence to prevent the little'un wandering down the back of the shed in the path of the gate... but right now, I've been busy making a few improvements to the remote control systems. I asked on the off-topic forum, and at least five people said they'd like to read about electronics, and since the moderators didn't complain, here goes.
Because of safety regulations and suchlike, the gate travels at a very leisurely pace and takes around 45 seconds to fully open or close. The remote controls that came with the gate have a pitifully limited range of about 100 feet, and that's nowhere near long enough for the gate to open before I get to it on the road. Motorists round here are very impatient, and if forced to sit and wait behind me for 30 seconds whilst the gate opens, they're likely to crash into each other trying to get past (They're forever trying to overtake my wife as she turns right into the driveway... 6 near-misses in 12 months) - I looked into longer range transmitters and radio antennas, but things started to look expensive, and you still had no idea if your button-push was successful and the gate was opening... then I had a better idea.
The gate motor kit came with a keyswitch - Turning the key in one direction is the same as pressing button-1 on the remote... in the opposite direction, it's button 2. Inside the box is just two microswitches, so a couple of relays seems an easy way to send button-pushes to the gate.
For a while now, I've had development/experiment PCB called a 'NetIOM XAP' - It's a neat little board centered around a PIC Microcontroller, and it provides a 10Mbit network interface, a bunch of inputs and outputs and a serial port. When connected to the network, the board uses DHCP to optain an IP address, and sends and receives commands using a simple UDP based protocol called XAP. Conveniently, I have a relay extension board which plugs on to the main board.. and some LEDs.
My company (which conveniently has an office at my house) uses an open-source phone system called Asterisk. It's a fully-featured PABX system with voicemail, hold music, call diverting, conference calls and much more, and has the advantage that if you're up to the task of installing and running it, it's free. Our office asterisk server sends/receives all calls via broadband to an Asterisk server which our central-london rackspace supplier provides for us. The setup means that we have a bunch of 0845 numbers to play and very little in call charges. The Asterisk system has a plethora of different ways that you can extend the functionality, but one of the easiest ones is called Asterisk Gateway Interface (AGI) which allows you to run scripts and commands when calls come in or go out.
It occured to me that I could do the following...
1. Assign the gate an 0845 number all of it's own.
2. Assign the gate's 0845 number to a speedial on my mobile (and wife's etc)
3. When a call comes in for the gate, pass the callerID of the incoming call to an AGI script - if the callerid is good, then the script sends out the XAP commands to turn on and off the relays, which in-turn act as the button pushes that open and close the gate.
Here's the bits of my asterisk extension.conf file which deal with the gate's 0845 number. The AGI script is called flash2.py and is just enough python code to get the NetIOM board to flash some lights. The script is run before the call is actually answered, and the call is hungup immediately, so it lasts for 0 seconds and costs 0 on my phonebills
[gate]
exten => s,1,AGI(/root/flash2.py)
exten => s,2,Answer
exten => s,3,Hangup
Time for some electronics...
The NetIOM board and relays need a 12V supply. My burglar alarm in the shed uses a 12V supply too, but rather annoyingly, uses non-rechargable batteries as it's backup. Since I needed to create a supply for the NetIOM board, I decided put a battery backup in too and use it to power both the alarm and NetIOM systems. I ordered a slimline 2.1AH Lead Acid battery for the job because they're dead easy to float-charge at 13.8V with a simple constant voltage charger.
I spent a while digging around through drawers and boxes, finding old power supplies from all manner of things, and even found a 13.8V supply, but most of them were a bit on the chunky side, and I eventually want to put all this in a nice neat box. One of the neatest supplies I found was a little 12V 1A plug-in switchmode which came with a CCTV camera.
Time for a for a 'Don't Try This at Home' - I've got the right equipment and experience to do this (relatively) safely. Do not even think about attempting this direct to the mains, even with fuses in the way. When I'm messing with these things, I'm using current limited bench supply and a small inverter to generate my own AC supply voltage. My setup means the maximum energy I can supply is a measly 3Watts, and the biggest shock I can get from the board is a measly 0.16Joules of energy.. I'd feel the shock, but I can't cook myself.
Switchmode power supplies all work in pretty much the same way - They all have a high-voltage side which does it's work at mains voltages, and a low-voltage side. They all take mains-AC and rectify it to around 400VDC which they store on a capacitor... then use high-frequency switching to turn on/off the current to a high-frequency transformer which in turn steps down to a suitable voltage, which is smoothed with extra capacitors and inductors to get rid of the switching frequency ripple. The low voltage side always has a feedback circuit which controls the light-emmitting-side of an Opto-Coupler.. and the Light-receiving side of the Optocoupler controls the switching signal on the high voltage side. (sorry if I lost you all there)
This is one of the neatest ones I've seen thanks to the rather amazing Viper22a chip buried in the middle. I took a look at the datasheet for it... 8-pin chip switching at 60kHz which does 9-25V at up to 40W, with no heatsink or extra drive transistors.
In the top left corner, you can see my very simple modification with an extra resistor, which increases the output voltage from 12V to 14.2V.. I will of course trim the legs and solder neatly before I'm done.
And finally, here it all is together...
There's a very simple battery charging/isolating circuit buried within the wiring. A 15ohm resistor acts as a very simple current limit device, and a diode prevents the battery discharging back through the the switchmode and lowers the switchmode voltage to about 13.5.. ideal for trickle charging. Two more diodes seprate the battery supply from the Switchmode and feed them to the same power cable.. which you can see here powering the NetIOM.
I've got a metal-lined plastic enclosure that's going to hold all this lot but I need to modify it to provide mounting points for the various boards. SWMBO and nipper are off galavanting this weekend, so I stand a good chance of getting this finished.
For extra points, I may also hook into the magnets and reed switches on the gate so I can work out if it's open, closed or somewhere in-between - Then I could use the information to decide what to do on the phonecall... If it's closed, open and hang-up... If it's open, answer the call and ask if you want it closing.