I needed a way to switch several low-power isolated 12V loads with an Arduino.
There didn’t seem to be any shield with quite the requirements I had in mind:
- Eight isolated outputs
- Each output switched to one of two common lines (designed for 12V and GND)
- Fits standard Arduino shield size and layout
So I had to design my own. I didn’t want to take up eight outputs of the Arduino, so I elected to use a 74259 addressable latch to interface between the Arduino and the relay driver. The latch reduces the number of required Arduino outputs from eight to five. The 74259 takes a three-bit address selection (S0-S2), and data (D) and enable (G) inputs. The 8 individual outputs go through a ULN2803 darlington driver that switches the relays on/off.
To switch an individual output on/off, the Arduino simply needs to:
- Bring the enable (G) input HIGH
- Choose the output using the S0-S2 address lines
- Set or clear the data (D) input as required
- Re-assert the enable (G) input LOW
So it’s actually a pretty simple circuit. I was tight fitting everything onto the Arduino form factor, and I pretty much immediately jumped to getting a two-layer board fabbed through OSHPark rather than trying my usual approach of a quick single-layer hackspace-etched PCB first.
This was an expensive mistake, as I’d got a package size wrong. The ULN2803 doesn’t come in the narrow SOIC package I’d chosen. In order to save the three boards I’d got made from going in the bin, I used the seven-output ULN2003 instead. For the remaining output, I glued a SOT23 breakout board to the PCB with a MOSFET and tacked on a back-EMF diode and some wires.
They all work, and I’m pretty pleased with how the relays look together with the terminal blocks. Gives the board an excitingly functional look.
Eagle files (with ULN2083 package fixed) provided.