[solved] Arduino Mega to 16 channel relay board

Hello everyone! I'm working on a project using an Arduino Mega, and I've bought (not received yet) a 16 channel relay board like this one : http://ra.gy/4cifY . It says that it may be used directly with Arduino, but it doesn't seem so in every case as it says that the relays need a 15-20mA per channel, which would make a maximum of 320mA if I have all my relays on, which is way out of the Arduino Mega limits. So I was thinking of using a simple non inverter buffer chip, like three 4050 (http://ra.gy/9wE6j) between the Mega and the relay board. (each pin would go to a non inverter buffer before going to the relay board, which would make the 4050 sink the current instead of the Mega). As the 4050's maximum output per pin is 25mA, there should not be any problem for the 4050?relay board part. But I couldn't find the data to be sure that my Mega would be able to send enough current to the three 4050 to activate all relays at the same time.

Does anyone have an idea about that? Am I right in the global approach of the problem?

Thanks for your time! Brice


Edit : Quick answer for those interested The board doesn't really use those 15-20mA per channel, but only 4mA, which makes it possible to use it directly for the Arduino's outputs (more info on why in the conversation). Thanks everyone

Maybe the Arduino Mega 2560 can do that, all 16 channels of 15-20mA. But the voltage regulator on the Arduino board would get very hot, and the ATmega2560 chip itself also.

The relay module has opto-coupler inputs. That is why the 15-20mA is needed. And I see relay drivers and a DC-DC converter to make 5V out of 12V.

Perhaps you can use ULN2803, if the relay is active with the signal being low.

Thanks Peter. I didn't even think about using transistors... I think I'm going to do what you're saying and use two ULN2803, and it will even save a little space on my board! For the relay being active high or low, it doesn't really matter as both normally-open and normally-closed are available on the card.

For curiosity, wouldn't the non-inverter buffer have done the trick also?

I'm used that the 4000 series can only output 1mA. This 4050 has an absolute maximum rating of 20mA and 50mA for the whole chip. That means that the normal output current is much lower and if the relay boards 20 mA, the 4050 is at its absolute maximum. You should stay away from the dangerous "absolute maximum".

You won't see many 4000 series chips with Arduino, it is all 74HC and 74HCT here. There are '595' shift registers that can drive leds.

The ULN2803 are darlington open-collector drivers. It will only work if the optocouplers are activated when the signal is pulled low. But it is super cheap, they cost 2 dollars for 10 chips on Ebay.

I don't believe the current specification of the 15ma or whatever..

Looking at the schematic : http://www.sainsmart.com/zen/documents/20-018-103/16-relay.rar There are typical OptoIsolators with some multiple-resistor package from the Arduino outputs to the LED in the optoisolators to +5V.

Usually only less than 5ma is NEEDED.

You need to find out what the resistor values really are.

Try this: Connect the +12V on the relay board, and then activate a relay by connecting it's IN to Ground. The relay should activate. THEN start adding resistance from the IN terminal to ground. I'll bet you a 8-relay board that only takes 4 ma per input (Like THIS:) that the relay will still activate with at least 220 ohms of resistance to ground.

IF I'm right, you can run all those inputs from the Mega OK. If I'm, wrong at least you'll have a 8-relay board that DOES work :-)

Let us know what's happening when you get the actual board. And try to measure those resistors (inside the multi-resistor packages). A closeup photo of the optoisolators and resistor packs would be good too.

...you'll figure it out...

terryking228: Try this: Connect the +12V on the relay board, and then activate a relay by connecting it's IN to Ground. The relay should activate. THEN start adding resistance from the IN terminal to ground. I'll bet you a 8-relay board that only takes 4 ma per input (Like THIS:) that the relay will still activate with at least 220 ohms of resistance to ground.

Interesting. Although, wouldn't this be one of those rare occasions that the current measuring abilities of a multimeter would actually work. Just hook up the input of the relay through your multimeter to ground and you'll have a measure of what is being drawn.

Just hook up the input of the relay through your multimeter to ground and you'll have a measure of what is being drawn.

Good point.. then you'd know what the pin actually would draw from the Mega.

Still good to find the maximum resistance that is workable. You maybe be able to simply add series resistor to each input and still have reliable operation at less current.

I just don't believe those optoisolators need 15-20 ma!

terryking228: I just don't believe those optoisolators need 15-20 ma!

I'd put money on it. With trial and error using a pot to ground he could find out the minimum current required. Hook it up to a pin and find the actual current being drawn, then calculate a resistor value to be just above the threshold (likely somewhere closer to 5 than 20ma)

Hello! And thanks to all of you for your interrest! I've received the board and measured the current to activate a relay, it was around 3.9mA (so you bet well Terry), just as you thought it would. And I also tried with some resistors, and got it working until 4.7k (next resistor I had, 10k, did not trigger the relay). Isn't this a little bit strange? My calculation (R = 12 / 0.0039) shows that the relay should be triggered with a maximum of 3076ohms, doesn't it?

So, now, what I don't get, is why there is a +5V connector if all we need to do is to ground the pins to close the relays? Is it because I want the +5V to be seen as an HIGH state (so the system uses this pin as a value to compare to)? or is there a voltage regulator that creates its own 5V when the pins are not connected, and I just don't see it?

Anyway, 4mA * 16 = 64mA, so I think I'm going to drive the board directly from the pins of the mega.

Thanks again all! Brice

The relay board creates its own 5V with a dc-dc converter. I think that is because sometimes relays of 5V are used and sometimes relays of 12V. That 4mA is a lot better, drive them directly. If the voltage regulator on the Mega board gets too hot, you should change the way it is powered.

The check for "too hot" is to put your finger on it. If you can't keep your finger on it, it is too hot.

Noted, I'll do that! Thanks a lot!

"Too hot test" done successfully. I've let all channels on for one minute (which is a really worst case scenario for me, as this will never happen), and it wasn't even hotter than at the beginning... But I'm powering the Mega through the usb cable (in this project, it stays always connected to the pc to be able to drive the relays, among other things, through a TTY on a Linux machine), so I guess the voltage regulator isn't used at all in such a case. But I checked and the other components, like the atmega, didn't get hot neither, so I'm going to validate and drive the relays board directly from the Arduino.

Thanks all for your answers and suggestions.

Brice

Correct, the voltage regulator was not used. When you apply an external power supply, you can use 7.5V. The voltage regulator will stay cooler with 7.5 than with 12V.