A current source with non-linear control? - Page 1
Forum section: electronics / projects

author: miceuz
author_rank: Frequent Contributor
timestamp: August 25, 2015, 11:34:44 pm
content: 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 * valuemaxGiving 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.

author: moffy
author_rank: Super Contributor
timestamp: August 25, 2015, 11:57:33 pm
content: Use a logarithmic pot for your control element, they are very common and used in audio, because the ear hearing is logarithmically based.

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: August 25, 2015, 11:59:37 pm
content: 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.gifI was typing the same thing !!Jay_Diddy_B

author: miceuz
author_rank: Frequent Contributor
timestamp: August 26, 2015, 12:13:59 am
content: 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.htmhttp://sound.westhost.com/project01.htm

author: Jay_Diddy_B
author_rank: Super Contributor
timestamp: August 26, 2015, 12:21:23 am
content: 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

author: T3sl4co1l
author_rank: Super Contributor
timestamp: August 26, 2015, 01:28:51 am
content: 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

author: HackedFridgeMagnet
author_rank: Super Contributor
timestamp: August 26, 2015, 02:14:40 am
content: 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.

author: Poe
author_rank: Frequent Contributor
timestamp: August 26, 2015, 03:40:56 am
content: I would love to know more about the project.

author: miceuz
author_rank: Frequent Contributor
timestamp: August 26, 2015, 08:17:26 am
content: Quote from: Poe on August 26, 2015, 03:40:56 amA 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-lightinghttp://blog.technariumas.lt/post/121437145531/3d-printing-a-grid-for-led-panelshttp://blog.technariumas.lt/post/121501911836/a-cnc-cut-aluminium-casehttp://blog.technariumas.lt/post/122237647061/led-dimmer-on-setPannels 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-dimmerThis 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.

author: rvalente
author_rank: Frequent Contributor
timestamp: August 26, 2015, 02:24:52 pm
content: 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.

author: Andy Watson
author_rank: Super Contributor
timestamp: August 26, 2015, 02:31:38 pm
content: Quote from: miceuz on August 26, 2015, 08:17:26 amIf 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.

author: Siwastaja
author_rank: Super Contributor
timestamp: August 26, 2015, 03:20:31 pm
content: 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.

author: rvalente
author_rank: Frequent Contributor
timestamp: August 26, 2015, 05:35:17 pm
content: 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...

author: ajb
author_rank: Super Contributor
timestamp: August 26, 2015, 08:38:14 pm
content: Quote from: Andy Watson on August 26, 2015, 02:31:38 pm8 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.

author: Marco
author_rank: Super Contributor
timestamp: August 26, 2015, 09:26:11 pm
content: Quote from: Siwastaja on August 26, 2015, 03:20:31 pmEven 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.

author: miceuz
author_rank: Frequent Contributor
timestamp: August 27, 2015, 06:22:32 am
content: Quote from: Andy Watson on August 26, 2015, 02:31:38 pm... 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.

author: miceuz
author_rank: Frequent Contributor
timestamp: August 27, 2015, 06:24:31 am
content: Quote from: rvalente on August 26, 2015, 02:24:52 pmGood 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!

author: Siwastaja
author_rank: Super Contributor
timestamp: August 27, 2015, 07:05:57 am
content: 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.

author: rs20
author_rank: Super Contributor
timestamp: August 27, 2015, 08:16:02 am
content: Quote from: rvalente on August 26, 2015, 02:24:52 pmUm, 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 at2.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).Quote from: miceuz on August 27, 2015, 06:24:31 amRolling 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.

author: rvalente
author_rank: Frequent Contributor
timestamp: August 27, 2015, 02:10:24 pm
content: 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

author: rs20
author_rank: Super Contributor
timestamp: August 27, 2015, 03:02:44 pm
content: Quote from: rvalente on August 27, 2015, 02:10:24 pmSo 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 anawfulbuck converter if you must insist on allowing to be called a buck converter at all. Ahealthybuck converter has a triangle wave current waveform, not a distended sine wave.Quote from: rvalente on August 27, 2015, 02:10:24 pmIf 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$12comparator 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.

author: rvalente
author_rank: Frequent Contributor
timestamp: August 27, 2015, 03:05:10 pm
content: 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.

author: rs20
author_rank: Super Contributor
timestamp: August 28, 2015, 01:43:05 am
content: Quote from: miceuz on August 27, 2015, 06:24:31 amI'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& frequencyripple 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.Quote from: rvalente on August 27, 2015, 03:05:10 pmSorry, I didn't mean to be forceful. But if I see a bad/incomplete design suggested on this forum, Iwillpoint 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.

author: DanielS
author_rank: Frequent Contributor
timestamp: August 28, 2015, 02:18:27 am
content: 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.

author: C
author_rank: Super Contributor
timestamp: August 28, 2015, 02:41:09 am
content: 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 dacThis would let you have small step sizes at one end of range and change to larger step sizes at other end of range.C

author: Hideki
author_rank: Frequent Contributor
timestamp: August 28, 2015, 09:58:51 pm
content: Look up exponential (or antilog) amplifiers.