3

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 ?

Passerby
  • 72,580
  • 7
  • 90
  • 202
bdutta74
  • 3,524
  • 11
  • 46
  • 67
  • 2
    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 :) – xsari3x Feb 08 '12 at 13:29

3 Answers3

16

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.

stevenvh
  • 145,145
  • 21
  • 455
  • 667
  • 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](http://electronics.stackexchange.com/a/26348/857), 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. – Kevin Vermeer Feb 08 '12 at 19:57
  • 3
    "The device contains a built-in voltage clamp on the outputs for inductive transient protection." – markrages Feb 08 '12 at 22:02
  • Thanks @stevenvh. This device seems ideal, and also the current cost seems to be nice. Just what I needed. +1 and accepted. – bdutta74 Feb 09 '12 at 04:58
7

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.

mjh2007
  • 3,899
  • 24
  • 49
2

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.

Martin
  • 8,320
  • 1
  • 22
  • 30