i was wondering if it is possible to control 2 SainSmart 8-channel relay modules through a Sparkfun TLC5940 breakout board connected to an arduino mega 2560. Would i have to use something like a TIP120 in order to take the pwm and turn it into a 5v line to trigger the relays. Any help on this would be a huge help as i have just enough pins left on the arduino to run the TLC5940 and need to still connect and control the relays
While you could a 16 channel 5940 to drive these relays (15-20 mA), it’s a bit of a waste as you can’t really use the PWM capabilities of the 5940, relays just don’t act fast enough. Why don’t you use 2 of the shift register BoBs instead. Their pins have (just) sufficient sink capability, but just like the 5940, lack any protection from the inductive kick-back of a relay. You’ll need to add flyback diodes (unless the relays already have them, a link would have been nice). Even more robust would be to use a relay driver IC btw the SR’s and relays. This would also eliminate any question re: total current through the GND pin of the SR IC and thus any restriction on the number of relays on at any one time. (70 mA ?)
ok so it is possible to control them through the tlc5940 and sorry for the no links i will include links to everything iam using at the end of this post. I dont need the relays to switch on and off fast they will be turned on for around 30 seconds or more before turning off. would it make more sense if i used a (DAC) with a flyback diode or would just a flyback diode and the pwm from the tlc5940 work fine.
DAC = http://www.instructables.com/id/Analog- … o-Voltage/
relay board (x2)= http://www.amazon.com/SainSmart-8-CH-8- … B0057OC5WK
All you need is a register to hold 16 digital I/O lines. A single DAC won’t do that and all you need is an on/off (logic 0/logic 1, 0V/5V) output. You don’t need all the voltages btw 0 and 5 volts.
Nor do you want or need the PWM capabilities of the 5940. You’re code will be sending a “PWM” setting of either all on or all off to control each relay. That’s why I’d use the SR (x2). It’s less $$s and simpler code (shiftout function).
Since neither the SR BoB I linked to, nor the 5940, were intended to drive relays you need at least a flyback diode or risk damage to the ICs when the relays turn off. Using a relay driver negates that need but means you need to wire up your own board (of some sort). Alternately you could use two of the high power SRs, which eliminates the need for flybacks and any worry about total current draw. Again you’d need to wire your own board (of some sort).
https://www.sparkfun.com/products/734
http://arduino.cc/en/Tutorial/ShiftOut#.Uy9SFoUVBrA
I note you may be able to find a single 16 bit shift register, w/ or w/o relay drive (inductive load handling) “capability”.