Pages: [1]   Go Down
Author Topic: Can an optoisolator do this or do I need a relay?  (Read 2216 times)
0 Members and 1 Guest are viewing this topic.
Southern California
Offline Offline
God Member
*****
Karma: 5
Posts: 539
I like blinky lights
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm building an Arduino-compatible circuit that flashes some lights for an hour then turns itself off. I built the power circuit copying the Arduino AA Undershield schematic and all works well, like this:

1. User presses momentary switch which connects the batteries to the power circuit
2. The ATMega328 boots and pulls a pin high
3. This pin completes a 5V relay circuit

The relay's switch is in series with the momentary switch, so once the chip's booted it stays on.

After 1 hour the code pulls the pin low, which breaks the relay, which kills power to the circuit.

 As I said all is working, but I'm a programmer by trade and am new to hardware. Is there a more efficient way to do this? I tried using an optoisolator but couldn't get it to work, but I may have easily been doing it wrong.

Thanks in advance for any help.
Logged

http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

Copenhagen / Denmark
Offline Offline
Edison Member
*
Karma: 6
Posts: 2360
Do it !
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

How did you connect the optoisolator ?

Did you use a current limiting resistor for the LED in the optoisolator ?

How much current are the lights drawing ?
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 619
Posts: 33962
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The output current from an opto isolator is limited to a few mA, if you want more then you will have to have a transistor at the receive end. There is not enough current for an opto to directly control a relay.
Logged

Southern California
Offline Offline
God Member
*****
Karma: 5
Posts: 539
I like blinky lights
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It looks like the LEDs will draw about 500ma when all are on, but most of the time they blink so it's closer to 150 - 200.

I did put a resistor between the Arduino and the Optoisolator but didn't think about putting a transistor on the other side, to increase the amount of current the optoisolator can switch. I will look into that.

Thanks for the help,

Chris
Logged

http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 619
Posts: 33962
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
but most of the time they blink so it's closer to 150 - 200

Yes but be aware when designing things it needs to be able to handle the peak current as if they were all on at once.
The fact they are on an on / off duty cycle only helps with the power (heat) dissipation.

good luck
Logged

Southern California
Offline Offline
God Member
*****
Karma: 5
Posts: 539
I like blinky lights
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Good point, thanks Mike.

Chris
Logged

http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

0
Offline Offline
Full Member
***
Karma: 0
Posts: 177
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There is a schematic on the Playgroundwith a relay driven by a transistor triggered by an optoisolator

Logged

Southern California
Offline Offline
God Member
*****
Karma: 5
Posts: 539
I like blinky lights
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi thanks for the example but for this application I didn't need a high powered relay -- I have a 5v one that works directly off a digital pin.

I was looking to see if using an optoisolator + transistor instead a relay reduced power consumption enough to make running the system of AA batteries viable, but I think the draw from 96 LEDs means I'm stuck with a wall wart or D cells.

Thanks,

Chris
Logged

http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 619
Posts: 33962
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I have a 5v one that works directly off a digital pin.

Are you saying that you are driving a relay directly from the output pin of an arduino?
That is surprising if you find a relay that pulls in at less than 40mA? If so what is the maker and part number?
Logged

Offline Offline
Edison Member
*
Karma: 3
Posts: 1001
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The small 5V Omron relays (e.g. type G5V) have a coil resistace of approximately 175 Ohm's. Also I've seen Tyco electronics offer small relays (OMR series) with a coil resistance of 250 Ohm's.

Quote
That is surprising if you find a relay that pulls in at less than 40mA?

Are you thinking that the inrush current may be damaging to the Arduino over time when interfacing to the above relays directly?
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 619
Posts: 33962
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well 175R gives you a current of 28mA so that should be OK, however you do need a diode across it or you will damage the output pin with revers voltage.

Quote
Are you thinking that the inrush current may be damaging to the Arduino

Inrush current concerns only really applies to capacitors and motors. A relay is an inductor and when you first apply apply a voltage to it there is a delay as the current increases. That is the inrush current starts off at zero and ramps up to the full value given by the resistance of the coil.

You might think a motor is an inductor but in that case the inrush current ramps up to the stall current, before the motor starts turning. Once going a DC motors take less current due to the constant change in direction of current in the rotor.
Logged

Southern California
Offline Offline
God Member
*****
Karma: 5
Posts: 539
I like blinky lights
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Mike and Ben,

I found a 5v relay (Hanlin Breed HE3621A0510), it has a built in diode and if I did the math right it draws 10 ma (5v and 500 ohms).

I'm not sure if it's appropriate to include vendor links on this forum or not, but I bought it from Jameco:

http://www.jameco.com/webapp/wcs/stores/servlet/ProductDisplay?langId=-1&productId=1860088&catalogId=10001&freeText=1860088&app.products.maxperpage=15&storeId=10001&search_type=jamecoall&ddkey=http:StoreCatalogDrillDownView

Chris
« Last Edit: January 06, 2010, 11:39:45 am by cmagagna » Logged

http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 619
Posts: 33962
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes that relay looks OK for direct drive from an arduino. Things to note:-
1) You do order the one whose order code ends in 10 or 50 as that has the diode option.
2) This means the relay coil must be wired the right way round. If it is the wrong way round you will effectively short the output through the protection diode.
3) The contacts can only handle a small power 10W.

It is OK to post any relevant link on this forum.
Logged

Southern California
Offline Offline
God Member
*****
Karma: 5
Posts: 539
I like blinky lights
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks again for your help Mike.

Chris
Logged

http://en.wiktionary.org/wiki/magagna <-- My last name.  Pretty apt.

Pages: [1]   Go Up
Jump to: