Introduction: 8 Channel Relay Control Board With Serial Communication

This is a project that I made some time ago during undergrad school. It is a bit old, but still worth to share.

The project is about a PCB with 8 relays that are controlled by a microcontroller, which receives commands from a PC through Serial Port interface.

Originally, the project was going to be driven by the NI DAQ 6008 outputs only (no microcontroller).

But then I decided to make another version of the project, also able to be driven by the PC.

So I selected the PIC16F84A as the link between the PC and the relays. And of course, the Serial Port (DB-9) as the medium for transferring the commands.

The maximum current able to circulate through each of the relays is of 5A @ 250V.

Any GUI can be used to communicate with the device. The idea is that the microcontoller receives an single incoming byte, and turns on the relays depending on their respective bits: if n-bit is logic 1, that relay will activate. It is simple since the communications is for one-way only.

Step 1: List of Components

14 x 2-pin Terminal block

8 x 5.1KΩ , 1/4W resistor

8 x 470Ω, 1/4W resistor

4 x 10KΩ, 1/4W resistor

10 x 1N4148 diode

8 x 47Ω, 1/4W resistor

1 x 3.3KΩ, 1/4W resistor

1 x 400Ω, 1/4W resistor

8 x G6D-A1-ASI 5VDC relay

8 x BC547B, BJT transistor

8 x Green LED, 3mm

1 x PIC16F84A microcontroller

1 x 4MHz crystal

2 x 33pF ceramic capacitors

1 x 0.1uF electrolytic capacitor

1 x 66uF electrolytic capacitor

1 x LM7805 voltage regulator

1 x 1N4004 diode

1 x 2N2222 transistor

1 x Serial Port connector, male

1 x DC power jack

1 x Pushbutton

1 x 9VDC transformer or power source /w jack

Step 2: The Schematic and Layout

I used Eagle from CADSoft to create the schematic and layout. It is small, simple, and easy to use.

One important thing to mention is the RS-232-to-TTL circuit. Since it is for receiving only, it is composed by a couple of resistors, a transistor and a diode. You can follow this link:

or this one:

Step 3: Layout Transfer to Copper Clad

As for how to move the layout into the copper clad, I selected the toner transfer method. See the link here:

Basically the method consists on printing the "mirror image" of the layout in a glossy-satin paper or acetate sheet using a laser-toner printer, and then place the image facing the copper clad.

Fix the glossy sheet with tape into the copper clad. Apply an extra piece of paper if the layout is printed in acetate sheet.

Now, take an iron (for cloth), and set it to the highest like for ironing cotton. Press down firmly and uniformly, but not hard, onto the paper. Slowly iron all the area of the layout. The idea is to heat and "melt" the ink so it can stick onto the copper clad. The overall effect is that the whole printed paper will stick to the clad, glued by the ink. Iron it for several minutes.

Finally, let the clad to cool down. Use a container with water and place the clad inside, let it soak until the paper starts to peel off. You can peel the leftovers with the fingers.

Eventually you will see that the layout is in the copper clad.

There is a chance that it may not transfer 100%, and some fixes have to be done with a fine-tip permanent marker.

Step 4: Etching

For the etching, you can make your own etchant with Hydrogen Peroxide, and Hydrochloridic Acid;

or Hydrogen Peroxide, White Vinegar, and Salt.

Follow the rules: use protective gear, mask, gloves, in a ventilated facility, and have bucket of water close to you if something goes wrong, etc.

Step 5: Solder the Pieces Together

Not much to say here. Again, use protective gear like a head mask, in a clean area, well ventilated. Careful with the fumes expelled from the burning solder alloy.

You can see in the pictures the final product.

About the DB-9 interface, the only pins that are needed are the TX and Ground from the PC. They are going to be wired like this:

DB-9 at PC: TX --------> RX :DB-9 at PCB

GND ------- GND

Step 6: Files and Firmware

A couple of comments on the firmware.

It was designed to operate with a Baud rate of 4800 bps, 8N1. See the link here:

Since the crystal runs at 4MHz, the Fosc = 4MHz/4 = 1 MHz. This means that each instruction cycle takes 1us. So the delays present in the firmware are calibrated for that clock speed, and the device receives data at "4800 8N1" bps.

Step 7: Comments

The device was built in such a way that one dedicated terminal block will receive the AC source, taking only the live and neutral lines only but no ground line. Until the very end I thought it should have been better to leave a ground plane for the AC, but it was too late.

The rest of the terminal blocks will be used for connecting individual AC devices, one per terminal block. Also, the power is readily available at every terminal block, so there is no need for "wire jumping" or you will create a short right away.