Shift Register and Relays? Answered
Using a 74hc595 shift register to a ULN2003 darlington array to control 7 relays, all controlled by an MSP430, connected via RJ11. The relays are controlling LED Christmas light strings on and off. Everything seems to be functioning so far but the problem is that relays that aren't being told to turn on sometimes are turning on. The shift register is connceted with Qa to the master reset of the register so I can clear is quickly, but so far I have been just leaving it high.the other 7 outputs (Qb - Qh) connected to the base pins of the ULN2003 (B1 - B7). The outputs of the ULN2003 connected to the relay coils, COM connected to 5v, emitter connected to ground. I have tried pull down resistors on the base pins, I have tried tweaking the code which I tried to set up to just bit bang the shift register, make it as simple as possible just to test it and a sample is provided below for one iteration. I have it looping through several of these to turn a single channel on each time to check to make sure all the channels work. It however sometime make a channel just flicker, not turn on at all, or turns several channels on at the same time. I am curious as to whether this is a hardware problem (pullup/down resistors, filtering caps, more clamping diodes then what is built into the ULN2003, whatever) or whether I am just an incompetent programmer. I am fairly certain the problem lies somewhere between the driver seat and the steering wheel though. One thought I had but do not want to try right away is it possible the shift register is bad? Overheated from soldering? I try to solder one pin on chips, then a pin on another component, then a pin on the opposite side of the chip, etc to keep chips cool when soldering them, but are the 74hc595 very heat sensitive maybe? Would appreciate a fast answer, looking to build 5 more of these so I can control all my Christmas lights. This was supposed to be a cheap and dirty project so I didn't get into Triacs and dimming, I just want to turn lights on and off as I see fit. i = 30000; P1OUT = 0x00; //Channel 7 (unused) P1OUT |= 0x02; //Clock in P1OUT &=~ 0x02; //Clock low P1OUT = 0x01; //Channel 6 (Green Wreath) P1OUT |= 0x02; //Clock in P1OUT &=~ 0x02; //Clock low P1OUT = 0x00; //Channel 5 (Red Icicle) P1OUT |= 0x02; //Clock in P1OUT &=~ 0x02; //Clock low P1OUT = 0x00; //Channel 4 (White North) P1OUT |= 0x02; //Clock in P1OUT &=~ 0x02; //Clock low P1OUT = 0x00; //Channel 3 (White South) P1OUT |= 0x02; //Clock in P1OUT &=~ 0x02; //Clock low P1OUT = 0x00; //Channel 2 (Blue North) P1OUT |= 0x02; //Clock in P1OUT &=~ 0x02; //Clock low P1OUT = 0x00; //Channel 1 (Blue South) P1OUT |= 0x02; //Clock in P1OUT &=~ 0x02; //Clock low P1OUT = 0x01; //Channel 0 (Clear All/Active Low) P1OUT |= 0x02; //Clock in P1OUT &=~ 0x02; //Clock low P1OUT |= 0x04; //Latch outputs P1OUT &=~ 0x04; //Latch low while(i > 0) { i--; }
Question by Electric Spectre1 | last reply