---------------Getting along in the 21st Century with half the baggage you carried in the last.------------ /*************************Low cost electronic solutions for a low impact lifestyle.************************/

Friday, November 12, 2010

Bodgineering!

Here's a really useful relay board fitted with four 10A mains relays. I bought cheaply a few years ago thinking that it might be useful. The only problem was that it used a PIC16F886 and a weird serial protocol to control the relays and the rest of the I/O.

How about transforming it into a Arduino Relay Slave - just what the Navitrino central heating controller needs?

A quick check of the PIC16F886 data sheet confirmed that the reset, power and clock oscillator pins of the PIC were nearly all in the same position as on the ATmega328 - as used in the Arduino. Those that weren't, could readily be bodged.

The only changes needed were that pin 19 on this board is grounded - no problem if I make D13 an input, and pin 22 - an output to an unused darlington driver, would have to be made OV to keep the ATmega happy.

The board has a 12V dc input, a 5V regulator and a MAX232 serial chip. In addition to the four relays, there are four further outputs driven by the same ULN2803 octal darlington driver IC, plus four opto-isolated inputs. All inputs and outputs have LED indicators fitted to show their status.

The first job was to trace all the connections and work out what I/O was connected to the relevant pins on the Arduino

Once I was sure that the wiring was OK, I replaced the resonator with a 16MHz crystal and fitted one wire link to correctly feed 5V to pin 7. I then made up a 4 wire cable with a header that would fit my FTDI programming cable. With this all done, I powered up the board without the ATmega fitted and confirmed that my power and ground arrangements were good.

I wrote a short test sketch to set up the I/O with the correct pin functions and to produce a slow sequence of turning the reays on and off. I programmed this into an ATmega on another known working board and then swapped the IC into my relay board - remarkably it all works fine! I have subsequently reprogrammed the ATmega in-situ with the FTDI cable and all is well.

That's the underlying beauty of Arduino, you take a bootloaded ATmega328, add a crystal and connect power and ground and very quickly you have a common I/O platform for rapid prototyping of your latest hardware project.

For a couple of hours work - I now have a working relay slave board, onto which I can develop some code. The board will be used to drive the central heating, hot water and pump functions which require mains relays to operate. A simple seria slave link as developed for my "serial command interpreter" back in August will allow this board to be driven from the main Navitrino master - or possibly remotely via the internet using the Etherduino.

About Me

I am an electronics engineer working with embedded microcontrollers within instrumentation, telecoms and low power wireless.
Applications include energy saving, renewable energy, automation for CHP and open hardware
I'm interested in renewable energy, suburban repurposing/transition and gasification for domestic heat and power.
You can find me @monsonite on Twitter