Author Topic: Constant current source adjustable by PWM  (Read 5133 times)

0 Members and 1 Guest are viewing this topic.

Offline delphes123Topic starter

  • Contributor
  • Posts: 33
  • Country: be
Constant current source adjustable by PWM
« on: June 07, 2023, 01:36:06 pm »
Dear

I would like to get Constant current source, but the level of current needs to be adjustable (from 0 to 20 MA approx), I need to have very low cost of BOM, best is to avoid OP Amps if possible.

R3 is the charge where I need constant current.

The idea is to replace V2 source by MCU PWM output

How this schematic could be improved? Does Q2 needs to be replaced by Mosfet ?

Thanks
 

Offline paulca

  • Super Contributor
  • ***
  • Posts: 4046
  • Country: gb
Re: Constant current source adjustable by PWM
« Reply #1 on: June 07, 2023, 01:53:48 pm »
20MA ... that's a lot of current!  I assume you mean "mA".
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 
The following users thanked this post: Neomys Sapiens

Offline schmitt trigger

  • Super Contributor
  • ***
  • Posts: 2222
  • Country: mx
Re: Constant current source adjustable by PWM
« Reply #2 on: June 07, 2023, 03:53:13 pm »
Why are you against using an opamp? Why are you restricting the use of a component which will make your life easier and performance better?
« Last Edit: June 07, 2023, 03:58:22 pm by schmitt trigger »
 

Offline delphes123Topic starter

  • Contributor
  • Posts: 33
  • Country: be
Re: Constant current source adjustable by PWM
« Reply #3 on: June 07, 2023, 04:30:13 pm »
Yes sorry typo is mA of course
 

Offline delphes123Topic starter

  • Contributor
  • Posts: 33
  • Country: be
Re: Constant current source adjustable by PWM
« Reply #4 on: June 07, 2023, 04:31:18 pm »
Not using OP Amps is mainly cost problem with this project, but if there are no solutions why not ?
 

Online magic

  • Super Contributor
  • ***
  • Posts: 6778
  • Country: pl
Re: Constant current source adjustable by PWM
« Reply #5 on: June 07, 2023, 04:53:47 pm »
This may work. The PWM signal should be filtered with an RC circuit, unless the load can tolerate pulsed current rather than DC.

Accuracy won't be ideal because Vbe of a transistor varies from specimen to specimen and over temperature. There will be some minimum PWM level required to reach ~0.6V at the base and start conducting anything at all.

BJT is probably better than FET due to lower Vbe. FET has the benefit of no base current and higher accuracy, but that's important for more "high end" circuits.
 

Offline schmitt trigger

  • Super Contributor
  • ***
  • Posts: 2222
  • Country: mx
Re: Constant current source adjustable by PWM
« Reply #6 on: June 07, 2023, 05:14:26 pm »
It can work, but the performance will be reduced. Meaning the temperature dependency and larger filter components for a given ripple level.
Everything depends on your exact requirements.
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5870
  • Country: de
Re: Constant current source adjustable by PWM
« Reply #7 on: June 07, 2023, 06:27:44 pm »
It'll work, provided you include a series resistor between MCU and the diodes.
But it won't work well, the 1N4148 VF curve is extremely soft. How precise does this need to be?
 

Offline delphes123Topic starter

  • Contributor
  • Posts: 33
  • Country: be
Re: Constant current source adjustable by PWM
« Reply #8 on: June 07, 2023, 06:34:30 pm »

Thanks for all answer, the precision is not so important, the most important is to be sure PWM signal can offers a wide range of mA on the output, I mean from 2 to 20 mA for example.

How you will place the filter to avoid too much ripple ?
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5870
  • Country: de
Re: Constant current source adjustable by PWM
« Reply #9 on: June 07, 2023, 07:31:08 pm »
What filter?
You didn't mention that you want a DC output. PWM is PWM.
 

Offline delphes123Topic starter

  • Contributor
  • Posts: 33
  • Country: be
Re: Constant current source adjustable by PWM
« Reply #10 on: June 07, 2023, 08:16:59 pm »

The 12 Volts source provide DC voltage for the constant current circuit, the PWM source (5V source on schematic) is independent but PWM will reject on the 12 volts source, so RC filter is needed.
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5870
  • Country: de
Re: Constant current source adjustable by PWM
« Reply #11 on: June 07, 2023, 09:26:30 pm »
Ah, power supply decoupling. That's a different issue.

Concerning the CC driver, I looked through my archives, as I had to do the same a couple of years back.
This circuit works well and is reasonably precise. Increase R1 to 3k3 for 5 V PWM:
 
The following users thanked this post: ledtester

Offline pqass

  • Frequent Contributor
  • **
  • Posts: 725
  • Country: ca
Re: Constant current source adjustable by PWM
« Reply #12 on: June 07, 2023, 09:50:02 pm »
See attached schematic and play with it via link below.

The first circuit uses a pot adjusted Vbe multiplier.
The second circuit uses a PWM@1kHz that can be adjusted from 12% to 70% to achieve 200mA to below 1mA CC.
The smoothed PWM may be a little wiggly and slow but you can work on that.
Or, via the SPST, use a DAC that can be adjusted from 1V to 2.8V for the same range.


http://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWEAmA7NVbnIBwBYFkBmMIogThxAUmutoQFMBaMMAKABcVMQjlaRSHj4Co4EK2gIauVKhz9iNSMijSE5SKjxhcANjLJ9+tWDggAJowBmAQwCuAG07swOkDkH6qYPCNxfcHhaGGE8fRAABQB7TkYAO04ASxiAW0Z4gCd2LM9abBEwfQLkEUEtSHYAdz5hPh86kTJIqtqhZvqOnjUq7haekH8qLHEIZnJoHC1DLxwcP34icox+E2QtMBx9cjI2YNpre2dXPOGUeaG8KiJG2n0pmqubxoHbqiqiVFpzvSpz5AISIQULsABKz3AuEhXnEP1oejh6gQ7AA5pD3pC8BZQRDumw1N1YaEhgwkTAUV9BPUCU1wCUJKC8viGd1CmN4E83q8uncubdBmzeFUAA58AWjbk3OHsSx09lCtRqI6OFzsKngVCRfgFXg6xlQdhi9zasQmhrS0G1c2Y7qYtr5FBlR2jT7feXO4qlIoyvKwzE2u7iuBPG1m-yiUFi-TYob8EAxhjQogy2qJuNqEr-eMO9OEKhZ6jQqp5Qv6sv4DkhjWF0Zls0yiG13i12Mk2NIEkUtEgVCEItUPtqIFd8G9-uBcdKtviWOIrvSdXuocXQf93TA1NTgcJjvF3Lb84r-PiB44Li7n7xld4HMSCZTHAIBTaIiKPwrVD8If8BDDbH6BA5iHLYqquGmkD-DGCaQRmhoQVQJ6Fng5CtBez6RNc9ywVhYySGA0jYHouzYmwXyaOQyLkAI0zUWAz5bNiKbAVYoEnAeCCIrhG5DMSQzfCGeLrtckaQu2CKwL0cKLhqnFqLhGG8QiMpinJSnUIiJ4plaGnDtChYnrmsFviIyE5mOH7qbSuEQGY8AoNIDmduopDIOwADKQzFEM0FEOu0EkvYTgAM6MOIbm1DxJ5qYZB6AphsLmrhCKcgAxigQLqfFO6hLAITkAVhVFcVlEEXAQjEGAWhvrcujaXlHBijx3HeVpW7ZVpAqxZF3kRCIzXEvyCWCOug3tF10JRfucqWTZWpZaxxxqsyAq4QMhlOiGtTZWtq2DapiKTmptpbsdjTnPaTxqZOAKXA6CyYSJN4ifdrXQse+5ig9MJvZahoxD5QziO8JjBOocCmM58nauwAMICm5SkpQ4DQIC4PwOQWpAmjBTUCmRDqv8EAAGIgsD+EgAAwjESRZDETgADrBQAavTnB2KijCE4DpN0OYIBaBTlMADIANJMwAIg4nAAJ5M5TMupU4XNAA


EDIT:
I forgot to change the beta (to 25) of the main (right) transistor to better reflect that of a power transistor so a few resistors in the BJT version would need tweaking from what is shown.

Additionally, I've attached a MOSFET version.  Simulator link below.
I think the values chosen should work for a logic-level MOSFET like the IRLZ44.


http://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWEAmA7NVbnIBwBYFkBmMIogThxAUmutoQFMBaMMAKABcVMQjlaRSHj4Co4EMyLQAbHn5g8+IqhzlUCckSjQEctoWR4ZqyAiIiwcEABNGAMwCGAVwA2ndmFQicgmVUURXADweFoYMwIQAAUAe05GADtOAEtYgFtGBIAndmyQXxQjcDwg4to0eHYAdz5hPn86kTIZKBqmjqEg3kg8kFKqYP6lBqpaK3aB0b4iVtmx9hVaKbBcYcG9CXD2ACV18DWpwvD+8eRxcN12AHN9+f28a229rvBVjuPxR7oTmARF1CCepsc6vMAycYXPpgiEdbAicZVWotaave69ZGzHig+pYNoABxmrTxKPu2m2S3AqDmYhJYgg20JXhp42pqKhtWZqPq6PahXhBQqPQBQLKllKRUsUPyhXuXPR-UBGKpLJKzTEvUJcmW-BA2uoa3JbVq+vk5whVDNxr130IVAtBoW+Qd-FoLvw4iscBFesgg14LvpUL2Drxoe+J1tFx0-1uGnOdpA8eosOeScIKBwVGTRl+pwO0b+PpzWfT5zw4K21uTif1id6+WTUxra0R7QdxhEHd1yodtb9-XIrV63AQbKUboHE89kmk-jwyBMXSHs3IMf8mn4FlQqCEgPOXtsDhc7j6CHe04rrWntBwAm9LwzU1d+0jgkLV0p5-LhTH18KDIEtQF6-u8iZGsq36Or6VD1rsar9ABIGQge8AoLo6FIJcVi+GEeHwBwADK-SVp2fBPnI0ZOK4ADOjDiMgkyVomUFwfkyCbNOXI3qE3oAMYoJx-KbPWOh4eQEmSVJ0lrjAOB-mQeDqDIhBKVoYmQBwhJXohyzMYaHKCa04FYnBtQ6WRFnHO0KLTkQT7WZixmHPpCw2AhXHjvyR5OG4Hj5LZsqma2RTerUHH-oIWI3uwhJQUMUFkoZiWNM+jSQe8QxTEMyo4KRIxNiMuWuWW0GagU+VUHlzlUBB7D2DaOrnE2uq6geCDQGA57nvVRLYvsdIoOAHVdaN7Dua8AqTbw5x2L5p7ue6XZTm1Pknh4sT9OW4jzDIrRWBpMgcQxW18Owm1Kf0XyQJQPywPAyl6MdFSDmdRC1VQABigHvqwIAAMKxMk2SxK4AA6NEAGqg5wjjXIwiyWuc310Ad5C0H9-0ADIANIQwAIs4nAAJ4Q-9xN8a4CNAA
« Last Edit: June 08, 2023, 12:54:37 am by pqass »
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5870
  • Country: de
Re: Constant current source adjustable by PWM
« Reply #13 on: June 07, 2023, 10:01:07 pm »
I count 9 parts instead of just 5.
And I see no CC functionality at all. Cute graphics, though.
 

Offline pqass

  • Frequent Contributor
  • **
  • Posts: 725
  • Country: ca
Re: Constant current source adjustable by PWM
« Reply #14 on: June 07, 2023, 11:07:45 pm »
I count 9 parts instead of just 5.
And I see no CC functionality at all. Cute graphics, though.

Wah?

You've proposed a fixed current LED flasher.
The PWM just shuts off the LED in the low state or enables the transistors to pass a fixed 18mA in the high state.

I proposed (1st circuit) a Vbe multiplier that behaves like a variable zener between base-emitter of the main (right most) transistor. Or, (2nd circuit) turns a voltage into a current (through the 47K) into the base of the left transistor that varies the voltage between base-emitter of the main (right) transistor.  In both cases, the main (right) transistor base -0.7V over the 6.8R produces a true variable current.

Yes, there's 4 more [cheap] parts.  But the current through the 6.8R emitter resistor can be varied via the pot, DAC, or PWM duty cycle.


http://www.falstad.com/circuit/circuitjs.html?ctz=CQAgjCAMB0l3BWc0DMAmALGNkdgJxgIBsCaaICkll1CApgLRhgBQALiBhgBwhoB2Cr2qCK1CIx7QePbJAT40KYvh4pIEGMQEL8KHphTGBGFBDBwQAE3oAzAIYBXADbsOXHtWPEQKMn4qUOAgjDACGsRgsmBROKqCUNDECgLEaEr4JAoIQuBWto6u7gDunqKy5YG+kKwATlU+VRhW3iisAObNViJcscG1Zf4Uw34BLdSDY8I9Xlyt9Vy8-HmjYsHGtQ1reWgkK+L8OFM7IwHok6yxwnNgaVV7vhSFzm6MLvTWIZNJmqwASlVsHxesQMAN5uBDpNoAgAfx9utYqI8hAKJYrGhYfxsTC0qwULogWgQbd7looKwAPZQ75+Yg8Yi+JAwODpFn8WkoEAAYQAMgBpal+OkqRk1ZJ7X5S0Qi7nGf4EvjYEAAMQgHIxoQg-IFAB0AM4AESc7AAnoaeWaAMYfVhAA
 

Online Benta

  • Super Contributor
  • ***
  • Posts: 5870
  • Country: de
Re: Constant current source adjustable by PWM
« Reply #15 on: June 08, 2023, 12:18:59 am »
Wah?

You've proposed a fixed current LED flasher.
The PWM just shuts off the LED in the low state or enables the transistors to pass a fixed 18mA in the high state.

I proposed (1st circuit) a Vbe multiplier that behaves like a variable zener between base-emitter of the main (right most) transistor. Or, (2nd circuit) turns a voltage into a current (through the 47K) into the base of the left transistor that varies the voltage between base-emitter of the main (right) transistor.  In both cases, the main (right) transistor base -0.7V over the 6.8R produces a true variable current.
Yes. Which is exactly what the OP asked for.
A constant-current source  that can be PWM'ed from a microcontroller output pin. In the simplest and cheapest way possible.
The circuit I posted is pulsed at 10 kHz, 30% in the schematic. Dunno if that counts as a "flasher".
The blinking LED in your "falstaff simulation" is somewhat off.
Here's a pro simulation (Spice) of the load current:
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1537
  • Country: au
Re: Constant current source adjustable by PWM
« Reply #16 on: June 08, 2023, 01:04:25 am »
I would like to get Constant current source, but the level of current needs to be adjustable (from 0 to 20 MA approx), I need to have very low cost of BOM, best is to avoid OP Amps if possible.
The idea is to replace V2 source by MCU PWM output

The 12 Volts source provide DC voltage for the constant current circuit, the PWM source (5V source on schematic) is independent but PWM will reject on the 12 volts source, so RC filter is needed.


Thanks for all answer, the precision is not so important, the most important is to be sure PWM signal can offers a wide range of mA on the output, I mean from 2 to 20 mA for example.
How you will place the filter to avoid too much ripple ?

The lowest BOM, and best precision and stability, will be if you can use an ADC channel on that MCU, and read the current resistor.
The transistor or MOSFET Vbe/Vgs then do not matter, nor does the temperature variations.

Then you just need a PWM filter, commonly two stages of RC.

Otherwise, just use an opamp. They come in SOT25 packages, at low cost, and you do not need to calibrate a less-ideal transfer graph.

« Last Edit: June 08, 2023, 01:42:01 am by PCB.Wiz »
 

Offline pqass

  • Frequent Contributor
  • **
  • Posts: 725
  • Country: ca
Re: Constant current source adjustable by PWM
« Reply #17 on: June 08, 2023, 01:34:14 am »
Yes. Which is exactly what the OP asked for.
A constant-current source  that can be PWM'ed from a microcontroller output pin. In the simplest and cheapest way possible.
The circuit I posted is pulsed at 10 kHz, 30% in the schematic. Dunno if that counts as a "flasher".
The blinking LED in your "falstaff simulation" is somewhat off.
Here's a pro simulation (Spice) of the load current:

Well, I guess we have different ideas on what "...but the level of current needs to be adjustable (from 0 to 20 MA approx)," means; digital vs analog.  In that case, his original circuit only lacked a base resistor.

Falstad (or similar) shouldn't be taken as gospel but just as starting point before the breadboard/prototype stage.
« Last Edit: June 08, 2023, 02:17:52 am by pqass »
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1537
  • Country: au
Re: Constant current source adjustable by PWM
« Reply #18 on: June 08, 2023, 02:24:40 am »
How this schematic could be improved? Does Q2 needs to be replaced by Mosfet ?
...
I mean from 2 to 20 mA for example.

I love how spice lets you whack 5V across two series diodes.   :palm:

You seem to be ok with large drop across the emitter resistor, which is the most temperature tolerant, so the simplest filter-able circuit would be to ditch the 2 diodes and replace with a PNP emitter follower, and a pullup on the NPN base. (That can pullup to 12V)

That gives you 'nominal' vbe tracking and a high input impedance at the PNP base, where you place the PWM filter.
A dual transistor package would improve that tracking.

It may not drive fully down to 0mA, but it could manage 2mA~20mA.

You can nudge the lowest current down, by connecting the PNP collector to the NPN emitter, instead of the more usual GND.
Now, base current steered by the PNP, subtracts from the NPN Vbe.
 

Offline delphes123Topic starter

  • Contributor
  • Posts: 33
  • Country: be
Re: Constant current source adjustable by PWM
« Reply #19 on: June 08, 2023, 07:30:00 am »
Thanks to all for the discussion which gives me more information, however I am little confuse now and the reason is that I was probably not enough clear, let me explain again please.

the level of current needs to be adjustable (from 0 to 20 MA approx) should be

the level of current needs to be adjustable (from 0 to 20 MA approx) by PWM from MCU

In fact the PWM (on V2 supply) will be use only only to determine the value of constant current

My application will needs like (this is just an example)

PWM = 30% Constant current = 8 mA
PWM = 60 % Constant Current = 16 mA

etc

In all your ideas what solutions can achieve this ?

« Last Edit: June 08, 2023, 07:52:14 am by delphes123 »
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7374
  • Country: nl
  • Current job: ATEX product design
Re: Constant current source adjustable by PWM
« Reply #20 on: June 08, 2023, 07:57:18 am »
Buy a 20mA current regulator diode/led driver and place it in series with your transistor.
Like NSI45020A
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1537
  • Country: au
Re: Constant current source adjustable by PWM
« Reply #21 on: June 08, 2023, 08:02:22 am »
My application will needs like (this is just an example)

PWM = 30% Constant current = 8 mA
PWM = 60 % Constant Current = 16 mA

etc

In all your ideas what solutions can achieve this ?
Those are non-linear PWMs, for full scale of 20mA = 100% ?
This latest post does not mention PWM filtering, but previous ones do ?

Suggestions have already been made above.

If you really need to cover 0mA (or let's say 5uA) to 20mA, just use an OpAmp.
Otherwise, you will need to calibrate the transfer of a bipolar design.
 

Online magic

  • Super Contributor
  • ***
  • Posts: 6778
  • Country: pl
Re: Constant current source adjustable by PWM
« Reply #22 on: June 08, 2023, 08:04:22 am »
Like NSI45020A
20 mA ± 10%? OP's circuit can do better than that if the 5V rail is any good.


And this thread is going nowhere without the OP clarifying if it's supposed to be a DC current source adjusted by PWM or a PWM'd 20mA current source.
« Last Edit: June 08, 2023, 08:08:50 am by magic »
 
The following users thanked this post: schmitt trigger

Offline delphes123Topic starter

  • Contributor
  • Posts: 33
  • Country: be
Re: Constant current source adjustable by PWM
« Reply #23 on: June 08, 2023, 08:08:32 am »

It's a DC current source adjusted by PWM
 

Online magic

  • Super Contributor
  • ***
  • Posts: 6778
  • Country: pl
Re: Constant current source adjustable by PWM
« Reply #24 on: June 08, 2023, 08:27:32 am »
So it looks like you need to RC filter it down to the average DC voltage and then do something with it.

The "something" could indeed be as simple as 2N3904 with 220Ω from the emitter to ground, if this level of accuracy doesn't bother you.


One completely different option is "open loop buck" - i.e. a buck converter with the switch transistor driven directly by the PWM signal. But this needs an inductor instead of capacitors and may or may not be cost effective; I'm not very familiar with volume pricing of passives.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf