Estimate current through inductor in DC circuit with PWM control

I am designing a circuit to control an electromagnet (coil with iron core) through a N-channel MOSFET driven by a PWM signal.

I can't figure out how to derive the relationship between the PWM duty cycle and the current I will get in the coil, and I need to know this as the magnetic field generated is a function of i.

These are the system specs:

• DC voltage source: 7.5V
• Coil L = 15 mH

Thanks for the help!

Update

Thanks for the feedback so far: of course the resistance is missing, I forgot about that! At this point, I have the coil with L = 15mH and R = 2.4 Ohm. And no, it's not coursework, just a personal project.

So, the current in the circuit should be i = V/R (1 - e^(-Rt/L)). The steady-state value is therefore i = V/R.

With this in mind, I thought of adjusting this to PWM as follows:

V = Vcc * %pwm (%pwm: duty cycle), therefore I finally have a relationship that links the duty cycle to the current through the coil.

This, however, turns out to be off compared to experimental data I just took: for example, for duty cycle of 20%, I would expect V = 1.5 V and i = 0.625 A. In reality, however, I measure a voltage around 1.1 V.

What is this due to? I thought it might be linked to the PWM frequency, but it's 3.9kHz, which sounds like more than enough!

Finally, I also made a model in Simulink to try and understand the issue, and these are the plots I'm getting:

Funny thing is, I am getting average current and voltage values much higher than they should be! Besides, why does the voltage plot vary as a "sawtooth" rather than the square PWM signal?

Thanks again!

Update 2

Right, so I think I managed to get my model right now, thank you again for the help everybody!

At this point, I think I have a fairly good model of the relationship between PWM duty cycle and current through coil.

This is my updated Simulink output for a 50% duty cycle:

Thank you again

simulate this circuit – Schematic created using CircuitLab

• Is this homework/assignment? Help is available but we must know. – Russell McMahon Dec 20 '14 at 14:26

Ideally, a high-enough-frequency PWM circuit with a perfect switch and catch diode will give you $\alpha$ times the current you'd get with 100% duty cycle (where 0$\le \alpha \le 1$ is the duty cycle ) . In this case, you've drawn the circuit as having an inductor without resistance, so the current would increase without limit.. So you need to include the DC resistance of the coil in your analysis.

Edit: Something is obviously screwed up with your model. Below is a simulation of startup from zero inductor current with good models of all the parts as you've shown, and 4kHz frequency and 50% duty cycle.

The average current is about 1.428A. The ideal prediction was 50% of 7.5V/2.4 ohms or 1.56A, however there is some loss in the MOSFET and the diode.

Your "experimental" data does not sound too far off, as I said there are losses in the diode and MOSFET (mostly the diode in this case). If you want a more ideal result you could replace the Schottky diode with another MOSFET (drive the coil with a half-bridge).

If the Schottky Vf is 330mV at 0.5A and the MOSFET has 100mV across it when on, then with 20% duty cycle the voltage the R+L will see is +7.4V when on and -0.33V when off, for an average of 0.2 * 7.4 + 0.8 * -0.33 = 1.216V, so the average current will be 0.506A, which is very close to what the simulation shows.

• Thank you very much! That makes a lot more sense now. Sorry, I am just getting started with electronics... If I replace the coil with a simple resistor, I see the correct voltage across (i.e. for 20% duty cycle, 1.5V). Is it because the Schottky diode at this point isn't really doing anything since there is no coil pushing current back, therefore always leaving it off? Thanks again. – Niccolò Zapponi Dec 21 '14 at 12:03
• If you have no coil the current is discontinuous and the diode does nothing. The idea usually is to have the PWM fast enough with the inductor that the current is not only continuous but low ripple. – Spehro Pefhany Dec 21 '14 at 13:48
• Makes sense. With a time constant for my coil = L/R = 6.25 ms, what's an acceptable PWM frequency? Is 4 kHz enough or would it be better to go higher? – Niccolò Zapponi Dec 21 '14 at 13:58
• Depends what you need. Look at the ripple in my simulation- looks pretty good for an electromagnet. Keep in mind that if you go unnecessarily high there will be switching losses and in the case of an electromagnet large eddy current losses. So I'd say to stay with a few kHz unless there is some reason to change like audible sound (3.9KHz is roughly the frequency of a human scream or baby crying so we're programmed to find it disturbing). – Spehro Pefhany Dec 21 '14 at 14:07

The average voltage is lower than you expected because back-emf causes voltage across the coil to go above Vcc when the FET switches off. The diode then conducts and limits the coil voltage to about 0.7V above Vcc, so it actually swings from +7.5V to -0.7V (not 7.5V to 0V).

If the FET is switching fully on and off then the voltage waveform across the coil should be rectangular, and the current should be nearly DC with just a small amount of triangular ripple. However your simulation plot tells a different story, perhaps due to incorrect inductance and/or insufficient Gate drive.

• The 1N5819 is a (very popular) 1A Schottky so the forward drop with 0.2 duty cycle will be closer to 330mV than 700mV. – Spehro Pefhany Dec 21 '14 at 4:11
• His Simulink graph shows the voltage reaching -0.7V, so... – Bruce Abbott Dec 21 '14 at 7:53