Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Relay and Optocoupler

Status
Not open for further replies.

Urahara

Member
Hi

In the attached diagram, can the relay be powered (the blue ovals) from the same source as the PIC? Would it make sense then to use the optocoupler or a diode would suffice since I would not be able to achieve circuit isolation with the former anyway?

I am hoping to power the relay using the same source as the PIC to reduce complexity. :confused:

Thks!
 

Attachments

  • optocoupler-relay.jpg
    optocoupler-relay.jpg
    31.5 KB · Views: 10,093
Hi

In the attached diagram, can the relay be powered (the blue ovals) from the same source as the PIC? Would it make sense then to use the optocoupler or a diode would suffice since I would not be able to achieve circuit isolation with the former anyway?

I am hoping to power the relay using the same source as the PIC to reduce complexity. :confused:

Thks!

hi,
Why dont you drive the relay by using a transistor.?
Remove the opto.

The relay, providing its mains rated, will give the required isolation.
 
Last edited:
I am hoping to power the relay using the same source as the PIC to reduce complexity. :confused:

When driving relay coils I always power them from the input side of the voltage regulator.

As your output is a home appliance so it will switch on more hours.When the relay takes power from the voltage regulators output same as PIC, the voltage regulator getting too much heat.

So when I selecting a relay I always use >8V relays & feed power from regulators input side.
 
Hi Eric
I got the idea from an article that uses a relay driven from a PC parallel port which uses a optocoupler to provide "better" isolation to protect the port. Wouldn't the concept apply similarly to PIC? Or this is just overly-designed? From your posting, you are ok with powering the relay with the same source as the PIC?

Hi Gayan
Sorry my attachment was a little misleading. The appliance is not a TV or device that would be switched on for hours, but couple of 2-3 mins with longer periods in-between. Even so, I don't think a lot of heat should be generated : The PIC end would be powered from a 9V Wall-wart which is then converted to 5V using a 7805. So power loss = (9V - 5V) * 100mA(max) = 400mW. Is my assumptions correct then?

Thks!
 
Hi Eric
I got the idea from an article that uses a relay driven from a PC parallel port which uses a optocoupler to provide "better" isolation to protect the port. Wouldn't the concept apply similarly to PIC? Or this is just overly-designed? From your posting, you are ok with powering the relay with the same source as the PIC?

Thks!
hi,
You could use the circuit you have posted, driven by a PIC pin.:)

If I used a mains relay connected to a PIC pin, I would use a transistor driver.
A relay with mains rated contacts would be sufficent isolation.

Even better use the device shown in this pdf.
 
Hi Eric

Thks for the prompt response! I just want to be sure: by transistor driven, do you mean something like the attached? The relay I have has the following ratings :
-10A 250VAC
-10A 30VDC
- COIL : 5VDC

Thks!
 

Attachments

  • pic-relay.jpg
    pic-relay.jpg
    17.9 KB · Views: 1,556
Hi Eric

Thks for the prompt response! I just want to be sure: by transistor driven, do you mean something like the attached? The relay I have has the following ratings :
-10A 250VAC
-10A 30VDC
- COIL : 5VDC

Thks!

hi,
Looks OK, the base resistor [4K7] is too high a value, use a 390R or 470R.

With a 4K7, the base current is [5v-0.7]/4700,, about 1mA

To be sure that the transistor saturates allow a higher base current, about 9mA.
 
there is another reason why you don't want to power the relay coil from the same rail as the PIC - Vcc will jump all over the place and the PIC won't like it. You could use a large bypass cap to mitigate the problem but it's better to use a separate rail for the coil. I've see random system resets due to that problem.

Also, powering the opto's LED and PT from the same rail negates the primary reason to have the optoisolator - isolation. This is why people are saying to just power it directly.

By the way, on the base of the transistor in the last drawing, use a largish resistor (100K to 470K) from base to gnd to prevent start up glitches from causing the relay to engage.
 
I am feeding an unregulated wall-wart 9V into a 7805 to get a regulated 5V for my PIC. Would taking the 9V to power the relay considered providing a separate power rail? Thks!
 
I am feeding an unregulated wall-wart 9V into a 7805 to get a regulated 5V for my PIC. Would taking the 9V to power the relay considered providing a separate power rail? Thks!

hi,
Providing the relay is rated for 9V operation, if its 5V, running it at 9V would cause overheating of the coil.
You could connect a 3V9 zener diode [suitable current rating] in series with top of the relay coil.
Or choose a suitable series resistor.
 
Last edited:
there is another reason why you don't want to power the relay coil from the same rail as the PIC - Vcc will jump all over the place and the PIC won't like it. You could use a large bypass cap to mitigate the problem but it's better to use a separate rail for the coil. I've see random system resets due to that problem.

Also, powering the opto's LED and PT from the same rail negates the primary reason to have the optoisolator - isolation. This is why people are saying to just power it directly.

By the way, on the base of the transistor in the last drawing, use a largish resistor (100K to 470K) from base to gnd to prevent start up glitches from causing the relay to engage.

Could you please clarify what does it mean by same rail. I have a problem when the AC load is connected to the relay. I powered both the pic micro controller and 5v relay with 5v. The controller hangs after a couple of seconds. It happens only when I connect the AC load. Some noise is travelling back to the micro controller. I have also used a diode across the relay. Now I am planning to use optocoupler, but still planning to keep one power supply (5v) powering both pic and the relay with 5v Orelse I can do voltage division and supply 3.3V to the pic micro controller and 5v to relay. (since many say that using same voltage and power supply for pic and relay causes problems)

Check out this page:https://www.electro-tech-online.com/threads/pic-16f54-controller-hangs-while-triggering-a-relay.98765/#post801452
 
Hi kurrodu

Optocouplers are designed to this purpose.That is to separate grounds & activate within a small trigger pulse.

Easiest way to solve your problem is to give separate supplies to the PIC & Relay coil.
 
Hi all, I nid help on how to connnect the ac load to relay??? Does the component listed able to withstand the high voltage??(AC 240V)
 
I design circuit relay and optocoupler without transistor. Please help me if there is a problem. Thanks



**broken link removed**
 
Last edited:
I design circuit relay and optocoupler without transistor. Please help me if there is a problem. Thanks

hi,
The emitter diode of the opto MUST have a series resistor to limit the current thru the diode.

With R1 and R2 at those values, the opto transistor will always be switched ON.

You would also need a suppression diode across the relay coil to protect the transistor.

The circuit as drawn will not work, I would also advise you, use a transistor driver after the opto.

You have not indicated what is the relay coil current/resistance.?
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top