A couple of Relay problems

Hi, I’m working on an arduino christmas light project. I’ve found a couple good references online, but none that use as many inputs as I am. I have 16 channels, and since I am using the wave shield I didn’t have enough outputs to control each one with a single output (Arduino Uno). To minimize the number of pins necessary, I set up the outputs as four rows and 4 columns. To turn on any specific light, the row must be high and the column must be low. I use a timer interrupt to swap through the rows quickly, imperceptible to the human eye. Well it worked perfectly with a LED instead of the relay circuit. But now I soldered the relay circuit and I’ve got a couple of problems. See the attached drawing for an illustration of the circuit. This shows only one of four columns.

  1. If I plug in a string of lights, it is always on, just really dim. I have all LED christmas lights. Incandescent ones are not visibly on if I plug them in, but the LEDs are on. It seems that even when the Relay is switched off, it’s not a completely open circuit. I measured the resistance, it seems like closed is about 10Mohms. Anyone know why the LEDS are still visibly on? (They are definitely brighter when the relay is “on” btw)

  2. The “rows” connect to the base of the transistor and the “columns” connect to the emitter. When the row is high and the column is low, the relay should switch, but it doesn’t. It will only switch if I connect the emitter directly to ground and turn the row high. I don’t understand why because the pinMode is set to output and LOW, so it should be the same as ground, right?

  3. Two things I didn’t think about was the speed of the relay switching and that the AC circuit would not act the same as the dc circuit. Although switching through the 4 columns really fast worked fine with the dc circuit (one led per section of christmas lights), it doesn’t work with the relays. 16 relays switching at 1/1000 of a second sounds nightmarish and definitely doesn’t make the flashing imperceptible. Any ideas for how I can use as few pins as possible but still have the freedom to light each string of lights in any combination? Is there a way to make the 4x4 configuration work?

Do you have a spec for the relay?

Sorry about that. I meant to include those Relay - http://search.digikey.com/scripts/DkSearch/dksus.dll?lang=en&site=US&WT.z_homepage_link=hp_go_button&KeyWords=PB874-ND&x=0&y=0 1N4004 diodes 2N2222 Transistors 1K resistors

Here is the instructable I started with http://www.instructables.com/id/Arduino-Christmas-Light-Controller/

Coil Current 91mA

Current goes via emitter to arduino pin, which couldn't handle more than 40 mA. Probably, shift register chips would help to save a pins, and optocoupler with triac or SSR as a driver on high voltage side 'd be better solution

Magician:
Current goes via emitter to arduino pin, which couldn’t handle more than 40 mA.

Whoops. Thanks! It worked with my mockup using 5V and an LED at the output of the Relay, but I guess that was just a fluke. Last night I started rewiring it with some old NAND chips I had, what I figured was I’d have a NAND for each row and column and put them as the input to each base and the emitter to ground (as it should be). I’ll change the logic of the code so that a segment is “ON” when both the row and column are LOW. See the modified drawing attached. I just played with it for a second and it seemed to work. Anyone see any problems with this idea? I’m using 74LS02 chips.

EDIT: Sorry about the terrible drawings. I am at work and have no access to quality schematic drawing software, so paint and hand-drawing have to do.

Looks better, but still you should think about alternative for relay:

Operate Time 10ms Release Time 4ms

They wouldn't allow you to get 1/1000 seconds update rate, 1/100 at the best,

Magician:
They wouldn’t allow you to get 1/1000 seconds update rate, 1/100 at the best,

I am still working on that issue. I don’t want to start all over with SSRs, because I spent a lot of time soldering the 4x4 array of relays and other components. I had thought about using capacitors on the outputs of each NAND so that when it goes high it will smooth the 1/1000 sec switching… basically I want it to go high when the row and column go low, then when I move to the next column, any lights on in the previous column will stay high (due to the capacitor) until it gets back around to that row. My thoughts are that it would be impossible to turn high for 1/1000 of a second and then stay high for 3/1000 by simply using a capacitor, but maybe I could swap it up and use 8 rows and only two columns. This would require a total of 10 pins (or 9 if I just used the logic row2 = !row1) and only require the cap to smooth over 1/1000th of a second on/off time. Will this work or is there a better option than a simple RC circuit to help me smooth over that timing?

Better option is shift register (latching) chip. All your problem is concentrated around lack of output pins. There are two solution: - matrix; - serial to parallel external chip or "extender". Matrix approach, as you already noticed, not so convenient one when you need to communicate with something not so simple as led's or button's. edited: even with leds matrix not perfect, as issue high impulse current arising So, IMHO, would be better to get rid off matrix configuration, and build relay drivers based on extender. SN74HC595 or similar.

:D Thanks Magician! I've never used a shift register before but that looks like it will work perfectly and even make my code easier to write! I found what looks like a great tutorial here http://www.arduino.cc/en/Tutorial/ShiftOut

Anyone have any ideas how to solve the problem I numbered 1 earlier? How can I avoid the leakage from the relays?