# PWM-controlled current source to drive a 24 V proportional solenoid valve using an Arduino

I would like to implement a PWM-controlled current source to drive a 24 V proportional solenoid valve using an Arduino.

What I need:

1. Input will be 5 V PWM with 5000 Hz frequency, duty cycle will increase the load current.
2. The solenoids I need to use have internal resistances varying between 10-25 Ω.
3. My circuit should give the same load current for ALL solenoids at an exact duty cycle.
4. My maximum load current should be 2.5 A, which means at 100% duty cycle (5 V) the load current should be 2.5 A for any solenoid I am driving (if it can draw it), so no matter the load resistance.
5. My switch has to be at the high side, and the load should be at the low side.

What I have tried so far:

1. Even though I need my load at the low side, I tried implementing this circuit by inputting my PWM from Vin to see if it gives a specific current for any solenoid I use at a certain duty cycle, as I thought the shunt resistor and op-amp would create the current no matter the load, but it did not work for me, the load resistance is still effective, so for example at 50% duty cycle Solenoid 1 is drawing 500 mA and Solenoid 2 can still draw 1 A, so the current is not the same for ALL solenoids at a certain duty cycle as I desired.

1. I also tried the following circuit, which is similar to the previous one, but the load resistance is still effective. Again, this switch is low-side too, but I thought I could translate it to the high side if it worked.

1. I also tried the circuit below, but here it is not clear to me what to do with the op-amp's output. Do I read it from another pin and compare my PWM output and the reading and change my PWM accordingly in software?

1. And lastly, I tried the circuit below, which is similar to the third circuit, but the solenoid's and shunt resistor's places are different. The result is similar as the third; I am not certain about what to do with the op-amp's output. I think this one is the closest one out of all to what I want, because the switch is high-side, and the shunt resistor is between load and ground.

For all the circuits above, I chose resistor values to create such gain that 100% duty cycle 5 V PWM input would translate to 2.5 A load current. But for every one of them, load resistance was effective, the load current was not the same for a certain duty cycle.

Any help would be appreciated. Thank you already.

EDIT#1: Instead of getting the same current on all loads at a certain duty cycle, I guess the duty cycle should be changed accordingly to get the same current on all loads, by sensing the current on the shunt resistor and feeding it back. But the maximum should still be 5 V input for 2.5 A Iload

EDIT#2: I guess what I need is a current limitting PID loop, any help?

• NB : First schematic, driving gate of IRF540 with a 10kOhm is not "really" good, especially if your inputs a PWM (should be 10 Ohm). May 19, 2022 at 11:42
• @Antonio51 I think it's meant the input is a PWMDAC (i.e. MCU output --> VREF switch --> filtered PWM) and so the circuit is analog (op-amp, not comparator or driver). Note that the first two circuits are analog/linear so will dissipate up to half the output power, (24V * 2.5A)/2 = 30W. A heatsink is required. May 19, 2022 at 12:31
• @norbel: note that 2.5A requires R <= (24V / 2.5A) = 9.6 ohms, so exactly zero of your specified range will fully satisfy your current range requirement. I suggest looking at the solenoid datasheets to determine what actual voltage and current range they require. May 19, 2022 at 12:32
• @TimWilliams Ok. Agree also for the power dissipated in analog behavior. May 19, 2022 at 12:39
• You would need a supply of 65V or so minimum to reach this goal with PWM. May 19, 2022 at 13:00

There are cheap boost converter chips to drive LED strings with constant current. They have PWM inputs to set the target current and some support grounded LED connection. This would be an energy efficient way to control your valves and cover all requirements. If you can use more than 24V supply voltage, a buck converter offers more options and there are more on the market. Can your 25 Ohm valves accept 2.5A at all?

• hello, no 25 ohm valves won't accept 2.5A but for future valves with less resistance I have to implement maximum 2.5A May 19, 2022 at 17:39

Here is what happens when driving resistor (your R1, first picture) is too big ...
R1=10k -> magenta curve. Not very usefull and dependent of the value of load (my R3).

The DC analysis seems however correct, Note that this is "analog" behavior.

Here is the case when my R2 = 10k and R3 varies from 1 to 24 Ohm (stepping x2). Sorry, little text error in picture.

Same but R2=100 Ohm.

This case for load wired directly to ground. Not tried with PWM, ONly DC Dynamics.
A "translator" for command voltage is been used. (0..5A -> 0..5V to 24V..19V).

• thank you, its just the circuit from the link, I typically use 100 ohm as gate resistor works just fine, yes 10K is high May 19, 2022 at 12:37
• Is the input, pure only PWM ? Or filtered as @Tim Williams pointed in his comment ? May 19, 2022 at 12:42
• input is only PWM May 19, 2022 at 12:43
• NB: I did not try the last picture with PWM. Load is wired directly to ground. May 19, 2022 at 13:33

You can try using the motor driver from Texas Instruments. For example, the DRV8873H (or DRV8873S).
Why did you come up with 5kHz? I always thought that the suitable frequency for these proportional valves should be 200-1000Hz