# How Can I Design a Digitally Controllable Constant Current Source?

• HHOboy
In summary, the design is for a digital constant current source with a digitally controllable range of maximum current outputs. The input voltage range is 9 to 14 volts. The current source would be able to be turned on and off fairly rapidly (40Hz) via a digital signal. However, there is a problem with the use of a digital potentiometer in the circuit and testing has shown that resistance of the load resistor has a large impact on the current that is drawn, resulting in a current to level smaller than the current sources level.
Lexilighty said:
right not pin 2 to GND is 0.288V when pin 3 to GND is 1.652V (RIO is also 1.652V). I have probably lost the opamp. I also get a very hot valve afterwards.
How hot is the mosfet to touch? To be technical, does it "fry spit" ?

0.288 volts/7.4ohms = only 0.038 amps , so if excessive current is going through valve it isn't making it to R1.
Might you put DMM set for ammeter in series with valve ?
and with R1 of only 7.4 ohms
wouldn't 165 ma give voltage of 1.221 ?

Indulge my curiosity
RIO calling for 1.221
meter negative on your AGND where they all tie together (at RIO?)
Volts at OUT/bottom of solenoid valve =
Volts at top of R1 =
Volts at opamp pin2 (-in)=
millivolts at physical bottom of R1 = not at RIOgnd, am looking to measure millivolts along the wire from R1 to AGND
millivolts at 0V side of 24 volt supply = right at the supply not at RIO gnd same reason looking for millivolts along that wire
millivolts at opamp V- terminal pin11 = right at opamp same reason

Also have you scanned that current schematic ?

Hang in there - this is typical of prototyping.

jim hardy said:
How hot is the mosfet to touch? To be technical, does it "fry spit" ?
Brutally hot.

#### Attachments

• P1030535.JPG
43.4 KB · Views: 491
• P1030536.JPG
43.6 KB · Views: 544
• P1030540.JPG
31.6 KB · Views: 543
• P1030542.JPG
43.8 KB · Views: 491
• P1030543.JPG
42.4 KB · Views: 538
• P1030532.JPG
17.8 KB · Views: 554
RIO volts now between 1.189V (=165mA) and 0.724V (=100mA) solenoid requirement as set resistor is now 7 ohms.

jim hardy said:
meter negative on your AGND where they all tie together (at RIO?)
Volts at OUT/bottom of solenoid valve =
15.17V

jim hardy said:
Volts at top of R1 =
15.16V

jim hardy said:
Volts at opamp pin2 (-in)=
15.17V

jim hardy said:
millivolts at physical bottom of R1 = not at RIOgnd, am looking to measure millivolts along the wire from R1 to AGND
15.15V ( I smell the rat)

jim hardy said:
millivolts at 0V side of 24 volt supply = right at the supply not at RIO gnd same reason looking for millivolts along that wire

jim hardy said:
millivolts at opamp V- terminal pin 11 = right at opamp same reason

15.15V

Something weird is definitely going on. Again, thanks for your probing intellect.
I tried measuring MOSFET gate-source resistance, I have 71.9 ohms, drain - source = 3.86K, gate-drain = 4K.

Opamp resistance with all power off:
Pin1 to 11 =159K
Pin2 to 11 7.4 =ohms
Pin 3 to 11 1=58K
Pin 4 to 11 = 9.82K

Hmm why do we keep killing mosfets and amps ?

i hope your schematic is wrong..

1. Diode goes in parallel with valve not in series
cathode to +24 side
anode to OUT side
you can solder it to the wires or put it on breadboard your choice
why does diode go that way??
'cause when mosfet tries to stop current, inductor tries his best to keep it flowing.
As shown, he tries to force it through Mr Mosfet and a modest inductor can make kilovolts.

had to close and reopen window to post above
and system only got half of it
very strange

here it is again
----------------------------------------------------------------------------------------------------

Hmm why do we keep killing mosfets and amps ?

i hope your schematic is wrong..

1. Diode goes in parallel with valve not in series
cathode to +24 side
anode to OUT side
you can solder it to the wires or put it on breadboard your choice
why does diode go that way??
'cause when mosfet tries to stop current, inductor tries his best to keep it flowing. He makes his bottom terminal more positive than his top one (Lenz's Law)
As shown, that'd force current down through Mr Mosfet, and a modest inductor can make kilovolts in order to do that.
Moving the anode to bottom of solenoid let's solenoid instead push current around himself thru diode and it flows in that circle until the inductive energy is dissipated. He only has to make 0.6 volts to do that.

2. I trust the capacitor shown in series with pin 3 is mis-drawn. Else it could never have worked.
Pin 3 goes of course to your RIO's voltage divider. Capacitor from junction of pin3-RIOVref to gnd.

Will post this now, don't want an edit timeout.
looks like i got one any way this is extremelyy frustrating
hope next one goes smoother

Good job on those voltages ! Clearly R1s bottom isn't reliably connected to gnd and neither is amplifier common. That happens sometimes with those push in terminals... intermittents are hideous to troubleshoot.

looks like current could be returning to your RIO's +15 supply through opamp.
might put1k between top of R1 and pin 2, and 1k between pin1 and mosfet gate... to protect RIO.

mosfet gets really hot? heatsink needs to be about 1 square inch per watt... it'll see a watt at 100 ma...

it worked for a while , we'll spiral in on what changed.

jim hardy said:
cathode to +24 side
anode to OUT side
I clearly played that wrong, didn't I?

jim hardy said:
Moving the anode to bottom of solenoid let's solenoid instead push current around himself thru diode and it flows in that circle until the inductive energy is dissipated. He only has to make 0.6 volts to do that.
This is so beautifully explained. I read this in high school physics some 17 years ago but it has clearly slipped. You have such a sharp edge!

jim hardy said:
2. I trust the capacitor shown in series with pin 3 is mis-drawn. Else it could never have worked.
Pin 3 goes of course to your RIO's voltage divider. Yes! I got a 10K resistor in there. Sorry I somehow omitted this. Will redraw the circuit morrow morning and have it all together. Capacitor from junction of pin3-RIOVref to gnd. Yes, you are right. The circuit was hastily put together. The other leg of the cap is grounded.

jim hardy said:
might put 1k between top of R1 and pin 2, and 1k between pin1 and mosfet gate... to protect RIO.
Will implement this tomorrow. Again, I am so grateful for your valued expertise. I am learning great from you!

Lexilighty said:
I am learning great from you!
no, you're learning by doing.

i feel bad about all the trouble. But it demonstrates the difficulty of conveying ideas accurately by just words..

When we're done I'm going to point you toward Lavoisier's "Introduction to Treatise on Chemistry"
which speaks at some length to that. (i use him a lot) "Science is but language well arranged"..

old jim

dlgoff
I have everything together on a prototyping board now and I have equal voltages at pins 2 and 3 wrt GND = 1.452V when RIO max is 1.652V. 1.2K resistor sits between RIO input and pin 3 (discovered the previous 10K I had there before failed when I measured its current this morning: was reading 16K!). V+ supply of opamp is 15V from RIO and +24V supply is interfacing with inductive load and OUT of drain. But my load is not turning on. I kept hearing buzzing sounds but no opening of valve. SO I put DMM on OUT and V+ of power supply and it reads 15V! I take this to mean the voltage of the V+ on opamp since gate of MOSFET and Pin 1 of opamp both read same volts of 5.9V. Mosfet seems ok. Voltage drop across R1 is also 1.452V and circuit seems perfect.
I am operating from a +24V supply so I turned up voltage to +30V to see if I'll get any changes but nope!
So I went back down to 24V, turned up inductor and I discovered another 15.72V drop across the load. When I disconnect the load however, I get 24V through it. Wondering what could be wrong!

Okay. I tested the circuit with my other spare valve and I realize that other one now responds to proportionality with same circuit. But the first one I've been using along would not any longer. It still opens up at full voltage across its coils though. Could it be I have lost the first valve?

Lexilighty said:
But my load is not turning on.
I guess by "load" you mean the air ?

Lexilighty said:
+24V supply is interfacing with inductive load and OUT of drain
Interfacing ? not sure what you mean.

Lexilighty said:
But my load is not turning on. I kept hearing buzzing sounds but no opening of valve.
hmmm remember that line in valve datasheet about voltage may give fluctuations...
buzzing could be the valve oscillating.

See if does the same when you call for midrange air, 130 ma or so

Lexilighty said:
SO I put DMM on OUT and V+ of power supply and it reads 15V!
that says there's about 15 volts across valve, meaning you have about 100 ma through valve?
When it is doing that and buzzing switch your meter to ACvolts , if valve is oscillating you'll read substantial AC.

Lexilighty said:
Okay. I tested the circuit with my other spare valve and I realize that other one now responds to proportionality with same circuit. But the first one I've been using along would not any longer. It still opens up at full voltage across its coils though. Could it be I have lost the first valve?
Could be it's got overheated and damaged. But that it opens at full current says it's worth further investigation.
Can your RIO be programmed easily to step current from 100 ma to max in 10 ma steps, then back down?
If so try that . Valve might have a piece of dirt in it or something that's making it sticky.
Repeat that test several times being observant for clues.
Does it suddenly leap open at full current?
Is there some range of current that makes it buzz?
Is 24 volt supply staying constant?
How's heat on that Mosfet ?

posting this so as to avoid timeout

stability problems can be tricky.

Lexilighty said:
gate of MOSFET and Pin 1 of opamp both read same volts of 5.9V.
good deal .
Observe from mosfet datasheet http://www.vishay.com/docs/91015/sihf510.pdf
line "Gate-Source threshold voltage" he's allowed 4 volts to start conducting
and from curve 3, typical transfer characteristics, gate voltage goes up with temperature. That's why i asked how hot he's running.

your 1.452 at top of R1 (which is mosfet source terminal) plus 4 volts makes ~5.5 volts so we're passing sanity checks now.

How much air pressure do you have to this thing?
I notice from curve on page 687 of valve datasheet " PQ30 1.6mm orifice flow vs dp " that at 30 psi flow won't start until about 140 ma

jim hardy said:
I guess by "load" you mean the air ?
I meant solenoid valve.

jim hardy said:
Interfacing ? not sure what you mean.
Connected. Eternal vigilance, eh?

jim hardy said:
that says there's about 15 volts across valve, meaning you have about 100 ma through valve?
Nope, valve is operating at full voltage (1.65V) and resistor is now 10 ohms. I am attaching schematic and circuit layout down here.

jim hardy said:
Does it suddenly leap open at full current?
Yep!

jim hardy said:
Is there some range of current that makes it buzz?
Full current, I have observed.

jim hardy said:
Is 24 volt supply staying constant?
If you mean the 24V of power supply,. I bet he is.

jim hardy said:
How's heat on that Mosfet ?
Fairly okay for now. I've not noticed any hotness on the heatsink plate.

jim hardy said:
and from curve 3, typical transfer characteristics, gate voltage goes up with temperature. That's why i asked how hot he's running.
The temperature is fairly ambient or below ambient based on what I observe when I touch the heatsink.

jim hardy said:
How much air pressure do you have to this thing?
I am doing between 0 to 24 psi for moving air through the valve.

#### Attachments

• P1030549.JPG
18 KB · Views: 507
Great job on that schematic.

Lexilighty said:
I am doing between 0 to 24 psi for moving air through the valve.
Okay...
take a look at valve data sheet
http://content.smcetech.com/pdf/PVQ.pdf
page 686 chart 1 is the transfer curve for your valve which by part# has 1.6mm orifice
would paste it if i could
it shows four different curves, one for each of four pressures
Curve D is for 0.2 mpa which i think is 29psi.
Observe valve doesn't begin to open until 140 ma at 29 psi
and at lower pressure, even higher current
So with discrete current steps of 20 ma , that'd sure resemble a "leap" at the last step.

Now i don't know if that's what is happening
but it deserves a look.

That the two valves behave differently suggests they have different internal friction

now go to page 684, section " working principle "
cutaway drawing of PVQ30
coil and core make an electromagnet that pulls UP on the armature to open the valve.
Armature is pulled down by gravity and pushed down by spring.
That's the balance that determines how far the valve is open, electromagnetic pull vs gravity and spring.
Almost.
There's one more UP force:
incoming air pressure underneath that black valve disc pushing up.
That's why it opens at different currents for different pressures.
Clearly the designers chose spring and area of orifice carefully to balance all the forces. That's what valve designers do.

If you take it apart don't be surprised if the disc is not flat on bottom but has a Cyrano deBergerac "nose" protruding down into the incoming air passage. I don't know if it will but that's a trick used on giant steam valves.

And that "up" force from air is why it could be unstable if current isn't controlled with authority. But we'll get to that later on.
For now, check very carefully those two valves... time how long it takes each to fill a garbage bag or balloon with air at known pressure and current. More air pressure will give more consistent results, as indicated by that family of curves on page 686.

Does this make sense ?

Objective now is to resolve difference in the two valves.
If it were mine and it indeed proved sticky, i'd consider cleaning it with rubbing alcohol or something. Don't use tap water it's too dirty. Microscopic grit in the sliding surfaces will be deadly.
Follow with a half hour air blow dry, half current to warm it.

See precaution about temperature, it should be kept below 100C.

What do you think ?

old jim

Last edited:
jim hardy said:
What do you think ?

I think whatever you're taking, I want ALL of it! You are darn good!

I will try isopropyl alcohol on it tomorrow morning as I have none of that with me right now.

Lexilighty said:
I will try isopropyl alcohol on it tomorrow morning

first try a little more air pressure...

thanks for the kind words, but your success is due your good observations and your perseverance .

Last edited:
Yeah, after flushing for 30 minutes with air (this was after I had rinsed with isopropyl alcohol), I turned on the bad valve at 165mA and I hear a humming sound. Measured the DC Volts across OUT and +24V (which is constant btw, and I notice 17.41V DC and 4.351V a.c. Valve would not turn on. But when I apply 24V from power supply straight across its terminals, I can move air through it.
MOSFET is not hot. Just mildly warm.

Last edited:
Lexilighty said:
Meaured the DC Volts across OUT and +24V (which is constant btw, and I notice 17.41V DC and 4.351V a.c. Valve would not turn on. But when I apply 24V from power supply straight across its terminals, I can move air through it.

hmmm solenoid will open if pulled hard enough.

Humming might be solenoid just dancing on bottom, relieving a little air with each bounce.

If your dmm has a frequency button see if you can get a number for that 4VAC.
120hz is power supply, something else low is likely solenoid's natural frequency.Does more air pressure straighten it out ?
How about cycling it a hunfdred times - is RIO programmable enough to handle FOR-NEXT loop ?
That diode in parallel with coil -see if making it into a diode plus 30 ohm resistor changes it.

Valve may be a candidate for post-mortem analysis.

17,41/165 = 105 ohms

does DMM agree ?
What's other valve read by DMM ?

Low resistance is indicative of shorted turns in coil.
Result of overheat probably.

jim hardy said:
Does more air pressure straighten it out ?
I note that at higher air pressures, the valve will not open beyond 23-ish psi when i put 24V across its terminals.

jim hardy said:
17,41/165 = 105 ohms
Nope. DMM says its infinite impedance. Probably explains why armature is not lifted.

With 24V across it and at any pressure more than 20psi, it will not open up. It opens with full 24V below 20 psi.

Something interesting I have just noticed, by reversing the direction of air inlet, valve works beyond 20 psi with 24V across it. This is somewhat stated in the manual ( I just stumbled upon it this morning that pressure should be applied on the P1 port.

Yes! Valve now works with proportionality. The trick was in the reversal of the inlet/outlet port.

Page 695 of Valve sheet:

Caution
When the product is used in vacuum, apply vacuum pressure to A(2) port.
The pressure at P(1) port should be larger than the pressure at A(2) port.

Science is but language well-arranged!

Last edited:
great news
Lexilighty said:
Nope. DMM says its infinite impedance. Probably explains why armature is not lifted.
We ought to solve that mystery. Which valve was that, working or not working ?

Lexilighty said:
The trick was in the reversal of the inlet/outlet port.
That's in interesting observation
Look at cutaway drawing on page 692
pressure on port P(1) pushes UP on armature with force PP(1) X area of that middle part of disc covering P(1), call that area AreaP(1).
pressure on port A(1) pushes DOWN on the armature with force PA(1) X (area of armature - Area(P1))

net force on armature from air is difference of those two forces

you now have a number for milliamps to overcome that force at one pressure. It'd be fun to plot ma to just overcome backward dp vs pressure

Observe they chose direction of flow so increasing pressure across valve pushes it further open
which reduces pressure across it
helping it be stable
Backward pressure helps it be unstable - might that be the buzzing you heard?
\

Does the bad one read any ohms to its metal case? That'd confirm it's shot

Great news there Lex

you done good my friend !

Last edited:
jim hardy said:
Observe they chose direction of flow so increasing pressure across valve pushes it further open
which reduces pressure across it
helping it be stable
Backward pressure helps it be unstable - might that be the buzzing you heard?
\
Again, great analysis!

jim hardy said:
Does the bad one read any ohms to its metal case? That'd confirm it's shot

I will check this on Sunday/Monday and revert to you. I have since left the lab.

I promised you a pointer to an interesting essay by Lavoisier

i stumbled across it in a library book and it affected my life. I kept a copy over my desk for decades.
here it is:
http://web.lemoyne.edu/giunta/EA/LAVPREFann.HTML

last paragraph:

the sciences have made progress, because philosophers have applied themselves with more attention to observe, and have communicated to their language that precision and accuracy which they have employed in their observations: In correcting their language they reason better."

Two paragraphs prior is an outrageously funny observation that you'll see demonstrated aplenty over the course of a career.
It begins "Instead of applying observation to the things we wished to know..."
Be careful how you use it around work for some don't like their foibles to be pointed out

I hope you enjoy him as much as i have.

old jim

Thanks a lot for the reference. I will look through it.
Back to your former question, the valve still gives proportionality but I am still reading infinite impedance across it.

Lexilighty said:
Back to your former question, the valve still gives proportionality but I am still reading infinite impedance across it.
well that's curious
it's certainly not open if it responds to current
some dmm's don't like to measure inductive loads
try a couple different scales?

of course you're measuring valve out of circuit
and you checked that your dmm reads less than an ohm when you short its own leads..oh well, you'll find it.

time to move on to making this thing do what it's intended to do - measure and control air flow?

I had fun, hope you did too ... and CONGRATULATIONS AGAIN !

keep us posted on your progress ?

old jim

jim hardy said:
well that's curious
it's certainly not open if it responds to current
some dmm's don't like to measure inductive loads
try a couple different scales?

of course you're measuring valve out of circuit
and you checked that your dmm reads less than an ohm when you short its own leads..
Yes, you are right. It does work. I tried with a different DMM and this has been confirmed.

jim hardy said:
time to move on to making this thing do what it's intended to do - measure and control air flow?
Yes, now onto the control design for my pneumatic system.

Thanks a lot for your help. I hope our paths continue to cross and cross. :)

#### Attachments

332 bytes · Views: 576
jim hardy
Lexilighty said:
I hope our paths continue to cross and cross. :)
me too.

Lexilighty
Hey Old Jim,

Trust you are well. I am designing a variable voltage source, this time for a different proportional pneumatic valve that takes voltage between 0 to 30V and max current of 400mA. Specifically, this is for the Dakota Instruments valve with parts number 6ASV0105. The data sheet is https://www.dakotainstruments.com/d...al_6apsv01_proportionating_solenoid_valve.pdf.

Please do let me know if you have any pointers on how I can go from here.

Lexilighty said:
lease do let me know if you have any pointers on how I can go from here.
Hi Lex

i have a big project underway, had the yard all dug up, and made a trip out of town as soon as we covered the trenches. Unanswered mail is waist deep. I had to pretty much set everything aside for a couple weeks.

Will take a look at your project this evening

old jim

Replies
20
Views
6K
Replies
6
Views
6K
Replies
7
Views
2K
Replies
19
Views
4K
Replies
2
Views
1K
Replies
11
Views
2K
Replies
5
Views
2K
Replies
31
Views
4K
Replies
15
Views
8K
Replies
7
Views
2K