# PWM - Average current

#### Gorden

Joined Oct 30, 2019
19
Hello,

I am trying to put a circuit together to operate a solenoid valve using PWM 25kHz, 50% duty at 12V.
I have built a couple of really basic circuits to test this, the first uses a 12V bench supply driving the solenoid (12V 5W 450mA) via a VN1NV04PTR MOSFET on the low side. The MOSFET is driven by a PIC. ( I have used this MOSFET because I wanted the protection features)

The PIC drives the solenoid at the full 100% duty for 1 second (just so I can see what's going on would be shorter normally), then drops to the 50%.

I have also connected a 1R resistor in series with the output of the +12V supply to measure the current via an oscilloscope.

My reason to do these tests is that I want to see the peak current pulses and look at ways to average this, for example I want to use a small SMPS mains converter, that is rated less than the 450mA the solenoid will require at 100%, as it's running at 50% duty.

My issue is this:- When I measure the voltage pulses across the valve using an oscilloscope, I can clearly see just under 12V 100%, then 12V 25Khz 50%, so my assumption is the valve is fully switched on. However when I measure the voltage drops across the 1R, I again can see the same, but the voltage drop is only 250-300mV, this is lower than expected.

I have tried multiple power supplies and MOSFET's and also compared it with a DRV103, the results are identical. So I guess I am not understanding the averaging that is already taking place.

I need to be able to measure/understand this as I want to use the smallest power supply taking into account the average current not the peak current. I figured I would need to put a capacitor say 470uF across the supply to provide the energy required during each pulse, to smooth this, but if I can't measure it correctly I won't know if I have it correct.

If anyone can help me with understanding this I would be grateful.

Thanks.

#### Tonyr1084

Joined Sep 24, 2015
5,258
We'd need more information on your solenoid valve. I always thought they were either OPEN or CLOSED. I don't think it's possible to have a solenoid valve half open.

Also, since a solenoid valve is magnetically opened (or closed) the magnetic resonance of the valve will likely come into play. Leading to the question "Can a solenoid valve operate that fast? (25KHz)" The magnetic field probably can't break down that fast, meaning the valve would still be 100% opened. You may need to rethink the valve you want to use and the manor in which to moderate the degree in which it's open. Have a look at Idle Air Control Valves (IACV) in cars. Some are mechanical, in which they drive a screw open or closed to maintain a particular idle condition. Others use a vain that swings open or closed against a spring based on the amount of current driving them as controlled by the PCM (Power Control Module) (a.k.a "The Computer").

#### Gorden

Joined Oct 30, 2019
19
Thank you Tonyr1084,
The solenoid is a valve, and it is normally closed, when the initial charge is applied to the solenoid, this pulls the armature in, the PWM signal holds the valve open at a lower "Average" current. The function works fine, my problem is understanding why I am not measuring what I expect, i.e. 50% of 450mA across my 1R resistor.

Thanks

#### Alec_t

Joined Sep 17, 2013
11,752
However when I measure the voltage drops across the 1R, I again can see the same, but the voltage drop is only 250-300mV
That's the correct long-term expected value at 50% duty cycle. Don't forget the inductor current takes some time to rise and fall.
Presumably you have a catching diode across the solenoid coil?

#### BobTPH

Joined Jun 5, 2013
2,601
The solenoid is an inductor, the 25 KHz PWM frequency is way too high, the inductance is dominating the impedance and reducing the current too for it to operate. Try a 100 Hz or so PWM signal.

Bob

#### Alec_t

Joined Sep 17, 2013
11,752
I agree 25kHz seems a tad high. The few proportional solenoid valves I've researched have typical PWM frequencies ~700Hz.

#### Gorden

Joined Oct 30, 2019
19
Thankyou All,
Just for testing I have a 1N4002 across the solenoid.

BobTPH,

The solenoid is actually working just fine at this frequency, it's just that I was not getting the expected current across 1R. Decreasing the frequency, although still working, reduces the current across the 1R further.

It seems the MOSFET is fine, the function is fine, I just need to be able to calculate / simulate the solenoid inductance to prove that the average current drawn from the power supply will be within it's ratings.

#### crutschow

Joined Mar 14, 2008
25,680
I can clearly see just under 12V 100%, then 12V 25Khz 50%, so my assumption is the valve is fully switched on. However when I measure the voltage drops across the 1R, I again can see the same, but the voltage drop is only 250-300mV, this is lower than expected.
At 50% duty-cycle the average voltage across the solenoid is 6V.
At 25kHz, with the inductance of the solenoid, you would thus see 50% of the 12V current or 225mA, which appears to be about what you are seeing.
Why do you think it's lower than expected?

#### Gorden

Joined Oct 30, 2019
19
I have not been taking the inductance of the solenoid into account correctly.

I think what I should be asking is, how can I calculate the effect of the inductance at different frequencies? Or what would the correct method be to determine the best frequency.

This application is not for a proportional valve - it's just an open/close valve, reducing current by lowering the average current.

Thanks

#### crutschow

Joined Mar 14, 2008
25,680
how can I calculate the effect of the inductance at different frequencies? Or what would the correct method be to determine the best frequency.
The current will increase and decrease during each PWM cycle as determined by the time constant τ = L/R where L is the solenoid inductance and R is the solenoid resistance.
From that you can determine the minimum PWM frequency as determined by how much ripple current in the solenoid you can tolerate (which can generate noise, so the exact value is somewhat arbitrary).

You can calculate all that, of course, but it's easiest to do a Spice simulation to determine the solenoid ripple current.

If you don't know the solenoids inductance, you can determine it by suddenly applying a voltage to it, and measure the current rise-time through the series resistor with your oscilloscope.

Joined Jan 15, 2015
5,667
Do you have a link to the solenoid valve you are using? You are sure that the valve is a proportional type solenoid valve? Not a standard On/Off type solenoid valve? A simple standard On/Off valve will have a pull in and drop out voltage.
"The pull-in voltage is the minimum voltage at which the solenoid valve can be energized. The drop-out voltage is the one below which the solenoid valve is no longer energized. The value for power is given in [volt ampere] at inrush and holding at 20°C ambient".
So with a 100% duty cycle PWM the valve body can pull in (energize) and as the average voltage is dropped the valve orifice will remain 100% open till the drop-out voltage at which point the valve is de-energized. This is where a good link to your specific valve's data sheet would come in real handy.

Ron

#### TeeKay6

Joined Apr 20, 2019
572
Do you have a link to the solenoid valve you are using? You are sure that the valve is a proportional type solenoid valve? Not a standard On/Off type solenoid valve? A simple standard On/Off valve will have a pull in and drop out voltage.
"The pull-in voltage is the minimum voltage at which the solenoid valve can be energized. The drop-out voltage is the one below which the solenoid valve is no longer energized. The value for power is given in [volt ampere] at inrush and holding at 20°C ambient".
So with a 100% duty cycle PWM the valve body can pull in (energize) and as the average voltage is dropped the valve orifice will remain 100% open till the drop-out voltage at which point the valve is de-energized. This is where a good link to your specific valve's data sheet would come in real handy.

Ron
See post#10: "This application is not for a proportional valve - it's just an open/close valve, reducing current by lowering the average current. "

#### Gorden

Joined Oct 30, 2019
19
Thank you all.

Crutschow - thank you, this is the answer. I understand that the frequency has to be enough to keep the solenoid fully charged without ripple, not so sure what the effect of going to high would be. As the frequency is reduced, the coil ripple is greater, although fitting a 1000uF capacitor across the supply (after the 1R) smooths this out completely. So it seems a combination of frequency setting, and input filtering will get me there.

I think it's time to invest in some simulation software...

#### kubeek

Joined Sep 20, 2005
5,734
I think it's time to invest in some simulation software...
Just go download the free LTspice, a lot of people here use it.

#### Alec_t

Joined Sep 17, 2013
11,752
I just need to be able to calculate / simulate the solenoid inductance
Note that the inductance with the armature pulled in is greater than when the armature is extended.

#### Tonyr1084

Joined Sep 24, 2015
5,258
"This application is not for a proportional valve - it's just an open/close valve, reducing current by lowering the average current."
So just use an appropriate wattage sized resistor in series with the valve. You'll have to determine what current you want and from there whether the valve will operate on that current.

#### Gorden

Joined Oct 30, 2019
19
Tonr1084,
Would that not just waste power through the resistor?

#### Tonyr1084

Joined Sep 24, 2015
5,258
The resistance (or impedance) of the coil is X. At a given voltage you're drawing so many amps (or milliamps). To add resistance means to reduce current. Yes, some is wasted as heat, but overall, you're using less current.

Last edited:

#### Tonyr1084

Joined Sep 24, 2015
5,258
Example: Suppose your coil is operating at 120 VAC. And your coil is 240Ω. 120V ÷ 240Ω = 0.5A. 120V x 0.5A = 60 watts.

Now, suppose you add an extra 100Ω resistor in series. 120V ÷ 340Ω = 0.353A (353 mA). 0.353A x 120V = 42 watts.

Keep in mind these numbers are just made up off the top of my head. You'd need to substitute actual values to come up with the correct wattage. However, I would expect that a solenoid that operates on 1/2 amp will still operate on ~1/3 amp.