3
\$\begingroup\$

While I understand that moving up to a high pin-count uC might be the simplest option, I am looking for Low-cost options to do the same with low pin-count uC.

Would like to control a maximum of 8 relays, using an ATtiny85, which has 5 available GPIO pins, of which I definitely need to set aside 2 for some other purpose, leaving me 3. One obvious approach that comes to my mind is a Mux. Given 3 pins, 2^3 = 8, fits nicely. However I was wondering if the relays (which control the power-supply socket for servers), would de-energise, while changing mux values ?

Are there other gotchas with this approach ? Are there any alternative methods available ? I've heard about IO expanders, but would it be a worthwhile approach from complexity / cost standpoint ?

\$\endgroup\$
1
  • 2
    \$\begingroup\$ In order not to make relays to de energise , use a latch at the ouput of the mux , the latch will keep the logic(1) while switching between MUX pins :) \$\endgroup\$
    – xsari3x
    Commented Feb 8, 2012 at 13:29

3 Answers 3

16
\$\begingroup\$

The TPIC6C595 is a power version of the 74HC595 shift register, serial in parallel out, with 8 output channels, each capable of driving 100mA. You only need three pins: serial data, serial clock and latch, and if needed you can cascade multiple devices for more than 8 outputs.

It contains clamping diodes to protect against the relays' inductive voltage.

\$\endgroup\$
3
  • \$\begingroup\$ As an added bonus, this device is far more likely than the others to be capable of driving the relays directly without an external transistor. As noted by mjh2007, most other solutions will need another transistor. This will, of course, still need a diode to protect against damage from the inductance of the relay coil. \$\endgroup\$ Commented Feb 8, 2012 at 19:57
  • 3
    \$\begingroup\$ "The device contains a built-in voltage clamp on the outputs for inductive transient protection." \$\endgroup\$
    – markrages
    Commented Feb 8, 2012 at 22:02
  • \$\begingroup\$ Thanks @stevenvh. This device seems ideal, and also the current cost seems to be nice. Just what I needed. +1 and accepted. \$\endgroup\$
    – bdutta74
    Commented Feb 9, 2012 at 4:58
7
\$\begingroup\$

There are many I/O Expanders out there that use either SPI or I2C buses. With a single MSSP module you can control almost an infinite amount of digital outputs like LEDs or Relays.

See the Microchip datasheets or application notes for the following parts:
SPI - MCP23S08
I2C - MCP23008

NOTE: These parts by themselves will not sink/source enough current to activate a relay, however adding a transistor at the output pin will allow you to drive a relay.

\$\endgroup\$
2
\$\begingroup\$

A mux won't work, because you need to latch/disable the output using another one of your pins, and have an input state for on/off of the relay you are muxed through to, using another pin. An SPI IO expander would seem better, but then you need an SPI library on your chip.

\$\endgroup\$
1
  • \$\begingroup\$ Yes, indeed a mux alone won't work, my bad. \$\endgroup\$
    – bdutta74
    Commented Feb 9, 2012 at 12:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.