Diodo flyback in car

Hello everyone, I am in a project for which with an Arduino Uno I command an opto-coupler and this in turn a mosfet-P transistor (IRF9Z34NPBF), all this will go in an installed vehicle.
Said mosfet gives a positive current to an electroiman 12v 5A, the negative part of the magnet connected it to the chassis of the vehicle.
As I have read here it is necessary to place a flyback diode to avoid inductive problems, but I have doubts for that diode to perform its function well, I doubt whether putting the cathode to the drain pin and anode to the chassis would be good or necessarily has to be directly in The pins of the electroiman itself? Or with the diode that carries the integrated mosfet is not necessary the flyback diode? Thanks for everything in advance

There is a common misunderstanding that the inductive "kickback" is generated by the inductor itself and therefore the diode must be connected directly across the inductor.

This is incorrect. The impulse itself is generated by the component that switches off the current, so the diode should connect at that device. It will probably make little difference where you physically connect it, as long as it is reliably connected to the correct part of the circuit.

The internal diode of the MOSFET is - necessarily - connected across the MOSFET so this is obviously irrelevant to the need to have a diode across the inductor.

Kickback voltage is definitely generated by the inductor, there's no misunderstanding about that, but its due to rapid changes in current. The diode across the inductor allows a path for current to continue flowing rather than reduce suddenly.

If the inductor carries a large current placing a diode at the switch and at the inductor is a wise precaution, as the stray inductance / characteristic impedance of the cable may generate large voltages anyway.

Paul__B:
There is a common misunderstanding that the inductive "kickback" is generated by the inductor itself...

I also have that misunderstanding, so please explain.
What else could generate that high voltage.

The impulse is ofcourse generated after the transistor switch turns off, but kickback current flows through the inductor. The shortest current path is when the diode is connected directly to the inductor. Any wire in between will act as an aerial and could transmit the spike to other circuits.
Leo..

A semi-related factoid.

Adding a "normal" diode across a relay coil can actually reduce life of the contacts by slowing down the collapse of the coil current therefore slowing down the mechanical opening time. Best way would be a diode and an zener.

I don't have any numbers but I suspect for hobby purposes the effect is negligible. Just though I would post it for others to obtain more probably useless info.

Hi,

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.... Tom... :slight_smile:

Attached image with the connection, with this way to connect the diode would its correct flyback function? Or does it have to be directly connected to the electroiman pins?

The diode there is fine. It's primary job is to protect the transistor.

That diagram won't work though. The opto can only turn the transistor 'on', not 'off'.
And the opto LED and/or the Arduino pin will burn out if you don't use a current limiting resistor.
Leo..

If I made a quick assembly, the resistors in the optocoupler and in the mosfet are missing so that it can be turned off.Otherwise as indicated in the image the connection would be good? to the diode? thanks !!

Captura de pantalla (4).png

OK, so that diagram is not drawn too well and has a number of issues.

As mentioned, it needs a pull-up resistor to pull the gate of the FET up to the battery supply to turn it OFF. About 4k7 should be fine - drawing 2.5 mA and dissipating only 36 mW. Using a 470 Ohm resistor in series with the optocoupler LED will drive it with about 7.5 mA which should ensure reliable switching.

The diode shown has an illegible marking but the symbol is a Schottky. This is quite unnecessary unless you propose to use PWM, but using PWM would not work too well with the optocoupler for a couple of reasons.

Wawa:
I also have that misunderstanding, so please explain.

So it seems, and of course I will. :grinning:

Wawa:
What else could generate that high voltage.

It sounds simple to say the inductor "generates" the voltage and of course it does, but I deliberately referred to an "impulse".

Wawa:
The impulse is of course generated after the transistor switch turns off,

No, it is not generated after the transistor switch turns off, it is generated as the switch turns off. The inductor is in the short term, a constant-current source. Unless otherwise constrained, it will produce whatever voltage is required to keep that current flowing. So you have a circuit consisting of a switch and a constant current source in an "open-collector" arrangement. As the switch opens, the voltage rises. It makes no difference whether it is "open-collector" or "totem pole" driving, the switch is the source of the impulse and the critical concept is that - it radiates from there.

Wawa:
but kickback current flows through the inductor.

Here is the point of the common confused thinking. There is no such thing as "kickback current"! :cold_sweat:

The inductor has a current flowing through it. When the switch opens, the current in the inductor and the wires that connect the inductor to the rest of the circuit instantaneously stays the same. That is the whole point of an inductor - to resist any change in current.

OK, so what does change? Where is there a current impulse?

Well, the diode of course! Before the switch off, a current was flowing through the (power supply and) the switch (transistor). After the switch off, the same current is now flowing through the diode.

So what current has changed? Where is there a current impulse?

It is in the switch circuit, including the power supply itself, and the diode. Current in the switch goes (suddenly) down, current in the diode goes (suddenly) up by the exact same amount. Current in the inductor and the wires that connect the inductor to the rest of the circuit instantaneously stays exactly the same. Then of course, the current in the inductor (and diode) smoothly decays - not as much of an impulse by any means. So the wiring to the inductor does not generate an impulse (or a sudden change in magnetic field) between the inductor and the diode.

Wawa:
The shortest current path is when the diode is connected directly to the inductor.

Following from the above, if however you connect the diode directly across the inductor, the actual current impulse occurs in the wires that run beteen this and the switch, and it is this part therefore that radiates interference. Not only that, but this also involves the wiring to the power supply itself, so any other devices that connect along this path will also be subject to the impulse.

Wawa:
Any wire in between will act as an aerial and could transmit the spike to other circuits.

Yes, the wires between the diode and the switch, not the wires between the diode and the inductor! :sunglasses:

What about the voltage "spike"? Well, that appears on the switched line all the way between the switch and the inductor, including the diode terminal irrespective of where the diode is located. It clearly is important that the two wires to any part of the circuit be bundled together as a pair, to minimise capacitive (electrostatic) radiation but much more importantly, to avoid electromagnetic radiation from "loops" in the wiring.

MarkT:
If the inductor carries a large current

Not strictly a factor

MarkT:
placing a diode at the switch and at the inductor is a wise precaution, as the stray inductance / characteristic impedance of the cable may generate large voltages anyway.

No, putting a second diode at the inductor is again, irrelevant! :astonished:

In fact, inductance in the cable will add to the voltage at the switch, as the switching impulse travels from the switch to the inductor, so the diode placed there will be first to conduct, and the diode at the inductor will not be needed as it is simply ineffectual!

In summary, note that the transfer of current is from the power supply and switch, to the diode. To properly suppress the impulse, the triangle of three components which are involved must be located as closely as possible with short wires between: the switching device itself, the diode and the local bypass capacitor across the power supply. The latter is needed to prevent the current impulse travelling back along the wires to the power supply itself

Hi,
This is something like you need;


Feel free , open to discussion.

Tom... :slight_smile:

Thanks for your help, the diode I was planning to put is V4PAN50-M3 / I. If I forgot to draw the 330 ohm resistor between the arduino pin and the optocoupler and the 10k resistor between gate and source. R2) 470R What is the function between the gate and the optocoupler?

RcP:
R2) 470R What is the function between the gate and the optocoupler?

No function.

Bad circuit to use in a car though.
A 12volt car supply can be 'dirty', and a >20volt spike could kill the mosfet when 'on'.

Could leave the 470ohm resistor on the gate, and use a 12-15volt zener across the 10k resistor.
Leo..

Wawa:
No function.

Want to hear Tom's explanation of that!

I understand in case of a voltage peak greater than 20v the mosfet would damage, in this way with the resistance even if there is a voltage peak it would be protected right? Thanks!

Paul__B:
Want to hear Tom's explanation of that!

The resistor from my experience is not just a current limit to the gate capacitance, but protection for the opto-transistor if the MOSFET fails.
From work/repair experience, no resistor in the gate usually blows the cr&*p out of the driver circuit when the MOSFET goes bang!!!!.
The resistor usually protects the driver.
But feel free to leave it out, its just a personal preference.
Tom... :slight_smile:

Interesting, but the MOSFET is probably the most expensive component, so it it fails, collateral damage to the opto-coupler is a relatively minor detail. In fact, that is really the purpose of the opto-coupler, an expendable isolation of the two sections.

Certainly, in SMPS, you expect more widespread damage if the FET has failed. Not fun things to attempt to repair.

I thought you might be wanting to limit the gate charging current from the opto-coupler.

Is the current that passes through the source and drain necessary to clean it from any noise or something? Or are the mosfets ready for the current to pass from source to drain without being clean?

Sorry, that's not making any sense.

As long as you do not attempt to pass more than the rated current through the FET (source - drain), do not expose it to any voltage in excess of the various ratings between elements, and do not allow it to overheat, it will function according to its specifications.

Perfect thanks for everything!