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

0 Members and 1 Guest are viewing this topic.

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7369
  • Country: nl
  • Current job: ATEX product design
Re: Constant current source adjustable by PWM
« Reply #25 on: June 08, 2023, 09:23:57 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.
Have you seen any specifications?
 

Offline delphes123Topic starter

  • Contributor
  • Posts: 33
  • Country: be
Re: Constant current source adjustable by PWM
« Reply #26 on: June 08, 2023, 01:19:19 pm »



NS145020A is a good component but it has fixed 20 mA constant current, how I can manage with this component any other value of current between 0 and 20 mA ?
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 6761
  • Country: pl
Re: Constant current source adjustable by PWM
« Reply #27 on: June 08, 2023, 04:06:39 pm »
You could PWM the power supply to this chip and get a lower average current, but it would be pulsed 20mA rather than constant 5mA, 15mA or whatever.
Some people assumed that you are OK with the output being PWM'd, hence such suggestions.

It seems you are not, so filtering is the way to go. Maybe 1kΩ and 1μF would be good enough for Australia? Two easily available passives, not too expensive in SMD...
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1535
  • Country: au
Re: Constant current source adjustable by PWM
« Reply #28 on: June 09, 2023, 05:36:28 am »
NS145020A is a good component but it has fixed 20 mA constant current, how I can manage with this component any other value of current between 0 and 20 mA ?
What exactly do you need to drive with this? LEDs are quite different from instruments 4~20mA.
What precision and temperature variation do you need ?
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5896
  • Country: es
Re: Constant current source adjustable by PWM
« Reply #29 on: June 09, 2023, 01:46:16 pm »
Trying to do this with discretes makes no sense at all, you'll end using more parts, making the design more complex and perform a lot worse.
You have LM324 / LM358 op-amps for 3 cents in lcsc, or around 10 cents in normal distributors.
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline magic

  • Super Contributor
  • ***
  • Posts: 6761
  • Country: pl
Re: Constant current source adjustable by PWM
« Reply #30 on: June 09, 2023, 04:57:50 pm »
Nope, it's making the design more complex with more parts OR perform worse. The latter may be acceptable.

And LM358 can't implement this kind of current sink by itself, not without ugly kludges which may or may not work (tie OUT to V+ and IN- to GND, minimum current is 1mA, no warranty :P). So you are looking at more external components and more than 3 cents.
 

Offline delphes123Topic starter

  • Contributor
  • Posts: 33
  • Country: be
Re: Constant current source adjustable by PWM
« Reply #31 on: June 09, 2023, 06:10:37 pm »

In order to clarify , it is not a led driving, it is more complex to describe the use case, but it is a resistive charge (with probably a very very low capacitive)

I need to produce a constant current at different level between 0 to 20 mA max during a certain amount of time (very slow events)

like 0 to 2 sec = 20 mA
2 to 4 sec = 10 mA
etc

Precision is not very impressive let say 10% is ok.

I would prefer for many reasons a very simple transistor solution with PWM to control the level of mA.
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1535
  • Country: au
Re: Constant current source adjustable by PWM
« Reply #32 on: June 09, 2023, 08:18:49 pm »

In order to clarify , it is not a led driving, it is more complex to describe the use case, but it is a resistive charge (with probably a very very low capacitive)…
Precision is not very impressive let say 10% is ok.

I would prefer for many reasons a very simple transistor solution with PWM to control the level of mA.
Is that 10% of full scale, or 10% of output, meaning 2mA is within 200uA , or now 1% of full scale.

What voltage(s) is across your ‘resistive charge’ ? The power in the output device needs to be considered.

How many of these will you make ? What is operating temperature range?

Are you ok with a calibrate curve (look up table ) in flash ? That will be needed to get 2mA@10%.

You probably would not need to curve re-calibrate every single unit, but single point calibrate will give you better performance, so you should allow for that, in your production costing spreadsheet and jigs.
In practical terms, I’d expect same-reel calibrate to be ok here.
An opamp does not need a look-up-table, but you ( or your tutor ?) has excluded the opamp.

 

Offline delphes123Topic starter

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

Is 10 % of ouput 10mA +- 1 mA

Voltage with be variable due to constant current, but it is powered by 12 Volts initially

it will operate between 10 and 30 °c

Yes of course I can have a lookup table and calibration can be made for each.
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7369
  • Country: nl
  • Current job: ATEX product design
Re: Constant current source adjustable by PWM
« Reply #34 on: June 09, 2023, 10:54:07 pm »



NS145020A is a good component but it has fixed 20 mA constant current, how I can manage with this component any other value of current between 0 and 20 mA ?
You drive it with a transistor, which has the PWM signal on it's base/drain, and then smooth the signal (bypass it) with a capacitor.
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1535
  • Country: au
Re: Constant current source adjustable by PWM
« Reply #35 on: June 10, 2023, 12:04:04 am »

Is 10 % of ouput 10mA +- 1 mA

Voltage with be variable due to constant current, but it is powered by 12 Volts initially

it will operate between 10 and 30 °c

Yes of course I can have a lookup table and calibration can be made for each.

Good, here are a couple of options. They assume you have access to the 12V and it is regulated.
Test is by a linear ramp, with 5ms == 5V and R1 is used as an ideal-load check, allows simple error as a difference plot I(R1)-I(R2)

First is a classic/simple PNP.NPN pair that gives nominal VBE compensation, but it cannot quite get to 0mA, min is around 100uA, due to Vbe effects. 100uA may be 'good enough' for your needs.

Second design splits the emitter resistor, and steers some base current to allow a reverse offset effect and that can get closer to 0mA
Here, I've adjusted it for a ballpark 12 bit ADC 1-LSB as a zero-point.

The error curves that you need to compensate, in a table, you can see in the graphs.
You should closely thermally couple the Q1.Q2, and Q1 needs to have decent HFE.

Addit : added a 5V bias version, does not need 12V connection, and the lower RE does not need a split to give ~5uA zero compensate.
Drive is divided by 2, to give some bias on R2, which also improves the Q1.C load-range to below 5V
« Last Edit: June 10, 2023, 03:45:15 am by PCB.Wiz »
 

Offline delphes123Topic starter

  • Contributor
  • Posts: 33
  • Country: be
Re: Constant current source adjustable by PWM
« Reply #36 on: June 10, 2023, 09:10:06 am »

Thanks alot I did simulation and it works, just last question remember V2 is from PWM (MCU) does it needs any filter on the output to drive transistor base ?
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1535
  • Country: au
Re: Constant current source adjustable by PWM
« Reply #37 on: June 10, 2023, 07:34:31 pm »

Thanks alot I did simulation and it works, just last question remember V2 is from PWM (MCU) does it needs any filter on the output to drive transistor base ?
Yes, I just left that off to allow simple ramp testing.
The 10k PNP base resistor can split to a double RC filter to suit your Pwm.
If you only slow change this, there is plenty of scope to filter.
 

Offline delphes123Topic starter

  • Contributor
  • Posts: 33
  • Country: be
Re: Constant current source adjustable by PWM
« Reply #38 on: July 20, 2023, 07:27:18 pm »
@pcb.wiz

The first solution you give me works perfect as same as simulation you did , could you change V1 to 5 V for me and tell me what value of R4 need to be there ?

Thanks
Regards
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1535
  • Country: au
Re: Constant current source adjustable by PWM
« Reply #39 on: July 20, 2023, 07:55:50 pm »
@pcb.wiz

The first solution you give me works perfect as same as simulation you did , could you change V1 to 5 V for me and tell me what value of R4 need to be there ?

Thanks
Regards
#35 above already has a 5V sim, with other minor changes too. R4=3k3
 

Offline delphes123Topic starter

  • Contributor
  • Posts: 33
  • Country: be
Re: Constant current source adjustable by PWM
« Reply #40 on: July 22, 2023, 01:27:47 pm »

on #35 I only see V1 = 12V
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19494
  • Country: gb
  • 0999
Re: Constant current source adjustable by PWM
« Reply #41 on: July 22, 2023, 04:16:30 pm »
The circuit attached to the original post won't work. D1 & D2 will blow up, as there's nothing to limit the current.

Is it really PWM to a linear constant current, or just PWM'd constant current which is required? Is the 5V supply well-regulated?

Is it a purely resistive load?
 

Offline PCB.Wiz

  • Super Contributor
  • ***
  • Posts: 1535
  • Country: au
Re: Constant current source adjustable by PWM
« Reply #42 on: July 22, 2023, 08:24:42 pm »

on #35 I only see V1 = 12V

 PNP_NPN_current_Sink_5.PNG has a new V3 added, for 5V supply to R4
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf