Jump to content

Banner.jpg.b83b14cd4142fe10848741bb2a14c66b.jpg

Arduino and PCB micro relays


Gina

Recommended Posts

I have a number of micro relays to control from an Arduino. These relays have a 5v 180ohm coil and so draw 27mA at their rated 5v. Arduinos are capable of sourcing or sinking 40mA on all their digital I/O pins. To me that means that the Arduino can drive these relays directly and doesn't need the extra NPN transistor that the Arduino data shows for driving relays. With transistor relay drive you need a diode to catch the overswing voltage when they are switched off but the Arduino has a push-pull output so I wouldn't have thought a diode was necessary. As I shall be driving 12 relays I could save a bit of soldering etc.

Could someone with more Arduino knowledge (eg. Chris-yesyes perhaps) confirm (or deny) this please?

Link to comment
Share on other sites

The drive capabilities of ATmega devices mean that they can source up to 40mA per pin, and each pin has protection diodes but I would still use something like a Darlington array chip ( the ubiquitous ULN2003/2004 is a likely candidate ) to drive the relays. Whilst the ports feature protection diodes, these are really to protect the drive FETs from static shock and are probably not up to the mark if you consider the inductive spike that a relay can impart as it is switched off.

The other thing to be careful of is that although you can source up to 40mA per pin, what is the total rating of the chip? The ATmega8, for example, has a total rating of 300mA. 12 x 27mA = 324mA, which would exceed that rating. You do not say which arduino you are using so the chip may have better characteristics, but it is worth considering.

The beauty of using a ULN2003 array is that it already features the suppression diodes keeping the soldering quite low anyway. It also means that you don't have to worry about overloading the ATmega, and can even run the relays from a different power rail if you wish to keep switching noise from affecting the processor.

Hope this helps,

Alan

Link to comment
Share on other sites

There will be one relay on continuously and one other on for a few seconds at a time so the total current capability would not be exceeded. I expect to be using a Nano. I could use a couple of ULN2003s, I guess, I do have some. Another thought is that I could use a naked ATMega328P with crystal and capacitors. I have USB to serial 5v TTL adapters an I only need PC connection to upload the sketch.

Link to comment
Share on other sites

Another thought is that I could use a naked ATMega328P with crystal and capacitors. I have USB to serial 5v TTL adapters an I only need PC connection to upload the sketch.

I'm not sure I understand what you mean by this. I take it that by 'naked' and 'upload the sketch' you mean that you already have an ATmega328P with the Arduino bootloader code in it. If it is just an ATmega328P without the Arduino bootloader code ( the way I like them :grin: :grin: ) then you will need some form of programmer to load any code.

As far as the relays are concerned, it sounds like you are not switching a lot very often, so switching noise is unlikely to affect the ATmega. This means that you could probably get away with direct connection, but personally I still prefer some form of isolation for any inductive load. I take it from your description that one relay will be used to control the power to some form of rig ( hence the permanently on ) and another will control some form of periodic process performed from that rig. Are there 11 separate possible things to use, hence the 12 relays?

Another thought I have had is that if you wish to control so many relays from a small device, why not do it via a BCD decoder? This means that you only need four pins to control up to 16 devices. It does make the controller board a bit more complex but means that your Arduino could perform other useful tasks while its there.

Hope this helps,

Alan

Link to comment
Share on other sites

The purpose of the relays etc. is contained in my CCTV camera control thread. These are DPDT 5v 180ohm PCB micro relays which I think I bought from Maplin. 10 relays select one of ten camera video lines plus one of ten motors which control the camera direction. The other 2 control on/off and polarity of power to the DC motors. I've looked into various ways of doing this including MOSFET switches etc. and came to the conclusion that relays were the simplest solution and least likely to have problems. I could drive the 10 selecting relays from a BCD decoder if there's a relay driver type - ie. capable of about 30mA and with spike catching diodes. I'll check - simpler than two ULN2003s.

I have just enough digital I/O pins - 12 to drive the relays and 2 for serial. So decoding isn't a necessity.

Forgot to say... the ATmega328 is supplied with Arduino uploader code already installed. You can get kits from ebay which include the chip with bootloader pre-loaded, crystal and capacitors for a few pounds. Some kits include other components too eg. http://www.ebay.co.uk/itm/221179678534?var=520131942703

Link to comment
Share on other sites

Just a thought, I can understand the use of relays to control power but what are the voltage levels you are running on the video lines? Normally this is of the order of 1V to 3V ( depending upon the video standard ) so unless it's higher, would it not be better to control them with simple CMOS analogue switches? Maybe the ubiquitous 4066 could be used if it can handle the video speeds. You would end up with a simpler and somewhat more robust control circuit and the interfacing to the ATmega would be a lot easier.

I've always found that relays can exhibit quite a lot of mechanical problems from time to time, especially if left somewhere where the elements can affect them.

Hope this helps,

Alan

Link to comment
Share on other sites

This was one of my solutions in the past but I need relays to select the motors for direction control so it was just a matter of using DPDT relays instead of SPDT. There was a doubt about the on resistance of CMOS switches with the video impedance being 75 ohms. As for the environment, this will be in a large shed which is weatherproof - no problem with damp.

Link to comment
Share on other sites

Yes, see what you mean about the on resistance of the 4066 ( having just looked at the datasheet ). I didn't remember they were that high.

If it helps I've just had a look through my stock and have about 100 2SJ317 P-channel MOSFETs and a similar number of MMBF170 N-Channel devices if you are interested. Both have very low on resistance but are surface mount devices, so you would probably have to make a PCB for them. However, they are quite robust when handled properly and can be soldered to directly with ordinary hookup wire. I'm quite happy to send you some if you want to try them as I think the project I bought them for has long since disappeared :grin: :grin: . In other words, "I can't remember why I got these........."

all the best,

Alan

Link to comment
Share on other sites

Thank you very much for your offer but although I have connected to the occasional SMD I try to avoid them as my eyesight isn't what it was. So I will have to decline your offer.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. By using this site, you agree to our Terms of Use.