Author Topic: A current source with non-linear control?  (Read 14117 times)

0 Members and 1 Guest are viewing this topic.

Offline miceuzTopic starter

  • Frequent Contributor
  • **
  • Posts: 387
  • Country: lt
    • chirp - a soil moisture meter / plant watering alarm
A current source with non-linear control?
« on: August 25, 2015, 11:34:44 pm »
I'm building a linear LED dimmer. I can't do PWM because I need it to be completely flicker free and have an extremely smooth fading (it's used for LED lightning in movie production). That's why I'm using a standard current source and burning the excess power in a transistor:



The circuit works allright and is already used in production, the only problem is the human eye - it has a logarythmic response to the light, it's said to be around the power of 2.4. The led becomes bright at the very beginning of the pot range and does not change much to the eye for the rest of the range (Yes, I'm sure I'm not overdriving the led, max current I'm delivering is nominal current for the led, led luminosity seems to be fairly linear to current) 

If I would do it in digital I would introduce a nonlinearity in this way:
Pout = (valuevalue/valuemax) ^ 2.4 * valuemax
Giving me this response:


My question is - how can I introduce such nonlinearity into my circuit in analog?

I've tried using a rotary encoder and replacing the pot with PWM DAC, but I lack resolution both in encoder detents and in PWM to achieve smoothness. I've also tried to use a logarithmic audio potentiometer, but the curve felt wrong.
« Last Edit: August 25, 2015, 11:44:23 pm by miceuz »
 

Offline moffy

  • Super Contributor
  • ***
  • Posts: 3017
  • Country: au
Re: A current source with non-linear control?
« Reply #1 on: August 25, 2015, 11:57:33 pm »
Use a logarithmic pot for your control element, they are very common and used in audio, because the ear hearing is logarithmically based.
 

Offline Jay_Diddy_B

  • Super Contributor
  • ***
  • Posts: 2985
  • Country: ca
Re: A current source with non-linear control?
« Reply #2 on: August 25, 2015, 11:59:37 pm »
Hi,

You can solve your problem by using a potentiometer with a log taper, (audio) sometimes called taper C.

http://sound.westhost.com/pots-f4.gif


I was typing the same thing !!

Jay_Diddy_B
 

Offline miceuzTopic starter

  • Frequent Contributor
  • **
  • Posts: 387
  • Country: lt
    • chirp - a soil moisture meter / plant watering alarm
Re: A current source with non-linear control?
« Reply #3 on: August 26, 2015, 12:13:59 am »
Ah! Seems the "log" pot I was using was of "commercial log" type, I was clearly able to see the discontinuity.

http://sound.westhost.com/pots.htm

http://sound.westhost.com/project01.htm

Offline Jay_Diddy_B

  • Super Contributor
  • ***
  • Posts: 2985
  • Country: ca
Re: A current source with non-linear control?
« Reply #4 on: August 26, 2015, 12:21:23 am »
Hi,

There is another technique that you can use:




The circuit requires that the pot is fed with a fixed voltage. I have used two 1N4148 to form a cheap 1.2V ref.
A resistor is added that bends the pot response.

You should be able to try this easily. It uses a 10K linear pot.

Jay_Diddy_B
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 22435
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: A current source with non-linear control?
« Reply #5 on: August 26, 2015, 01:28:51 am »
As it happens, there's a way to calculate the best resistor values for a resistor-shunted linear pot, to make it look as log-like as possible.  The trick is, a log pot never actually goes all the way to zero (or, it's not *supposed to*), so you put some resistance "below" the pot, and adjust the shunt value to get a somewhat similar curve.  It of course can't be perfect (mathematically speaking, the pot can only make, at best, a second order rational curve, a far cry from a transcendental log curve), but within 3dB for a 20dB range is reasonable.

Speaking of diodes, it would be quite reasonable to use a series of diodes, currents and voltages (added with op-amps) to make a simple, drifty, inaccurate, squaring function.  Or an adjustable gamma correction, for that matter.  The I(V) curve of a diode is exponential, so one can deliver a controlled current into a diode, measure the voltage, multiply the voltage by some gain factor (say with a pot and op-amp), then apply that voltage to another diode (carefully, of course), measuring the current into it.  The result is Io = Iin^gain ... give or take differences in temperature and manufacture in the diodes.  (Or usually transistors are used, which are a little easier to get the voltages and currents around.)

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline HackedFridgeMagnet

  • Super Contributor
  • ***
  • Posts: 2045
  • Country: au
Re: A current source with non-linear control?
« Reply #6 on: August 26, 2015, 02:14:40 am »
Sometimes also the log pot is wired in backwards and gives a stupidly fast transition. Reverse Log.
Probably not the case for you, but it does happen.

My Yamaha PC speakers had this.
« Last Edit: August 26, 2015, 02:16:15 am by HackedFridgeMagnet »
 

Offline Poe

  • Frequent Contributor
  • **
  • Posts: 263
Re: A current source with non-linear control?
« Reply #7 on: August 26, 2015, 03:40:56 am »
I would love to know more about the project.
 

Offline miceuzTopic starter

  • Frequent Contributor
  • **
  • Posts: 387
  • Country: lt
    • chirp - a soil moisture meter / plant watering alarm
Re: A current source with non-linear control?
« Reply #8 on: August 26, 2015, 08:17:26 am »
I would love to know more about the project.

A friend of mine is a professional camera man and a CNC machinist. He has created small LED panels for himself:

http://blog.technariumas.lt/post/116376606931/led-panel-for-cinema-lighting
http://blog.technariumas.lt/post/121437145531/3d-printing-a-grid-for-led-panels
http://blog.technariumas.lt/post/121501911836/a-cnc-cut-aluminium-case
http://blog.technariumas.lt/post/122237647061/led-dimmer-on-set

Pannels are 6W each, powered from a car battery or from a camera battery.

Me and several people from our hackerspace are helping him with 3D printing and electronics. We are going to make a product out of this eventually, we will probably open the design.

I've made a rough and ready 4 channel analog dimmer as described above, then I've tried to make a single channel digital version as this would allow various tricks like remembering light levels, blinking, sequencing, etc: https://github.com/Miceuz/linear-led-dimmer This proved to be inferior as encoder I've used and PWM dac both have too little resolution, now I'm going in two directions - making a compact single channel analog version and using 100 line optical encoder and a proper 16bit  dac for digital one.


Online rvalente

  • Frequent Contributor
  • **
  • Posts: 829
  • Country: br
Re: A current source with non-linear control?
« Reply #9 on: August 26, 2015, 02:24:52 pm »
Why not use a buck converter and save this energy waste?

The output current is very very constant, check this very simple circuit, the current ripple is only 10mA...

This is just an example, almost any comparator will do (and check the proper ref voltage).

In this case I was just testing to use the internal ref voltage of 0.25V for the PIC16F677 internal comparator.
 

Offline Andy Watson

  • Super Contributor
  • ***
  • Posts: 2340
Re: A current source with non-linear control?
« Reply #10 on: August 26, 2015, 02:31:38 pm »
... then I've tried to make a single channel digital version as this would allow various tricks like remembering light levels, blinking, sequencing, etc:
If a digital option is being considered I would forget the analogue mapping scheme and do the "trick" digitally. A simple 8 pin PIC will give you 256 levels without breaking a sweat.
 

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 11163
  • Country: fi
Re: A current source with non-linear control?
« Reply #11 on: August 26, 2015, 03:20:31 pm »
Just use PWM. It will be so much easier on thermal design, and if you ever want to run that on batteries, energy waste is a problem.

You can use high enough frequency so that it's flicker-free for any type of camera. Say, tens of kHz.

If you still feel that flicker is a problem, add an LC filter, and it will become an unregulated buck converter. But really, this is not needed, unless you do some seriously high FPS stuff.
 

Online rvalente

  • Frequent Contributor
  • **
  • Posts: 829
  • Country: br
Re: A current source with non-linear control?
« Reply #12 on: August 26, 2015, 05:35:17 pm »
I just do not see any point for not choosing a switched mode topology (being just PWM, a regulated or unregulated buck), the flickering light on camera is just a problem if the modulation matches or is harmonic of the scan frequency, if you go way way faster (lets say, 5....10 times more) you won't see this effect... 
 

Offline ajb

  • Super Contributor
  • ***
  • Posts: 2867
  • Country: us
Re: A current source with non-linear control?
« Reply #13 on: August 26, 2015, 08:38:14 pm »
... then I've tried to make a single channel digital version as this would allow various tricks like remembering light levels, blinking, sequencing, etc:
If a digital option is being considered I would forget the analogue mapping scheme and do the "trick" digitally. A simple 8 pin PIC will give you 256 levels without breaking a sweat.

8 bits is not really adequate for smooth dimming of an LED source without visible steps.  You want at least 12 bits of output resolution, but you can map an 8-bit input to the 12-bit output via a simple quadratic function and achieve quite nice results that are close enough to visually linear for most purposes.  With especially big, bright sources, though, even 12 bit dimming will show visible* steps at the low end of the dimming curve, so 16 bits with either a higher resolution control input or interpolation from an 8-bit input is required for dead smooth fading through the low end.  Of course 16-bit PWM at several kHz requires a pretty ridiculous counter frequency for a small MCU, which is tricky.  Using a DAC to control a buck driver may be a better bet.

* Visible when viewed directly with the naked eye, anyway, whether or not the steps are visible via the camera will depend on the filming conditions.
« Last Edit: August 26, 2015, 08:41:54 pm by ajb »
 

Offline Marco

  • Super Contributor
  • ***
  • Posts: 7742
  • Country: nl
Re: A current source with non-linear control?
« Reply #14 on: August 26, 2015, 09:26:11 pm »
Just use PWM. It will be so much easier on thermal design, and if you ever want to run that on batteries, energy waste is a problem.

You can use high enough frequency so that it's flicker-free for any type of camera. Say, tens of kHz.

If you still feel that flicker is a problem, add an LC filter, and it will become an unregulated buck converter. But really, this is not needed, unless you do some seriously high FPS stuff.

Even if you're really paranoid about the flicker you could use a switch mode power supply to charge a capacitor to feed the LED, stopping the charge cycles once V-drain on the MOSFET of OP's linear current source gets too high.
 

Offline miceuzTopic starter

  • Frequent Contributor
  • **
  • Posts: 387
  • Country: lt
    • chirp - a soil moisture meter / plant watering alarm
Re: A current source with non-linear control?
« Reply #15 on: August 27, 2015, 06:22:32 am »
... then I've tried to make a single channel digital version as this would allow various tricks like remembering light levels, blinking, sequencing, etc:
If a digital option is being considered I would forget the analogue mapping scheme and do the "trick" digitally. A simple 8 pin PIC will give you 256 levels without breaking a sweat.

... and that proved to be too little resolution - you can clearly see light levels jump and this is a nono when fading during the take.

Offline miceuzTopic starter

  • Frequent Contributor
  • **
  • Posts: 387
  • Country: lt
    • chirp - a soil moisture meter / plant watering alarm
Re: A current source with non-linear control?
« Reply #16 on: August 27, 2015, 06:24:31 am »
Why not use a buck converter and save this energy waste?

Good point! I was looking at switcher LED drivers, but all of them were too inaccurate or resulted in too much current ripple, didn't think to roll a discrete one, thanks!  :-+

Offline Siwastaja

  • Super Contributor
  • ***
  • Posts: 11163
  • Country: fi
Re: A current source with non-linear control?
« Reply #17 on: August 27, 2015, 07:05:57 am »
A self-oscillating current-mode buck would be easy - a shunt resistor and a fast comparator which turns the FET on when the current is below the setpoint. Inductor ripple current would be equal to comparator hysteresis, and inductance defines the frequency. "Flip" the buck topology around so that you can use a N-channel FET and control it directly from the comparator... I'm quite sure this is the simplest way to make a relatively precise and stable current control for LEDs or battery charging.  :-/O
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2322
  • Country: au
Re: A current source with non-linear control?
« Reply #18 on: August 27, 2015, 08:16:02 am »
Why not use a buck converter and save this energy waste?

The output current is very very constant, check this very simple circuit, the current ripple is only 10mA...

Um, that's not a buck converter. That's a linear regulator with a comparator slapped in place of the op-amp, and a control loop instability screaming along at 2.5MHz. It's barely 50% efficient.

You don't make a buck converter by just slapping a comparator where the op-amp is in a linear regulator. The two classic methods are a sawtooth on the reference, or adding hysteresis to the comparator as suggested by Siwastaja. Adding hysteresis to your comparator (standard Schmitt trigger arrangement) brings the frequency down to 100kHz, and efficiency goes to 77% (which can be attributed to the use of a BJT).

I was looking at switcher LED drivers, but all of them were too inaccurate or resulted in too much current ripple, didn't think to roll a discrete one, thanks!  :-+
Rolling a discrete one is certainly an option, but I'd advise against using that circuit as a reference for the reasons listed above. At the very least, don't use a BJT.
« Last Edit: August 28, 2015, 01:44:14 am by rs20 »
 

Online rvalente

  • Frequent Contributor
  • **
  • Posts: 829
  • Country: br
Re: A current source with non-linear control?
« Reply #19 on: August 27, 2015, 02:10:24 pm »
Yes, that is a buck converter, contains a switch, a coil and a diode.

True, should use a comparator and change the BJT by FET or similar, but proves the point of how simple it is to make one, specially for current control on a LED.

The IRS2980 its just that (yest, have the internal hysteresis and the N Channel FET)

http://www.irf.com/product-info/datasheets/data/irs2980spbf.pdf
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2322
  • Country: au
Re: A current source with non-linear control?
« Reply #20 on: August 27, 2015, 03:02:44 pm »
Yes, that is a buck converter, contains a switch, a coil and a diode.

So a circuit is defined by the components that make it up, and not the behaviour it exhibits? I don't want to get into a nomenclature debate, the point is it's an awful buck converter if you must insist on allowing to be called a buck converter at all. A healthy buck converter has a triangle wave current waveform, not a distended sine wave.

...but proves the point of how simple it is to make one, specially for current control on a LED.

If you had taken the time to add the two resistors to give the comparator hysteresis, I wouldn't be criticizing the design. But as it stands, your attempts to prove how "simple" it is have resulted in a circuit so oversimplified that it whines at an impractical 2.5MHz due to simple instability rather than engineered switching, and is just not worth building in real life. And built using a $12 comparator to boot. This is just confusing to a newbie who will come along, find your circuit, see it described as a "buck converter", and then see the transistor goes up in smoke.
« Last Edit: August 28, 2015, 01:43:58 am by rs20 »
 

Online rvalente

  • Frequent Contributor
  • **
  • Posts: 829
  • Country: br
Re: A current source with non-linear control?
« Reply #21 on: August 27, 2015, 03:05:10 pm »
Dude, please, do not be pick.

I got the first comparator avaiable in LTSpice, just to show some point. There are thousands of different ways for doing the same thing.

Let's just state you are correct, I'm not here to get into forum fights.
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2322
  • Country: au
Re: A current source with non-linear control?
« Reply #22 on: August 28, 2015, 01:43:05 am »
I was looking at switcher LED drivers, but all of them were too inaccurate or resulted in too much current ripple, didn't think to roll a discrete one, thanks!  :-+

I'm wondering what you mean by "too inaccurate"? There's just a knob you turn and it gets brighter and dimmer, right, so what does "accurate" mean? And when you say too much current ripple, what do you mean? Did you try building it and see problems in the video footage, or did you just simulate it? If you simulated it, what voltage & frequency ripple did you see? Why didn't you just increase the frequency or get a bigger inductor, which would both reduce ripple voltage? There's a whole of bunch of questions to resolve here before resorting to linear, or even discrete solutions. Having said that, a discrete switching solution would be fun to build, just be aware that it's still a PWM going into an inductor, so you're still going to have to decide what frequency and voltage of ripple you're willing to allow.


Dude, please, do not be pick.

Let's just state you are correct, I'm not here to get into forum fights.
Sorry, I didn't mean to be forceful. But if I see a bad/incomplete design suggested on this forum, I will point it out to protect newbies from trying to use it, and I will respond appropriately to attempts to defend such a design. It's not personal or a fight, it's just a bad/incomplete design.
 

Offline DanielS

  • Frequent Contributor
  • **
  • Posts: 798
Re: A current source with non-linear control?
« Reply #23 on: August 28, 2015, 02:18:27 am »
If you use a PWM controller in constant-current mode, you won't have any observable flicker since the ripple current will be in the tens of kHz or higher - many modern CC PWMs for LEDs operate at over 500kHz.

As far as resolution goes, you can add DC bias to the current sense/feedback using a resistor network to achieve 0-100% analog dimming.
 

Offline C

  • Super Contributor
  • ***
  • Posts: 1346
  • Country: us
Re: A current source with non-linear control?
« Reply #24 on: August 28, 2015, 02:41:09 am »
In place of using a linear dac for complete range, you may want to use a non linear dac.
The digital phone system does this with it's A-law and u-law dac's.
You could do this by having one dac set the reference for a second dac

This would let you have small step sizes at one end of range and change to larger step sizes at other end of range.

C

 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf