I use a constant current control design to control the current through the halogen lamp, which typically runs at 800-900 mA

Resistor MPN: PCS2512DR1000ET

DAC: MCP4725


simulate this circuit – Schematic created using CircuitLab

The circuit itself works as I expect it to. The issue I have is with the ambient temperature rising or dropping, which reduces the current that goes through the lamp.

I tested heating with the heat gun the electronics only, or the lamp only, and the result is the same. Increasing temperature on the electronics only increases current on the lamp, and increasing temperature on the lamp only reduces the brightness of the lamp (its performance eventually). The current increase/decrease is in the scale of mA (2-3mA) and 5mA max, but it is enough to cause some trouble in our measurements.

Since we make precision devices that are calibrated with the halogen lamp's brightness/intensity, we want the current to be as steady as possible during the variations of the ambient temperature.

We do try to keep the ambient temperature steady for the measurements, but some measurements might take more than 1 day and it's preferred if we did not leave the air condition on all the time. So I am trying to figure out a way to compensate the ambient temperature changes.

I have thought only one practical way of doing this. It is to add a NTC resistor in series with the halogen lamp:


simulate this circuit

I have not tested the circuit with the NTC resistor yet, but I will in the next weeks. I might as well try to use a 100mΩ NTC or PTC resistor instead of R1 and see how the circuit behaves, but overall the idea is to play with NTC resistors.

The physical layout:

The white line is the high current flow. The black/red wires on the left go on the resistor from the multimeter to measure the voltage drop for my tests. In the picture I do not have the heatsink soldered on the MOSFETs. (Those are two parallel MOSFETs)

current controlled source

Bottom layer is a copper pour GND layer

bottom copper pour

I know there is no a way to solve this issue 100%, so I try to come op with ideas to reduce the impact of ambient temperature in this system.

Other ways I have thought of reducing this problem:

  1. Measure the ambient temperature and adjust the DAC voltage (aka change the current drawn based on ambient temperature). This is tricky since DACs have a quantum scaling, like the one I use is 1024 steps, and each step is 17 mA, which is a lot, considering 4-5 mA difference due to ambient already cause us trouble. But I could try making a system that has the ability to control the current on the 1-2 mA range, that would be useful.

  2. Use Low ppm/oC components. That's the most obvious one. I actually set my soldering iron to 200 oC and was touching different components, turns out the DAC and the MOSFETs are the ones that when hotter contributed more to the current change. (Still, we are talking about 2-3 mA of change, but to out measurements its important)

  3. Use heatsinks and forced air to cool the components. This helps in the summer, but in winter when we use the air condition vs during the night when the air condition is off, we see the differences.

  4. I am also thinking of separating the control circuit (the op amp and the DAC) with the "high current" side (the Halogen lamp, the MOSFET and the resistor). Because the GND voltage near the high current electronics is messing with the DAC's accuracy and reference voltage of the Op amp. I guess when the temperature rises, the GND voltage around the high current components also rises due to the increase of the resistance of the copper. I want to separate them using a MOAT like so: https://electronics.stackexchange.com/a/430095/252145

  5. I measured the current that is drawn from the power supply while I heat up the 100 mΩ resistor only, and the current drawn reduced. And this resistor has positive temperature coefficient. I was thinking, to replace that resistor with a one that has a larger temperature coefficient. So when all the components get their temperature increased and as a result, more current is drawn, the resistor with its higher temperature coefficient will balance it.


  • Any ideas (except of the ones I mentioned) to improve my system's performance over temperature change?

  • Is any of my ideas not leading me in the right direction? Especially the 5th idea and the NTC in series resistor idea.

  • \$\begingroup\$ Putting a NTC resistor in the lamp should not change anything if the current source is working properly, as the current source will keep the current constant. Anyway, if the goal is to burn constant accurate power in the lamp, why measure current instead of power actually burned in the lamp? \$\endgroup\$
    – bobflux
    Jan 28, 2023 at 15:40
  • \$\begingroup\$ The lamp changes its resistance based on temperature and depending on how long it is operated. When its cold it has 0 omhs resistance. When its hot its around 5 ohms. I cannot know how much current flows from it since It changes its resistance. So I need to use a sense resistor anyway. \$\endgroup\$ Jan 28, 2023 at 15:43
  • 1
    \$\begingroup\$ I mean if the goal is constant brightness, then why not control lamp power (I*V) instead of current? Anyway, what is the 5V voltage reference and have you measured its temperature stability? Is the opamp oscillating (check with a scope)? \$\endgroup\$
    – bobflux
    Jan 28, 2023 at 15:54
  • \$\begingroup\$ to control lamp power I need to know how much current it flows through it. So I need the sense resistor anyway, and the current is the component that should be controlled, not the voltage. and actually controlling the current, I control the power. the op amp is not oscillating. I checked it. \$\endgroup\$ Jan 28, 2023 at 15:57
  • 1
    \$\begingroup\$ ultimately isn't the brightness what you want to control? Use a phototransistor to sense the lamp output, input its signal to the control circuit. \$\endgroup\$
    – Rich S
    Jan 28, 2023 at 20:30

3 Answers 3


Is any of my ideas not leading me in the right direction?

This is how the PCB tracking should be. I've also added questions about some components: -

enter image description here

If you don't have the 0 volts rails nailed down properly on this type of design you will get drift with temperature.

You should also ensure that the 7 volt supply isn't drooping too much either.

  • Op-amp is a good choice (on a 5 volt rail)
  • MOSFET is a good choice
  • Sense resistor is unknown and quite possibly a problem
  • DAC is an unknown and possibly a problem

Following an edit by the OP

The DAC choice is very poor for this type of accurate application. This is what it says in the data sheet about its internal reference: -

The DAC reference is driven from VDD directly

In other words, if the 5 volt Vcc is drifting then so is the DAC output. This now calls into question what provides the 5 volt DC power for the DAC and op-amp.

  • \$\begingroup\$ I edited the question adding the resistor and DAC information. Yes I want to change the DAC indeed if I find one with lower temp coefficient. And replace the sense resistor with one that has larger temperature coefficient (I talked about that in my 5th idea). Also, I have a single gnd pour on the bottom layer. I edited the question to add that info as well. So from what I understand, I will move the components closer (and around) the 0V of the sense resistor. \$\endgroup\$ Jan 28, 2023 at 15:41
  • \$\begingroup\$ A 1 mV DC change in the ground plane between DAC and sense resistor would be very significant. I mean you have a 2mA error in 800 mA and a 1 mV change in ground-plane voltage would be a significant effect. \$\endgroup\$
    – Andy aka
    Jan 28, 2023 at 15:42

It's possible to get good accuracy with these little DACs if their VCC/Reference comes from a nice stable source. If 5V from the microcontroller's VCC is used instead, it will be as bad as the accuracy and drift of the regulator providing this voltage, plus the ripple due to the micro's transient power supply current.

In addition the opamp buffer embedded in the DAC is only optimized for 12 bit accuracy, which makes sense because it's a 2-bit DAC. So the output offset drift versus temperature is way too high for your application. From DAC datasheet:

enter image description here

If the lamp typically runs at 900mA, then voltage on the 0.1 ohm sense resistor should be pretty low, less than 0.1V. Since your opamp is wired as follower, this means the DAC output voltage will also be around 0.1V, or a DAC code value of 80-82 out of 4096. This means you're wasting 98% of the DAC output range, essentially using only 7 bits out of the 12 bits you bought.

If you don't plan on exceeding 1A, a simple fix would be a voltage divider at the output of the DAC, for example divide the voltage by 40. So when the DAC outputs 5V, the driver opamp receives 0.125V on its input which corresponds to 1.25A through the 0.1 ohm resistor.

This won't fix problems with the voltage reference, because output is proportional to reference. It won't affect the driver opamp's offset, because it's after the divider. But it will reduce the DAC's output offset in proportion to the voltage divider's ratio.


Based on your soldering iron tests, another culprit is opamp input stage error drift.

Input offset voltage error is essentially a small battery between the two inputs. The voltage value of this error has a temperature coefficient, and appears at the circuit output multiplied by the circuit gain, adding to or subtracting from the desired output voltage.

Input bias current error is caused by the opamp input impedance not being infinite. There is a small current into or out of the opamp inputs, the current necessary to cause the input stage transistors to conduct. The value of this current has a temperature coefficient.

AND - The inverting and non-inverting inputs of the opamp are reversed in your schematic. Here is a quick innergoogle grab from

http://www.learningaboutelectronics.com/Articles/Current-source-circuit.php :

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.