1

I have a 10-bit DAC that outputs a voltage between 0 and 3V. This signal controls a current-driver for LEDs. I need to compensate the "log" behavior of the LEDs, otherwise the first steps are too much different than the last ones. And, more important, the very first step (1 LSB of DAC) is way too intense for the project requirement.

The straightforward option is to increase the resolution of the DAC (i.e. 16-bit) and change the curve in the firmware. I know how to do, but I'm looking for a different solution.

I would like to do the same in hardware, using an op-amp for a anti-log operation. A rough simulation of the basic circuit:

enter image description here

give me this result:

enter image description here

The region between 0.3 V and 0.7 V is the one I'm looking for:

enter image description here

But there are several problems:

  • until the diode begin to conduct the output is 0 V regardless the input voltage
  • the exp curve reaches the negative rail too early

Instead, I want a nice curve that smoothly increase its value and reach the negative rail (or even better the -3V) when the input signal is at 3V. This is mandatory in order to use the whole DAC output range.

I tried to put a resistor in series or in parallel to the diode but (as expected) it just combines the two behaviors.

How should I change my circuit to achieve this transfer function?

enter image description here

Ideally, the best it to fine-tune how far the curve differs from the linear. It's easy to do in firmware, but I'm trying to do this in hardware.

Mark
  • 1,161
  • 6
  • 23

1 Answers1

3

LED brightness is pretty linear with current, so I guess you meant your problem is the log perception of our eyes.

The circuit in your question imposes a voltage on the diode, which will cause problems because the diode's dynamic impedance is quite low and its threshold voltage strongly depends on temperature. So at the upper end of the range, a very small variation in voltage will cause a large variation in current, and it will be impossible to set the maximum level.

With two resistors and one diode you can make an IV curve with two slopes. When voltage is low enough, the diode doesn't conduct, and the opamp's gain is -R3/R2. When the diode conducts, since R1 is much lower than R2, the opamp's gain increases, which results in a curve with two straight segments of different slopes, which are adjustable with R1 and R2. In this case the diode's threshold still depends on temperature, but the series resistor will keep current in check.

enter image description here

The other circuit uses a long tailed pair as a multiplier to make a squaring circuit. It is a simplified version of an actual squaring circuit, the real one would require both differential voltage and tail current to be proportional to the input. I prefer the first circuit with the diode, it's simpler.

Note this is much easier to do with PWM. If you slow down the switching of the MOSFET with a large gate resistor, so that it takes several PWM steps to turn on, you both get lower noise emissions and a "soft start" over the few PWM steps.

Bonus:

Modifying the DAC voltage before the opamp that drives the LED current source won't remove this opamp's offset, which would be a problem when sensing low current on a low value resistor. For example if you use 1R resistor, with 1V swing on it, LSB on a 10 bit DAC would be 1mV which is already within the input offset voltage of many opamps.

A cheap solution would be to use two ranges: either switch two current sense resistors with low RdsON MOSFETs, or make two current sources with different sense resistor values, that can be enabled or disabled with GPIOs.

If you need accuracy, then the second solution would be better as it doesn't introduce a temperature-dependent RdsON into the circuit. In this case you can get two accurate current ranges.

bobflux
  • 70,433
  • 3
  • 83
  • 203
  • For a design requirement I cannot use any PWM in this project. I was on the right way trying with the resistor, but I didn't think to add both... – Mark Feb 11 '23 at 09:59
  • Thanks for the accept! I've added another idea into the answer – bobflux Feb 11 '23 at 10:59