Relay driver - Page 1
Forum section: electronics / projects

author: Greg Robinson
author_rank: Regular Contributor
timestamp: November 18, 2013, 09:13:08 am
content: Hi everyone.I'm working on a project that will incorporate a 7 or 8 bit relay array to make a discrete "digital pot".(7 DPDT relays would make a 7 bit pot)I know there are commercial digital pots available, but the max voltages (highest rated I've seen was around 50V) rule them out for my application.Where I need help is in figuring out how to drive this array in a sensible manner. I could of course use 7 or 8 digital outs from a microcontoller, but if I want to have 2, 3 or more of these arrays, I will quickly run out of pins.Ideally, I would use some sort of "analog to binary" chip, something that would accept an analog signal from the main micro, and have 7 or 8 digital outs for driving an array. If there is such a device, I don't know what it's called, and haven't been able to find it.I guess otherwise I would need to use a small micro for each array, but that would be non-ideal, requiring multiple micros to be programmed.Anyway, if anyone has any suggestions, I would greatly appreciate your help!

author: Greg Robinson
author_rank: Regular Contributor
timestamp: November 18, 2013, 09:55:31 am
content: So I'm starting to think that the easiest way to go would be a small micro for each array, and I2C from the main micro.Anyone got any better ideas?

author: Dago
author_rank: Frequent Contributor
timestamp: November 18, 2013, 10:21:51 am
content: I'd use an I2C port expander such as MCP23017http://ww1.microchip.com/downloads/en/devicedoc/21952b.pdf

author: fcb
author_rank: Super Contributor
timestamp: November 18, 2013, 10:27:27 am
content: Quote from: Greg Robinson on November 18, 2013, 09:13:08 ama.k.a. analog to digital converter - something like an ADC0804 driving a ULN2803A.All though you might want some hysteresis in the design.Personally I'd use a small PIC (18F1220 being in my parts bin) driving the relays with a 4094B and ULN2803A combination.

author: KJDS
author_rank: Super Contributor
timestamp: November 18, 2013, 10:33:41 am
content: Demultiplex the outputs, you only need three processor pins to drive eight relays, only four to drive sixteen. With eight processor pins you can drive 256.

author: Kremmen
author_rank: Super Contributor
timestamp: November 18, 2013, 01:52:10 pm
content: Naah, just use the trusty 74HC595 serial/parallel latch and drive it with your favorite small MCU from the SPI output. The 595 could even drive small relays but maybe you will want to put an ULN2803 or similar between. If you need more relays just chain more 595s until you have enough bits. Simple and efficient.

author: Rufus
author_rank: Super Contributor
timestamp: November 18, 2013, 03:07:05 pm
content: Quote from: Kremmen on November 18, 2013, 01:52:10 pmFor something slow like driving relays a chain of shift registers will drive as many as you like with 3 processor pins.TI do the TPIC6C596 (NPIC6C596 from from NXP) which is an 8 bit register with 33v 100mA open drain outputs. I am surprised such parts are not more popular and easy to source.

author: Jon Chandler
author_rank: Frequent Contributor
timestamp: November 18, 2013, 03:25:06 pm
content: An I2C port expander like the MCP23017 gets my vote. 16 output pins that can supply 25 mA each (but watch for max current limitations of the device). Eight of these can be used on a pair of port pins and port pins can be controlled individually without shifting out a string of data for all the bits.Use a ULN2003 or ULN2803 if more current drive is needed.

author: Kremmen
author_rank: Super Contributor
timestamp: November 18, 2013, 06:14:05 pm
content: Don't wish to argue but let me ask why I2C? It is far more complex than SPI and doesn't bring anything extra to this application. The relays won't have much to say so you don't need any kind of configurability. SPI is dead easy to do in most MCUs and the probability of problems is minimal.

author: kxenos
author_rank: Frequent Contributor
timestamp: November 18, 2013, 07:27:12 pm
content: Quote from: Kremmen on November 18, 2013, 06:14:05 pmYou're right but I think I2C will be more appropriate for this application because a) there is no high speed output that would justify SPI and b) there are many I2C port expanders. Although I would agree that in this application shift registers would be adequate.

author: Rudolfo
author_rank: Contributor
timestamp: November 18, 2013, 10:45:42 pm
content: An industrial 16 bit I/O port on SPI can be done with the iC-JX to drive relays up to 36V (http://www.ichaus.biz/wp1_mcu_interface). A complete board is described here:http://www.raspberrypi.org/phpBB3/viewtopic.php?t=9556&sid=a98d84943f7db20dd53348135d463765.

author: Rufus
author_rank: Super Contributor
timestamp: November 19, 2013, 12:05:30 am
content: Quote from: Rudolfo on November 18, 2013, 10:45:42 pmNice chip, and I thought the NPIC6C596 was hard to source - lol.

author: Greg Robinson
author_rank: Regular Contributor
timestamp: November 19, 2013, 12:53:28 am
content: Thanks for the suggestions everyone.If you hadn't guessed I'm no good with digital, I'm an analog guy.You've all given me enough information to get started, I'll probably be back once I get more details sorted for some feedback.Thanks again!

author: nctnico
author_rank: Super Contributor
timestamp: November 19, 2013, 02:19:24 pm
content: Quote from: Rufus on November 18, 2013, 03:07:05 pmI second the TPIC6x595 choice. ST also makes them.

author: strangelovemd12
author_rank: Regular Contributor
timestamp: November 19, 2013, 03:33:59 pm
content: Your application sounds similar to a project I'm currently working on and I came to the same solution as some of the above posts. I am using an 8 bit latch to hold an "operation code" where the first 4 bits act as a crude digi pot by switching around some resistors. This is probably the method I'll end up going with, but I'm still working on the best means of supporting multiple satellites boards.Is there any way to solidify your expansion estimates? 2-3+ is fairly vague and in the range where +/-1 may force significant design changes.

author: Greg Robinson
author_rank: Regular Contributor
timestamp: November 21, 2013, 07:22:56 am
content: Quote from: strangelovemd12 on November 19, 2013, 03:33:59 pmCool, interesting to hear of someone else doing a similar thing.In terms of expansion, I'm hoping that my eventual solution will be highly so, effectively "limitless" within practical considerations, each module being a self-contained expansion.Obviously, that's not very real-world, and in reality I will probably be looking at around 20 modules.

author: macboy
author_rank: Super Contributor
timestamp: November 21, 2013, 03:45:02 pm
content: Try something like UCN-5841A. It is literally designed for what you need to do.This is a serial input relay driver circuit: serial input, parallel output shift register with high current outputs and built in protection diodes. It has a serial data output that can be used to daisy-chain multiple chips. So if you need 32 relays, connect 4 such chips together, and shift 32 bits through them, then hit the strobe line to load the data and you're done. Just 3 I/O (data, clock, and strobe) on your micro for as many outputs as you need.

author: calexanian
author_rank: Super Contributor
timestamp: November 21, 2013, 08:50:36 pm
content: 5841A's are now discontinuedwe use 74HCT574's to grab the output data and latch it right off the buss in out products, then feed 2803's with that. Works pretty well and is robust and cheap.

author: Greg Robinson
author_rank: Regular Contributor
timestamp: December 27, 2013, 02:58:43 am
content: Thanks for the help so far everyone. With the suggestions I've received, I've decided to use shift registers to control the digital pots.Now my next challenge is to figure out how to interface the rotary encoders that will set the value of the pots. I've decided on 12 rotary encoders, and would also like to use two digit 7 segment displays to show the set value for each pot (I'm going to have values of 0-99 available, skipping a couple of bits for 7 bit linear, and an approximate logarithmic lookup table from 8 bit values).Any suggestions how best to achieve this? Remember, I'm hoping to stick to the Arduino environment. My unfamiliarity with digital hardware is really holding me back.Thanks again!