How Can I Design a Digitally Controllable Constant Current Source?

Click For Summary
The discussion focuses on designing a digitally controllable constant current source with a range of 0.25mA to 2mA, using an input voltage of 9 to 14 volts. Initial attempts with an LM317 and a digital potentiometer were unsuccessful, leading to the exploration of an LM334 and op-amp circuits. Participants suggest using a DAC for better current control and emphasize the importance of ensuring the digital potentiometer operates within its current limits. Issues with input bias current in op-amps were identified, with recommendations to provide a DC path to stabilize the circuit. The conversation concludes with successful prototyping using an analog potentiometer and plans for further refinement.
  • #31
In addition to the above, I have an L298N dual H-bridge (http://www.ebay.com/itm/like/231419432905?lpid=82) with datasheet here: https://www.sparkfun.com/datasheets/Robotics/L298_H_Bridge.pdf.

I tried PWM on the outA to the valve last week but was not much successful. I could only achieve full on or full off scenario with those. I realize this might not be contributing to the conversation but I have a hunch I could control output current with this dual bridge since its datasheet says a related stuff about using it to control solenoid valves in the intro.
 
Engineering news on Phys.org
  • #32
Oops, I am just reading Old Jim's reply. Yes, I actually ordered the LM324 opamp yesterday. My question about this op amp is can it do up to 165mA load on its output?
If so, are you suggesting I use it to replace the AD8510 or OP1177 in the figures in MBG's post?
Thanks, Science Advisor! :)
 
  • #33
Lexilighty said:
My question about this op amp is can it do up to 165mA load on its output?

no, check its datasheet. There exist opamps that can deliver such current but they're expensive. I used LM12's, good for 8 amps, when they were only about $20 but last time i looked they'd gone up to over $80.

Lexilighty said:
If so, are you suggesting I use it to replace the AD8510 or OP1177 in the figures in MBG's post?

It'd replace the OP1177 .
Read up on that National Instruments computer you're using. If it has analog out,
then see fig 2 here, from that Analog device MBG linked: http://www.analog.com/static/imported-files/circuit_notes/CN0151.pdf
Do you see that the opamp is connected as a follower that will make 100milliamps per volt applied to pin 4 three? That stout FET handles the current for it.
 
Last edited:
  • #34
Oh yeah cool. I will be trying this out in the next few days when my order arrives. Once again, thank you!
 
  • #35
I think it was meBigGuy who solved this one.

If that National gizmo has its own internal DAC to make analog out , your task is simplified a lot.

I hope you'll keep us posted.
 
  • #36
I only picked the I2C device because it happened to be the first one that came up when I searched for high-current DAC and looked at google images. (my favorite method for finding circuit solutions)

Here is another one
http://cds.linear.com/docs/en/datasheet/3092fb.pdf can be controlled by a DAC, and can be paralleled (rated at 200ma max, 40V).
103_circuit_1.jpg


You will need to determine power dissipation though. Read the application section of the data sheet.

Building a PWM based variable source with an H bridge assumes you switch it on and off at a high rate (say 100Khz) and the duty cycle controls the average current. (you switch at a rate that is too high for the solenoid to respond to)
This becomes very efficient since you don't have to linearly dissipate all the power to drop the voltage. But, for 160ma max at 24V it probably is not worth the trouble.
 
Last edited by a moderator:
  • #37
meBigGuy said:
Building a PWM based variable source with an H bridge assumes you switch it on and off at a high rate (say 100Khz) and the duty cycle controls the average current.
Yes, I know.

meBigGuy said:
(you switch at a rate that is too high for the solenoid to respond to)
Okay.
meBigGuy said:
This becomes very efficient since you don't have to linearly dissipate all the power to drop the voltage

are you speaking of the LT3092 here?
meBigGuy said:
But, for 160ma max at 24V it probably is not worth the trouble.
I do not get this.
 
  • #38
The LT3092, or any other linear current source must dissipate some power in order to drop the voltage to a point where the correct current flows.

Let's say your load is constant resistence, 160ma at 24V. That means it is 150 ohms. When you drive it at 160ma, there is (theoretically) 0V across the source driver, so the source driver is dissipating 0 watts. The load is dissipating 3.8 watts. When you drive it at 80ma, there will be 12V across the source device, and 12V across the load meaning the source device is dissipating 0.96 watts.

If the source device is PWM, it is either fully on, dissipating little power, or fully off, dissipating 0 power, or switching between, dissipating some power. One major reason for using PWM is the reduced pwer consumption in the switching device. But, at your low power levels it probably is not worth bothering with.

But, that aside:

For any LT3092 application (or any other control device) you need to determine the maximum power consumption and from that, and the spec sheet, determine whether you need a heat sink. In the example in the LT3092 datasheet, there is this:

TJ = 50°C + (1.02W • 30°C/W) = 80.6°C which shows that for 1 watt and a 50C ambient in a DFN package (with the stated amount of copper and vias), the junction temp. will be 80.6C

You always have to deal with power dissipation issues in linear devices. Note also that you must consider the worst case resistance of your load device and max voltage of your supply. Designers often calculate with typical values and have issues.
 
  • Like
Likes Lexilighty
  • #39
Hi Jim, I got my component from digikey over the holiday but the components are not friendly to work with especially the current multiplier NTE4153. The AD5446 and AD8510 ICs are really small SOC and I cannot start enlarging this components via some component amplification now. Is there a way I can work around this with the LM324 IC and some other readily available power mosfets that can do the current multiplication?
I am running out of time.
 
Last edited:
  • #40
Well, back to figure 2 here:
http://www.analog.com/static/imported-files/circuit_notes/CN0151.pdf
LM324 instead of the OP177 using correct pins of course
and you're in luck the 324 doesn't need negative supply it'll work with V- to circuit common
and most any 1 amp n channel Mosfet
that'll do the current multiplication
just send volts to 324's + in and it'll cause the Mosfet to sink 100 ma per volt

Your RIO's dac i would think can provide the volts for Mr 324 and his mosfet to follow..
 
  • #41
Is the current rating of the power supply to supply the +Vcc on the 324 specific? In the Absolute Max Ratings on Page 2 of its datasheet above, it says 50mA but in note 6 on page 4, it says the input current should only exist when any of the voltage at any of the input leads is driven negative.
I have a 24V 15A Output DC Power Supply and I am trying to ensure my 324 is not smoked if I plug these into it. :)
 
  • #42
The "operational amplifier" if connected correctly will only draw what power it needs to "operate".

Sometimes we connect a circuit through a light bulb, to limit the current in case there's a wiring mistake. That'd probably not save the LM324, but 324 is an inexpensive part.

15 amps is a stout source. Does it have a current limit knob? Built in ammeter ? Bring voltage up slowly while measuring current...
 
  • #43
I put together the figure 2 circuit in the attachment
lm324 design.png
but instead of the DAC there, I used the myRIO's SPI connector (called MXP connector A). The current VI I have is here. So on the MOSFET side, I have it replaced with http://www.mouser.com/Search/ProductDetail.aspx?R=VN3205N3-Gvirtualkey68900000virtualkey689-VN3205N3-G .
So I run my program and as far as I can tell, the VI is perfect but I could not make any intelligent reading from the output terminal of the MOSFET. What could I be doing wrong?
 
Last edited by a moderator:
  • #44
Lexilighty said:
The current VI I have is here.
current2.png


What on Earth is that ?

This i understand:

lm324-design-png.77477.png

Did you connect a load between OUT and V+ ? You could measure either current through that load or voltage across R1
 
  • #45
jim hardy said:
What on Earth is that ?
That, big Jim, is the code that myRIO understands.

jim hardy said:
Did you connect a load between OUT and V+ ? You could measure either current through that load or voltage across R1

Is the load supposed to be across OUT and V+? I thought it should be between OUT and V- or common ground? In any case, I measured the voltage through the 7 ohms 15W resistor I am using and it is essentially zero. Something is definitely not adding up. I am using a Power resistor by the way.
 
  • #46
It seems what I am missing is a DAC receiver between the myRIO and the Op-AMP. I might have to order the AD5446 that can fit into a VERO Board. The one I got the other day was a very small DAC that was surface mount and was no good. I would look in electronic stores around me and see what I can get tonight. Thanks Old Jim. I'll update you on what I get.
 
  • #47
I'm just guessing here, but the myRIO has analog outputs, meaning there are DAC's onboard that can drive your opamp. You just need to determine how to program them.
Look at the Analog outputs section in your manual. (Maybe your myRIO has no analog?)

Post a link to the user manual for your particular device.
 
  • #48
meBigGuy said:
I'm just guessing here, but the myRIO has analog outputs, meaning there are DAC's onboard that can drive your opamp. You just need to determine how to program them.

You are right. It does have analog outs. The myRIO link is here. And yes, there are DAC's on board. I did send some numeric constant though one of the outputs of the Analog Outs last night and generated voltage between OUT and V+ in the circuit above but I could not notice any proportional flow in the solenoid valve I was using. There must be something I am missing.

I wonder if I need to interface a servant (which in this case would be the AD5446 or something of similitude) to the myRIO before I can get a proportional current n the output. It seems to me that the DAC on the myRIO is a MASTER only.
 
Last edited:
  • #49
Lexilighty said:
Is the load supposed to be across OUT and V+? YES YES YES ! I thought it should be between OUT and V- or common ground? No No No !
Take a close look at your circuit, just the right hand side.
Conventional current flows down into the terminal labelled "out"..
How does it get there ?
Start at top.
Current is pushed by power supply, down through a load to "out" terminal,
then the mosfet does its "sphincter" thing to restrict how much current is allowed to continue on down through the current measuring resistor R1.
Opamp senses voltage across R1 and varies the constriction of Mosfet to make volts at inverting input equal to Vref from your RIO.
Since there's no place for current to escape, all the current through the load must also go through the mosfet and R1.

So, Iout X R1 = Volts from your RIO.
Iout = (Volts from your RIO) / R1 = (Volts from your RIO) / 10 or 100 ma per volt

if you're an "electron flow" guy the logic is same, just start at bottom instead of top and pull current instead of push.

As you see I'm just not fluent in RIO's or today's computers in general
i used to fix them when they were built from 7400 series IC's (early 1970's)
but there's not much call anymore for brontosaurus veterinarians

so i'd enjoy hearing of your success with this project, maybe post a waveforrm ?
old jim
 
  • #50
The way the output circuit works is that any voltage on pin 3 of the OP1177 will appear on pin 2 due to the OP1177 operation. That means the same voltage that is on pin 3 will appear will be the voltage across R1. That voltage is relative to AGND.

The voltage across R1 means a current (Iload) is flowing through R1, and it MUST come from OUT, through the MOSFET.

There will be a higher voltage on the gate of the MOSFET in order to turn it on. (whatever Vgs needs to be to conduct the current).

If the circuit is unstable, you could never tell with a meter, and you could get any sort of reading. (I'm assuming you don't have a scope?)

Things that could cause instability include:
No bypass caps on the op amp supplies
OP1177 doesn't like the capacitive load of the MOSFET gate
Poor grounds

You definitely need good bypassing on this external board. Electrolytics with paralleled 0.1 or 1uF ceramics from all supplies to AGND. AGND needs to connect to the myRIO ground.

So I would do the following:
1. Check the wiring of the pins and verify you are assigning them correctly
2. Bypass the OP1177
3. Check the voltage at pin 3 when you program the DAC
3a. If it doesn't change, disconnect the OP1177 recheck the analog out, and find the cause
4. Verify the same pin 3 voltage appears at pin 2 for all pin 3 voltages
4a. If it doesn't match exactly, there are a few ways to proceed. I would remove the FET, change R1 to a larger resistor that the OP1177 can drive (10ma, so maybe 1K or 470 ohms if you only go to 5V), and verify the OP1177 is working correctly with no FET. If it does work correctly with no FET, there was probably a FET wiring error, or instability.
4b. You could also just try increasing R1 to see if it works at lower currents with the FET connected.
5. If the pin 2,3 voltages match, then it must be working. The load current will be Vpin2/R1.
 
  • #51
meBigGuy said:
So I would do the following:
1. Check the wiring of the pins and verify you are assigning them correctly
3. Check the voltage at pin 3 when you program the DAC
3a. If it doesn't change, disconnect the OP1177 recheck the analog out, and find the cause
4. Verify the same pin 3 voltage appears at pin 2 for all pin 3 voltages
4a. If it doesn't match exactly, there are a few ways to proceed. I would remove the FET, change R1 to a larger resistor that the OP1177 can drive (10ma, so maybe 1K or 470 ohms if you only go to 5V), and verify the OP1177 is working correctly with no FET. If it does work correctly with no FET, there was probably a FET wiring error, or instability.
4b. You could also just try increasing R1 to see if it works at lower currents with the FET connected.
5. If the pin 2,3 voltages match, then it must be working. The load current will be Vpin2/R1.

Thank you, meBigGuy.
Here's what I can tell you. I replaced the power wire-wound resistor (7 ohms 15W) with a 10 ohms 1/4 W resistor and I noticed the following. The voltage across OUT and V+ is 24.4V which is just what I have across the pins 4 and 11 (V- and V+) of the LM324 (which replaces the OP117 in my circuit). This tells me the MOSFET is okay. In addition, I disconnected the MOSFET just to confirm this, connected a 272k resistor and I notice no voltage drop across OUT and V+.
With a 24.4V supply across the V- and V+ of the 324, I can read the 24.4V across the inversting input (pin 2) of the opamp). But there is no voltage between pin 3 and coomon ground. I have not tried this circuit with a bypass capacitor yet but it seems my program is the issue and not my connection. I sadly have no oscilloscope for now. Let me know if there is anything I am doing wrong. Thank you!
 
  • #52
I think you are very close to success.

Lexilighty said:
The voltage across OUT and V+ is 24.4V
Is that the voltage between OUT and V+, that is one reading with meter leads connected to those two spots,
or is it two equal readings one from each spot to circuit common?

It's a little confusing when you say "across ( two points)"
Do you mean
your two meter leads are connected to those two points and that's a single reading, which is what that wording suggests,
OR
you took two separate readings, one between each of those two points and circuit common?

It's less ambiguous to give one reading at a time, specifying the two points of measurement.24 volts across something will be taken in electronics circles as meaning 24 volts between its two ends.
24 volts at someplace will be taken to mean between that point and circuit common.
24 volts between two points is bulletproof wording.

Lexilighty said:
I can read the 24.4V across the inversting input (pin 2) of the opamp).
Okay, one meter lead is on pin 2, where's the other? I assume circuit common. 24 volts at that spot suggests R1 is not connected, or the 24 volt supply negative is not tied to circuit common.

Lexilighty said:
connected a 272k resistor and I notice no voltage drop across OUT and V+.
"no voltage drop " means you measured zero volts between the two points, or you saw no decrease in measured volts at either point ?
Eternal vigilance is the price of clarity.:)
MeBigGuy is a mighty good troubleshooter and explainer, just give him unambiguous info like this:
But there is no voltage between pin 3 and coomon ground.
 
  • #53
jim hardy said:
24 volts across something will be taken in electronics circles as meaning 24 volts between its two ends.
That's exactly what I meant.

jim hardy said:
Okay, one meter lead is on pin 2, where's the other? I assume circuit common. 24 volts at that spot suggests R1 is not connected, or the 24 volt supply negative is not tied to circuit common.
Guilty. I'll pay the so-called price of clarity. The other lead is on 24V supply negative.

jim hardy said:
"no voltage drop " means you measured zero volts between the two points, or you saw no decrease in measured volts at either point ?
I meant what I said, big Jim.

BTW, I like that vigilance "zinger"! Hehe!
 
  • #54
Lexilighty said:
I meant what I said, big Jim.
The voltage across OUT and V+ is 24.4V
hmmm...
so you read full power supply voltage between either end of 24 volt power supply and anything connecetd to circuit common (AGND) ?

Is Negative side of 24 volt power supply tied to AGND ?
Lexilighty said:
BTW, I like that vigilance "zinger"! Hehe!
Thanks - i was hoping you wouldn't be mad.
 
  • #55
jim hardy said:
so you read full power supply voltage between either end of 24 volt power supply and anything connected to circuit common (AGND) ?

Nope. I am reading between positive end of power supply and OUT. Are you suggesting I provide a separate common ground for the circuit?

jim hardy said:
Is Negative side of 24 volt power supply tied to AGND ?
No. If this is what you are suggesting, how do you do this? are you suggesting I use the AGND of the RIO?
 
  • #56
Lexilighty said:
Nope. I am reading between positive end of power supply and OUT. Are you suggesting I provide a separate common ground for the circuit?

but you also said
Lexilighty said:
Guilty. I'll pay the so-called price of clarity. The other lead is on 24V supply negative.

which i took to mean you got 24 volts in two different readings, one at each of these two places :
+24 to OUT
-24 to Pin 2

Lexilighty said:
No. If this is what you are suggesting, how do you do this? are you suggesting I use the AGND of the RIO?

Yes, that needs to happen.
Here's why:
Voltage is always between two points.
Your RIO makes volts between its DAC out pin and AGND.
Your LM324 op-amp senses volts between each of its input pins and its V- pin. It amplifies the difference between those two voltages.
So, when you write KVL around opamp input and R1 (or RIO DAC output)
a term appears for voltage between opamp's V- pin and AGND which must be defined.
To define it, some connection is required. A direct connection is simplest.

The LM324 is nice because it'll tolerate that direct connection , see "common mode input voltage" specs in datasheet - It goes all the way to zero which allows it to handle a direct connection..
http://www.ti.com/lit/ds/symlink/lm324.pdf

A 741 will not tolerate zero common mode volts so would require extra circuitry.

Connect -24 supply to AGND ,
right at bottom of R1 so that the load current returning to -24 doesn't flow through the physical segment of AGND wire lying between R1and RIO.
Connect opamp V- pin to same spot, or to RIO side of that connection but nearby. Idea is to keep load current return path away from opamp input.

wow I'm way too wordy. Somebody can summarize in twenty words, i'll bet.

keep us posted ?
 
  • #57
All measurements have to be relative to AGND. AGND has to be connected to myRIO GND. There has to be a common ground. All supply voltages are relative to GND. Everything is about GND. The only thing that really matters are the voltages relative to GND.

If you only have one +24V supply, then you have a problem. The opamp circuit you showed assumed there are two supplies, +15V relative to AGND, and -15V relative to AGND.

You can do this with a single supply, but you need a "rail to rail" opamp. The OP1177 can only go to within about 1V of its negative supply pin. You can connect V- of the OP1177 and the negative supply lead to AGND. The OP1177 output will not go all the way to ground, but it will almost turn the FET off. A 10K resistor from the opamp output to GND might help.

I'm not sure what will happen with the way it is connected now. The supply leads are theoretically "floating" relative to AGND, but in reality there will be paths to AGND. Not sure where it will stabilize.
 
  • #58
Alrighty. I have made a lot of progress in the past few hours. Thanks to youse. I have connected the 24V- to the AGND of the RIO and I have fixed my RIO code.
Now, I can vary the voltage on the analog out of the myRIO from 0 to 10V by increasing the number of digital words from 0 to 2047 bits total. The analog channel I am using on the RIO can do a max of 10V at 2047 bits total.
Ok. So I put a 60 ohms resistor as my R1 and I discover I have lost 10Volts across the entire circuit when I measure the voltage across V+ and OUT (I am reading 14V when I am at 2047 bits). I also notice that the voltage between Pin 2 or Pin 3 and common is now 10V, i.e. they are equal and conjugate. But on Pin 1, measuring voltage between this pin and AGND gives 14V. This is still not so clear to me.
Probably need a higher DC power supply in order to generate the exact 24V that can drive the solenoid valve?
Nevertheless, this has been a positive and rewarding experience. I will now try with, say, a 30 Volts supply and see what I can get out of this piece. Thanks Old Jim and MBG.
I appreciate your help so far. If you have more contributions, kindly let me know.
Cheerio!
 
Last edited:
  • #59
meBigGuy said:
You can do this with a single supply, but you need a "rail to rail" opamp. The OP1177 can only go to within about 1V of its negative supply pin. You can connect V- of the OP1177 and the negative supply lead to AGND. The OP1177 output will not go all the way to ground, but it will almost turn the FET off. A 10K resistor from the opamp output to GND might help.

I'm not sure what will happen with the way it is connected now. The supply leads are theoretically "floating" relative to AGND, but in reality there will be paths to AGND. Not sure where it will stabilize.

This might clarify MBG's statement about floating power supply, which i think is the biggest problem right now.

LM324 isn't quite rail to rail but it is bottom rail to 1.5 shy of top rail. That's why i suggested it.
Circuit might even work with 324 powered from +5...
but according to Kirchoff it doesn't stand a chance unless 24V supply can pull current out bottom of R1 and push it back up and around into load.

For that reason 24 volt supply negative side MUST be connected to bottom of R1 , which also is AGND.
LM324 can sense to ground and will sink to within millivolts of it.
 
  • #60
Lexilighty said:
But on Pin 1, measuring voltage between this pin and AGND gives 14V. This is still not so clear to me.
Pin 1 is output of the opamp, controlling Mr Mosfet.
that's ten volts across R1 plus four volts gate drive to turn on Mr Mosfet.
Coincidence that you got 14 volts two places...

Lexilighty said:
I also notice that the voltage between Pin 2 or Pin 3 and common is now 10V, i.e. they are equal and conjugate.
Good, that's how opamps "operate" , a good designer surrounds them with a network that enables them to make their inputs equal.

Observe ten volts = .165 amps X 60 ohms ---- well, within 1% .
Indeed any voltage across R1 subtracts from what's available to drop across load.
24 volt supply minus ten volts across R1 leaves 14 volts to be shared by Load and Mr Mosfet.
It looks like Mr Mosfet is politely taking only a small portion. Good mosfet.
I'd go back to 10 ohm R1 and tell Mr RIO to make 0 to 1.65 volts. That'll give you 0 to 165 milliamps and leave about 24 - 1.65=23.35 22.35 (oops) to drop across load. If your 24 volt supply can be adjusted up to around 26 you just might make it !
Keep on pushing ! This is how we learn. Beats computer simulatng, eh ?

old jim
 
Last edited:

Similar threads

  • · Replies 20 ·
Replies
20
Views
7K
  • · Replies 6 ·
Replies
6
Views
8K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 19 ·
Replies
19
Views
5K
Replies
3
Views
397
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 31 ·
2
Replies
31
Views
5K
  • · Replies 15 ·
Replies
15
Views
9K