Can an optoisolator do this or do I need a relay?

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.

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 ?

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.

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

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

Good point, thanks Mike.

Chris

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

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

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?

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.

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?

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.

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.

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

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.

Thanks again for your help Mike.

Chris