I would like to implement a PWM-controlled current source to drive a 24 V proportional solenoid valve using an Arduino.
What I need:
- Input will be 5 V PWM with 5000 Hz frequency, duty cycle will increase the load current.
- The solenoids I need to use have internal resistances varying between 10-25 Ω.
- My circuit should give the same load current for ALL solenoids at an exact duty cycle.
- 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.
- My switch has to be at the high side, and the load should be at the low side.
What I have tried so far:
- 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.
- 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.
- 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?
- 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?