Driving a lot of relays with Mega

Hey there,
I want to switch as many high power switches (relays, surge switches like "Eltako" and ssd-relays all switched by a 12V psu) as possible with a Mega. I looked at the max power specifications of the Mega and found out that it is divided into port groups that have a combinded max power output. (about 200mA for 16 Ports so i got 6mA fo each port, 5mA to be on the safe side)

I also want isolation between the Arduino and the 12V rail. So I'll go with optoisolators. But I'm not sure, if 5mA will be enough to drive optos and if that leaves have enough room for a clear pwm signal with the low CTR that driving them wit 5mA would result in.)

So what do you think? Can I drive those optos directly from the mega or should I put in some transistors in between to drive them? What kind of transistor would I use there and how do i calculate the resistor between Mega and transistor base?

For driving 12V relays you need transistors that support both that voltage and the required current. Use e.g. ULN2003 for minimum component count.

SSR should have opto isolation included, which can be driven by an output pin - as long as the currents are acceptable. Relays have well isolated circuits.

You can buy multi relay boards with transistor driving circuits for Arduino , and some on eBay .

hammy:
You can buy multi relay boards with transistor driving circuits for Arduino , and some on eBay .

Well, most of these shields use cheap components. This is for my house automation system, I would like to use high quality stuff this time. Also, the relay will be wall mounted ones so I will only need drivers and isolation on the PCB that weill them be wired to the wall mounted relays and switches.

DrDiettrich:
For driving 12V relays you need transistors that support both that voltage and the required current. Use e.g. ULN2003 for minimum component count.

SSR should have opto isolation included, which can be driven by an output pin - as long as the currents are acceptable. Relays have well isolated circuits.

Yes, this would be a nice driver for the 12 V side, but I would like all outputs to be equal in order have the most flexibility. So I want them all to be isolated to the Maga side and being capable to put out 12V 1A (just in case), more likely a couple of mA on the output side.

Well, most of these shields use cheap components.

The ones I use have typical components; nothing low-quality. See:

http://arduino-info.wikispaces.com/ArduinoPower

and

http://arduino-info.wikispaces.com/ArduinoPower#OI

I have sold over a thousand of these relay boards, often to industrial companies, and had (zero as I recall!) rejects/returns.

DISCLAIMER: Mentioned stuff from my own shop...

Connecting LOTS of relays? Consider the Mega "Sensor Shield" :

https://arduino-info.wikispaces.com/SensorShield#SSM

Then you can set up terminal strips:

and use rainbow cables to connect:

If all/most of your connections are to relays, just use rainbow cable from Sensor Shield to relay boards.

Like:

Come on man, stop advertising your own stuff. Where I am, house installazion has to comply with some strict standards. I will not hotwire a couple of relay boards togehter.

The only acceptable stuff for permanend istallaation of AC components has to be wall mounted (top hat mount) and has to comply with VDE regulations.

I just wanted to know if its alright to drive optocouplers with 5mA or if i require an additional driving stage.

If your electronics knowledge/pcb skills are lacking (which I doubt they are), I would go with terryking228's solution; otherwise, I would go with DrDiettrich's solution - (2) uln2003 has many packages - though hole and smd.

Hi,
Info on opto-isolators here (scroll down):

http://arduino-info.wikispaces.com/Popular-ICs

Details of Arduino output pins ratings here:

https://arduino-info.wikispaces.com/ArduinoPinCurrent

Common 8-channel relay boards have an opto LED (Vf~1.2volt), and indicator LED (Vf~1.8volt), and a 1k resistor in series.
Meaning the Arduino pin has to sink (active LOW) ~2mA per relay input.
So there are no pin/port/package current restrictions on a Mega.

Avoid 16-channel relay boards. They have a design fault. Optos, but no opto isolation.

If you want to switch your own relays, then look at the TPIC6x595 shift register family.
The TPIC6B595 can switch up to eight 150mA relay coils, and you can daisy-chain the chips.
Uses only three pins of the Arduino for as many relays as needed.
No opto isolation with TPIC or ULN chips though.
Leo..

Wawa,
Thanks for the post; the uln2003 is only rated for 500mA total sink as opposed to the 150mA per output of the chip you referenced. Care to post a link referencing digikey.com? My google search didn't appear to reference the chip you alluded to.

Thanks.

[edit] found it - mouser & digikey.

There is a whole family of those chips, with different max currents and packages.
I mostly use the TPIC6C596 (smd).

TPIC6* returns 94 shift register results on Digi-Key.

Also try searching "TPIC6B595" on ebay.
Leo..

The ULN can be used to drive 12V relays, instead of 7 discrete transistors and some more resistors. The same with the TPIC, for a serial connection.

DrDiettrich:
The ULN can be used to drive 12V relays, instead of 7 discrete transistors and some more resistors.

But the ULN2x03 is essentially obsolete, an inefficient switching device (which is why its rating is so much poorer than the TPIC6x595). If you think you want to use one, you really need to have a deeper look at your situation.

A likely misunderstanding here is the expectation of a need for a Mega. Using TPIC6B595s (8 of them), you requite only three control lines which if you feel the need, could be opto-isolated, for 64 relays and a Nano will control these perfectly well. While I am a bit tardy in the matter, this is precisely my plan for my home automation with a panel of 24 Volt DIN-rail relays, though an ESP8266 as controller could be a consideration (the original concept used a 6802!).

The need for opto-isolation is questionable. People do have trouble with interference from relays, but commercial equipment manages without. Understanding the need for lead dress and wiring layout is the critical matter.

How efficient must be a HV relay driver?

See reply #7.

A TPIC, or ULN, or other darlington array is not going to make any difference for 12volt or 24volt relays.
What makes a huge difference is driving them.
I would rather wire up eight TPIC chips (three control wires) than eight ULN chips (64 control wires).

Note that a TPIC is 5volt only (ULN is not).
With a 0.85*VCC HIGH switchpoint.
So level shifting is needed when driving from a 3.3volt MCU (ESP8266).
Leo..

Hi,

The need for opto-isolation is questionable. People do have trouble with interference from relays, but commercial equipment manages without.

Paul, all those PLCs and building automation systems have optical isolation. Opto22 type interfaces are common on process control equipment. There is little cost difference since optoisolation is so common.

Understanding the need for lead dress and wiring layout is the critical matter.

YES!! I have designed/built large test systems and I can tell you that basic planning of “Where is Ground” and “Where does the current actually flow” is critical. Fixing it later is NOT fun.

Some suggestions here:

http://arduino-info.wikispaces.com/Arduino-Project-Planning-Electrical

My Mega-driven home automation system has both Opto-22 rack modules and typical 4-relay optoisolated boards. It’s been running for years without glitches. (Well, except in my code…)

I DO have a 6 inch wide copper strap running the length of the cellar ceiling, with outside ground rods on both ends. But that’s more my old Broadcast Engineer / Ham Radio habit.

But it can’t hurt :slight_smile:

I dont really want the Mega for the Number of its outputs. I rather choose it for ihts memory and clock frequency.

I will be using a Wiznet W5500 to connect to my house automation network and will be running pubsubclient.

The Wiz stack uses a lot of memory so will pubsubclient when I'm working with about 50 topics, each is a sting of about 20 to 30 bytes...

I did not consider using an ESP8266 with shift registers before. But I will look into that now. It seems like a much better solution than using the Mega with Wiz W5500

terryking228:
Hi, Paul, all those PLCs and building automation systems have optical isolation. Opto22 type interfaces are common on process control equipment. There is little cost difference since optoisolation is so common.

I was referring to equipment that uses integral on-board relays. In my case, the relay drivers will be in the relay cabinet - and the dress will be strict

terryking228:
I do have a 6 inch wide copper strap running the length of the cellar ceiling, with outside ground rods on both ends. But that's more my old Broadcast Engineer / Ham Radio habit.

No comment. :grinning:

kimmjoe:
I did not consider using an ESP8266 with shift registers before. But I will look into that now. It seems like a much better solution than using the Mega with Wiz W5500

I am not really into using WiFi in systems where reliability is important, so not for example, in my business except for minor support functions not connected to the net, but the esp8266 already contains all the net functionality. The cheap bidirectional level converters - or optocouplers because it is only one directional in any case - are perfectly adequate to interface the TPICs though you might have to lower the speed if using optos.