Optocoupler + 12v automotive relay control circuit parts help and understanding

Hi, I am having trouble finding an example to reference and understand how they choose the values of resistors to make the circuit function. As I am creating this post, I've looked to the right on the screen, and it shows there's a few posts it shows are similar, but none seem to answer the question.

The project:
I am wanting to control an automotive relay from an Arduino Nano. The relays coil resistance is about 120Ω and draws about .125ma if I remember correctly when I used a dewalt 12v battery to test.

Ultimately, this will be like a 3 relay shield you can buy on amazon/ebay etc, but with automotive relays. The coil resistance of the automotive relays is too low and will draw more current than the optocoupler can handle. The project needs to use automotive relays as the current is probably more than 10a, maybe 15... safe than sorry for this project.

I've attached a picture of the schematic Ive drawn using the free version of Eagle. I have only about 2 weeks experience with the program . I've found several different schematics of using an optocoupler and transistor and drew up the sketch based off of what I found, but I don't understand how to read the data sheets to find the values to drive the gate, and if the gates current will exceed the optocouplers transistor limit.

I can find the octocouplers limit on the data sheets, understand how to calculate the Arduino Nano to octocoupler resistor value (so it doesnt burn out the internal led of opto but that's where my lack of circuit design ends.

the mosfet part number is correct in the sketch, I found it when researching, it has a current capacity of .8ma which is way more than I need, but again, I do not know what is ideal for this project.

Other thing I don't know is if I should drive the optocoupler output off of the 5v feed from the Arduino 5v power supply or use the 12v and add the (I'm guessing additional resistors or circuity to make the transistor function properly)

The Nano will be powered by an Adafruit 12v to 5v buck converter that has max current rating of 1.2a. To me it seems like a simple solution, incorporate a pre built component to my project board and has high efficiency vs a voltage regulator

If you have the patience to help and or point me to a link that explains how to do this, I will be very grateful as I am stuck once again with this project.

Thanks in advance,
Clint

Using a MOSFET for slow switching applications like this means you only need enough current capacity to charge and discharge the gate when switching. Given you are switching a relay you could easily get away with a relatively high gate resistor value, but to be fair it would probably work just as well directly connected. In this scenario I would use a gate resistor of about 1K, this will provide some protection to your optocoupler and ensure low noise and good positive switching of the MOSFET.
One thing you will need to change is where the collector in the optocoupler is supplied from, at the moment as soon as the MOSFET switches on, pin 6 of the optocoupler becomes switched to ground which will then switch off the MOSFET. Rather than oscillating it will probably find a partially on state and just get hot. I would supply it from your 12V rail.

If your UNO GND and your relay GND are common though, you could get rid of the optocoupler all together. The MOSFET will do just fine at isolating the relay from your GPIO pins, as long as you keep D1 there to shunt reverse voltage it should be fine.

This is a circuit I use alot, very simple and super reliable:
image

1 Like

Blockquote[quote="mahatmajman, post:4, topic:1099589, full:true"]
This is a circuit I use alot, very simple and super reliable:
image
[/quote]

From my researching / searching, 24 volt relays have a much higher ohm value, similar to that of the little 10a relays that are found on the pre made relay boards, near 400Ω... this is 12v power and will need to use 12v relays so I dont think it will work.

1 Like

I couldnt update the post quick enough to your first reply, and

As far as the resistor to the gate, 0Ω, so it would be 12 from source, to octocoupler to gate? I think the data sheet said 2-4v... but I might have mis read it.

already updated the sketch before I could :slight_smile: thank you

How would someone with no experience in circuit design know how to find that value of 1K you chose? Is it something calculated from the data sheet and using ohms law? or trial and error (experience)?

R4 can be 0 ohms.

BTW

H11F1 is an opto fet, i.e. it is not an opto coupler/BJT

sorry about that, is a placehodler, I am super new with Eagle and it just looked like a opto coupler. I will delete the text referencing it in the next image not to confuse anyone else. Thank you for your help too!

Would you know how to calculate the Gates current draw from the data sheet? That way i will know how to choose the optocoupler. The data sheets understanding is defiantly confusing me.

The gate current draw for the N channel MOSFET will be next to nothing, probably nano amps or less.

1 Like

I will look into the optocoupler that has the internal photo transistor rating of 12v ish rated input and update with what I find before I buy.

I bought some a while back from Mouser, H11A1 and I have 4 left in the package, but haven't looked at the data sheet yet.

I bought them for a project I failed at. That project was turning a Glade air fresher into a Smart Glade air freshener....I got the code right (alexa said so lol), but the electronics guessing/ probing killed the airfreshner and then sat it aside and then shelved it) this is not for the air freshener project though. I plan on trying this project again later, but I want to see this relay click and the nano to survive. :slight_smile:

Thank you again for your help,
Clint

updated with the irf610 mosfet data sheet

irf610-1768293.pdf (154.7 KB)

Nah it will work just as well with a 12V relay as with a 24V relay, as long as the MOSFET you choose is up to the task. A 12V 120R coil will sink 100mA to drive it, so as long as your MOSFET is capable of 100mA continuous drain current it will be fine. I have plenty of these out there running on 12V using a piddley BSS123 SMD MOSFET and they work just fine.

1 Like

A 4N35 is a good all round opto coupler.

The H11F1 is a good analog switch.

Normally it is a toss up between switching time and robustness. If you need super fast switching time (as in picoseconds) then you have to take into account gate capacitance, adding resistance here or having a low current gate driver might result in a slower than needed switching time as the current restriction slows the charge build up or removal from the gate. In that case you would want to have very low or no resistance in the gate drive path. If switching time is not a concern and you're happy with a few microseconds delay then you could put a really high value resistor here. The reason you might want to do that is if there are other elements attached to the gate (like a noisy ground or a higher voltage to pull it up). In this case a high resistance here protects your sensitive MCU GPIO pins, and over voltage bleeds to the MCU VCC via the silicone di, and is very small because the gate resistance is high (micro or nanoamps). If the gate resistance is super high though (megaohms for example) you might start picking up electromagnetic interference which may inadvertently switch the MOSFET on or off as the gate resistance is super high. So it is a balance, but in your situation you could put in anything from 0 ohms to 100K ohms and see no real difference practically speaking.

1 Like

I'm looking at the data sheet before bedtime and I hope I dont dream about this lol, but I seriously feel this is a stupid question,
how to tell the difference (between choosing components)
between the 4n35 and the H11F1 for example by looking at the data sheets. If I search octocoupler and found the 2, for example, how would a noob choose one over the other?

I am all for buying 5 $ worth of parts and 9$ shipping from Mouser, I love them, plus they are like 3 hours away!! Ill add those to the cart aswell :slight_smile:

time wise, definatly not pico seconds, I think is insanely fast switching time , this is a windshield wiper module project, and defiantly is not pico second sensitive.. more like 1 second -ish is fast enough.. heck, just playing around with the Nano and the 2 channel Amazon relay board works just fine, however in this just a test circuit/setup, there is zero load on motor + no linkages(which adds resistance and time) and the board can only handle 10a. This is why I am trying to figure out how to pick the components for the automotive relay

thank you both for help and recommendations. I will add these and some other odds and ends to my Mouser cart.

Clint

1 Like

When it comes to an opto coupler, look at the CTR (current transfer rate).

I always like this to be 100%.

Price and easily availability is important.

If you need to detect AC an internal back to back LED might be best. (H11AA1)

A good high gain chip has a darlington output (4N32) CTR 500%

A 6N139 is a good communication opto.

and could drive your automotive relays.

1 Like

for sure, however once I can get the Nano to turn on the automotive relay, the goal is to make a PCB with either relay installed on the board and appropriate traces for the current and the nano... or have it where the relays are remote mounted and the module and related components separate.

This is the board I have so far, its shows:
15 pin female header spaced for the Nano
6 pin connector for inputs
2 pin connector for +12v battery input
and 3 pin connector for regulator/buck converter power.

circuit_board_incomplete

No ouputs drawn yet in the schematic, I wanted to understand the relay control first.
clint