Convert PWM to constant current (programmable current source)

Thread Starter

Najossmith

Joined Sep 12, 2018
13
Hello,

I am trying to create a pwm controlled current source, but I can't have the diode turning on and off as you might do with a transistor and LED where your eye "filters" the on and off to a constant on. I am trying to drive a laser and it needs to be on constantly.

Similar circuit except the voltage source is an RC low pass filter with Vin over the cap. Current issue is that Vin and Vout do not follow each other as the PWM changes duty cycle.
http://www.ecircuitcenter.com/Circuits/curr_src1/curr_src1.htm

I need a 10mA - 100mA range over the load (laser diode). Currently using the AD842JN op amp, and the 2n2907 transistor.

Thoughts, insight, wisdom?

Thanks,
Nathan
 
Last edited:

Thread Starter

Najossmith

Joined Sep 12, 2018
13
That circuit should work.
Post the exact circuit you are using.
Attached is the circuit I have put together.

My problem occurs when I take the voltage across the cap and feed it into my non-inverting input. The voltage at the inputs, output, and the cap do not "follow" one another.

I appreciate the timely response crutschow. Reading some of your older posts have really helped me get started.
 

Attachments

Thread Starter

Najossmith

Joined Sep 12, 2018
13
Something like this, filter PWM output and feed to
OpAmp V+ (R1, R2 not needed). I = (15 - V+opamp) / R3

View attachment 159789

Regards, Dana.
Yea, that's pretty much what I have except my load is floating and not tied to the ground. I can get it to work with replacing the RC circuit with a lab supply, but once I attach it Vout and the inputs no longer "follower" each other. Any thoughts?

And thanks for the two .pdfs, I have only skimmed them but they seem like great resources. I'll be sure to put more energy toward reading them in the morning.

Nathan
 

Thread Starter

Najossmith

Joined Sep 12, 2018
13
wrong transistor type, you are taking feedback on low side so transistor in this case need to be NPN.
I'll have to verify this tomorrow morning, but assuming my memory is correct (yikes) when I switched to a NPN I still did not have a functioning circuit. I know I tested a NPN as well, but I'm not sure if I switched something else as well... (bad troubleshooting, I know)

I'll switch out the transistor type when I have it in front of me and I'll let you know what comes of it.

Thanks,
Nathan
 

ScottWang

Joined Aug 23, 2012
7,397
Attached is the circuit I have put together.

My problem occurs when I take the voltage across the cap and feed it into my non-inverting input. The voltage at the inputs, output, and the cap do not "follow" one another.

I appreciate the timely response crutschow. Reading some of your older posts have really helped me get started.
Try to use an 1N4148(-|>|-) in parallel with a 100K to replace 47Ω and use an NPN to replace the PNP as in your first post.
 

Bordodynov

Joined May 20, 2015
3,177
I think that using the AD842 operational amplifier is a bad idea in this case. The minimum supply voltage (total) is 10V. And I'm not sure that the circuit with it will be fixed with 100% negative feedback. The LT1221 chip, which is a complete analogue, has a stability with a gain of at least four.
Tell what PWM parameters and what frequencies you want to modulate the laser. If you report this data, I will be able to draw and simulate the necessary scheme. By the way, in my collection there are models of lasers for which it is possible to set the laser parameters.
 

ebeowulf17

Joined Aug 12, 2014
3,307
What frequency is the PWM signal? The RC filter is going to have a really small time constant with only a 47 ohm resistor! Unless the frequency being filtered is really, really high, I don't think the RC filter is doing anything.

I also question the value of the 27 ohm resistor. At 100mA, that will be dropping 2.7V. You'll also lose some voltage through the pass transistor. If you've got a 5V supply, you're running out of voltage for the laser pretty quickly. Depends on the Vop of the laser though. Maybe 27ohm is right.

Anyway, at first glance I think you need to go back to NPN and get your RC filter values fixed. There should be loads of resources online to help pick suitable RC values, but if you need help with that here, you'll have to tell us the PWM frequency.
 

Thread Starter

Najossmith

Joined Sep 12, 2018
13
I think that using the AD842 operational amplifier is a bad idea in this case. The minimum supply voltage (total) is 10V. And I'm not sure that the circuit with it will be fixed with 100% negative feedback. The LT1221 chip, which is a complete analogue, has a stability with a gain of at least four.
Tell what PWM parameters and what

frequencies you want to modulate the laser. If you report this data, I will be able to draw and simulate the necessary scheme. By the way, in my collection there are models of lasers for which it is possible to set the laser parameters.
I need a current between 10 - 100 mA for the laser. Voltage max is 2.

In terms of the minimum voltage being 10, if I had my Vcc and Vee to +/- 5 would that solve that concern?

Thanks,
Nathan
 

Bordodynov

Joined May 20, 2015
3,177
I probably did not speak well. This operational amplifier is not suitable even with two power supplies ( + /- 5V).
There will be oscillations of the current.
 

Bordodynov

Joined May 20, 2015
3,177
Choose a different operational amplifier, with the power supply from one source and available to you. Do you need direct current, with the possibility of adjustment? If so, then there is no need for a fast amplifier!
 

Thread Starter

Najossmith

Joined Sep 12, 2018
13
What frequency is the PWM signal? The RC filter is going to have a really small time constant with only a 47 ohm resistor! Unless the frequency being filtered is really, really high, I don't think the RC filter is doing anything.

I also question the value of the 27 ohm resistor. At 100mA, that will be dropping 2.7V. You'll also lose some voltage through the pass transistor. If you've got a 5V supply, you're running out of voltage for the laser pretty quickly. Depends on the Vop of the laser though. Maybe 27ohm is right.

Anyway, at first glance I think you need to go back to NPN and get your RC filter values fixed. There should be loads of resources online to help pick suitable RC values, but if you need help with that here, you'll have to tell us the PWM frequency.
PWM is 490 Hz.
 

Thread Starter

Najossmith

Joined Sep 12, 2018
13
Choose a different operational amplifier, with the power supply from one source and available to you. Do you need direct current, with the possibility of adjustment? If so, then there is no need for a fast amplifier!

Do you have a suggestion on the specs I would need on the new op amp?
 

Thread Starter

Najossmith

Joined Sep 12, 2018
13
I think that using the AD842 operational amplifier is a bad idea in this case. The minimum supply voltage (total) is 10V. And I'm not sure that the circuit with it will be fixed with 100% negative feedback. The LT1221 chip, which is a complete analogue, has a stability with a gain of at least four.
Tell what PWM parameters and what frequencies you want to modulate the laser. If you report this data, I will be able to draw and simulate the necessary scheme. By the way, in my collection there are models of lasers for which it is possible to set the laser parameters.
How do I get to your collection?
 

ebeowulf17

Joined Aug 12, 2014
3,307
PWM is 490 Hz.
Ok, so if freq = 490, then period = 1/490 = 0.00204 sec (2.04ms)

Depending on how low you want your ripple to be (how smooth the signal needs to be,) you want the time constant of your RC filter to at least equal the period of your PWM signal, and probably be more like 5x the period.

At 5x, you'd be looking at an RC time constant of ~10ms, which means when you change PWM duty cycle, it will take 10ms to reach 2/3 of the change, and 50ms to see the change fully take effect. I'm not sure if response time matters in your application. If so, you'll either need to accept more ripple in your current set point, or change to a higher PWM frequency.

For the following example calculations, I'll use the 5x number, but you can adjust to suit once you see how it's done.

The RC time constant (in seconds) is simply resistance (in ohms) times capacitance (in farads.) So, if we want an RC time constant of 0.01s (10ms,) then we need two numbers that equal 0.01 when multiplied together. Big caps get expensive, so let's start with something manageable, like 1uF.

Converting the formula to solve for R, we go from:
RC = R x C
to:
R = RC / C

Since 1uF = 0.000001F, and our target is 0.01s, our resistance would need to be:
0.01 / 0.000001 = 10,000 ohms (10k.)

So, to get a nice smooth signal from a 490Hz source, you'd need a 1uF cap and a 10k resistor (or 0.1uF and 100k, etc...) and you'd have a 50ms response time. If you want faster response at the expense of more ripple, you can reduce those numbers somewhat, but I wouldn't go lower by more than maybe a factor of 5 (the ripple at that point will already be huge!) If you want faster response AND smooth signals, you'll need a higher PWM frequency.

For comparison, I'm suggesting time constants of 2-10ms, and you've currently got a time constant of 0.000047 ms.
 
Top