I am trying to wire up a mechanical relay that closes its (normally open) contacts to common on a high voltage signal and only this signal. The normally closed terminal is not wired up in this application. I have a few circuits that I think may work, but I was hoping to get some advice about whether I should choose the relay with the optocoupler or without the optocoupler? Or if both circuits will even achieve the desired result.
I don't see a high voltage signal on either of your schematic diagrams.
Is the relay to switch a high voltage signal or is the relay to trigger on receiving a high voltage signal ?
Assuming a relay is appropriate for this application, a relay module with an opto-coupler is a safe choice. If both sides of the opto-coupler share a common ground, then the isolation benefit of the opto-coupler is lost.
6v6gt:
I don't see a high voltage signal on either of your schematic diagrams.
Is the relay to switch a high voltage signal or is the relay to trigger on receiving a high voltage signal ?
Assuming a relay is appropriate for this application, a relay module with an opto-coupler is a safe choice. If both sides of the opto-coupler share a common ground, then the isolation benefit of the opto-coupler is lost.
Logic high of 3.3V to close relay, most relays close NO contacts on logic low signal. But notice the first thing being done is to step this 3.3V logic high to a 5V logic high so the relay will be seeing 5V not 3.3V.
Interesting point about the optocoupler isolation being lost if the grounds of the two 5V supplies are tied together. I honestly don't know how to avoid this.
But are the two circuits posted viable for a high logic driven relay?
In your first circuit, there's no need for Q1. Rp should be used as a pulldown resistor to prevent false triggering on power-up. In your second circuit, there's no need for Q1 or Rp.
dlloyd:
In your first circuit, there's no need for Q1. Rp should be used as a pulldown resistor to prevent false triggering on power-up. In your second circuit, there's no need for Q1 or Rp.
The remaining circuitry looks OK.
Thanks for this info. For the first circuit, are you saying that the 3.3V logic signal can be used to drive the transistor? Would you mind suggesting a value for Rp or telling me how to find this.
For the second circuit, it sounds like 3.3V signal can drive the optocoupler as well, and suggested to eliminate the 5V connection on the anode side of optocoupler along with Rp?
Great post, I think I understand how to implement both. Which circuit is best though? It sounds like if I can't avoid tying the grounds together for the 3.3V signal and 5V signal then I will lose the benefit of the optocoupler, making circuit 1 the best option. Would you agree?
Yes, I agree. If you're switching an AC load, contact arcing and RF interference can be reduced by using an MOV connected from COMM to NO relay terminals.
feynman137:
It sounds like if I can't avoid tying the grounds together for the 3.3V signal and 5V signal then I will lose the benefit of the optocoupler, making circuit 1 the best option. Would you agree?
Why are you thinking you need a common ground? Isolation is the whole point of using an optosisolator. The circuit looks fine as drawn, although the bias resistor on the LED/emitter side might be a wee bit high for 3.3v logic.
S.
dlloyd:
Yes, I agree. If you're switching an AC load, contact arcing and RF interference can be reduced by using an MOV connected from COMM to NO relay terminals.
Thanks for these suggestions.
srturner:
Why are you thinking you need a common ground? Isolation is the whole point of using an optosisolator. The circuit looks fine as drawn, although the bias resistor on the LED/emitter side might be a wee bit high for 3.3v logic.
S.
I don't need a common ground. But if the 5V source also supplies microcontroller with 5VDC+/- and therefore 3.3VDC signal is grounded to this, how can I avoid?
feynman137:
Thanks for these suggestions.I don't need a common ground. But if the 5V source also supplies microcontroller with 5VDC+/- and therefore 3.3VDC signal is grounded to this, how can I avoid?
Use separate power supplies. But what is the need for total isolation? Are you worried about transients, or have experimental evidence that isolation is necessary? Make sure the Arduino supply is bypassed. I don't see the need for the opto at all, unless high voltage is present on the relay (and maybe not even then). It's not clear to me what's being switched.
S.
Paul__B:
Unless you are actually going to use a separate relay supply, you just feed the 3.3 V logic signal directly to the 510 Ohm resistor.
Thanks for the comment. I believe this is what was concluded in post #4, but it was suggested to keep a pull-up resistor.
srturner:
Use separate power supplies. But what is the need for total isolation? Are you worried about transients, or have experimental evidence that isolation is necessary? Make sure the Arduino supply is bypassed. I don't see the need for the opto at all, unless high voltage is present on the relay (and maybe not even then). It's not clear to me what's being switched.
S.
Unfortunately everything is tied to the same 12V battery so I don't think it's possible to further isolate. But as far as evidence needed for isolation, I have none. I looked at the typical relay modules for sale and saw their designs included a lot of these features.
When the circuit is closed by the GPIO, a ground signal is given to a kill switch. This switch then stops a V8 engine, so it is a rather large process.
feynman137:
Thanks for the comment. I believe this is what was concluded in post #4, but it was suggested to keep a pull-up resistor.
Sorry, that was a bit confusing. "dlloyd" recommended a pull-down resistor which would be connected to ground, not 3.3 V or 5 V.
This is unnecessary when using a BJT but needed if you use a FET in order to ensure the relay stays switched off until the microcontroller starts program execution and defines an output pin.
Note that you cannot use GPIO0 or GPIO2 on an ESP8266 to control a relay with this arrangement as they must be pulled up on boot.