# Why is this digital output circuit non-linear to the load?

I'm simulating a DAC which puts out 0-20mA, but in practice, the output varies depending on the load of 300 ohm resistor. If I using a 1k ohm resistor, then I get a different output current.

If you don't understand the schematic below, I can tell y'all that this circuit is a feedback circuit.

This is a P-gain controller. It uses two transistors - one NPN and one PNP to let the current flow through from 24V power supply.

I could use an NPN transistor only, but then the base voltage of the NPN transistor would be very high e.g 24V-0.6V. Therefore I'm using a PNP with a NPN transistor so the NPN transistor is releasing the "pressure" at the base of the PNP transistor so current can flow from emitter to collector.

And this is the feedback where we measure the voltage drop over the 160 ohm resistor.

Try to change the load of the 300 ohm resistor and change the input voltage of 1.0v to e.g. 3.3v and then change the load. Why does the current output changes? Should this circuit not be a feedback circuit?

• That sziklai pair adds a massive amount of loop gain. I'd say this would be hopelessly unstable in the real world. Apr 24, 2021 at 13:05
• Your Sziklai pair is adding a lot of gain and also a significant amount of delay to the loop. This is going to be very difficult to stabilize. Apr 24, 2021 at 13:06
• @DaveTweed So what should I do? Notice that this "sziklai" contains 10k resistors.
– DanM
Apr 24, 2021 at 13:06
• @DanielMårtensson Well, there are a couple of problems, at least. You bring up the fact that you are seeing a load-dependent variation. Well, that's entirely to be expected. A larger-valued load will require a larger voltage drop. But this added voltage drop also generates more current in the 10 k resistors driven by the opamp output and this "steals" current away from the load. Your 160 Ohm resistor accurately measures the sum, but it doesn't measure the load current. So if more current is diverted (because the load requires more voltage drop), then the load gets less.
– jonk
Apr 24, 2021 at 19:23
• @Circuitfantasist No. I don't have any -24. Double click on the op-amp and you will see the settings :)
– DanM
Apr 25, 2021 at 11:54

A better approach would be to use a high-side current mirror, which allows you to do your current sensing on the low side, vastly simplifying the circuit.

simulate this circuit – Schematic created using CircuitLab

• Nice, solves the stability problem as well. Apr 25, 2021 at 5:29
• A beautiful solution... We can see it everywhere - from classic dynamic load stages to sophisticated CFA output stages... I don't know why I have reservations about using it in such circuits with discrete elements... it still seems to me that it is intended for use in the internal structures of integrated circuits. Apr 25, 2021 at 6:33
• Wow! Excellent solution! I like it!
– DanM
Apr 25, 2021 at 9:33
• Dave! What do you think about replacing your NPN with a NPN+PNP transistor, like this? tinyurl.com/ygxwxjmj
– DanM
Apr 25, 2021 at 11:36
• @DanielMårtensson Now you're adding that massive loop gain again, destabilising things, for no good reason. Apr 25, 2021 at 12:24

I'm simulating a DAC which puts out 0-20mA, but in practice, the output varies depending on the load of 300 ohm resistor. If I using a 1k ohm resistor, then I get a different output current.

According to your simulation; with a 300 Ω load the output current is 6.206 mA, but with a 1 kΩ load it is 5.999 mA (0.207 mA less). We see why this is when we look at the current going through the right-hand 10k resistors. With a 300 Ω load it is only 0.043 mA, but with a 1 kΩ load it is 0.25 mA (0.207 mA more). The reason for this is that the 1 kΩ load drops more voltage (6 V vs 1.86 V), increasing the voltage across the 10k resistors. The sensed current is the same in both cases, but it includes the current through the 10k resistors. Therefore the 1 kΩ load gets less current than the 300 Ω load because more of the sensed current is 'stolen' by the 10k resistors.

You can eliminate this loading effect by buffering the sense resistor voltage, like this:-

simulate this circuit – Schematic created using CircuitLab

• Try to increase these 10k ohm resistors to e.g 200k. So all you have done is to place an op-amp buffer? I like your solution :)
– DanM
Apr 25, 2021 at 13:57

... in practice, the output varies depending on the load of 300 ohm resistor. If I using a 1k ohm resistor, then I get a different output current.

This means that, for some reason, your circuit does not fulfill its main purpose of maintaining a constant current.

Conceptually, the circuit solution is correct. Because the load is grounded, the current is measured through a high side "floating" current-sensing resistor... and this requires the use of a differential amplifier.

The two transistors form not exactly a Sziklai pair because the emitter of the NPN transistor and the collector of the PNP transistor are separated... but this is not so important here.

The problem here, in my opinion, is that the PNP transistor cannot be reliably cut off when the NPN transistor is cut off (I have explained why here). This problem can be solved by connecting a (few k) resistor between its base and emitter and adding a "shifting" Zener diode in series to the base resistor.

Also, the PNP transistor should be always in active mode (with some voltage drop VCE > 1 V). Search in Google with "current source compliance voltage".

EDIT: I would like to consider the Dave's circuit solution (through a current mirror) by comparing it with the OP's solution. At first glance, they are completely different, but I will try to convince you that, in a sense, they are the same.

Both solve the same topological problem - they reverse the direction of the collector current of the NPN transistor. In the OP solution, the humble PNP transistor does this because its collector current has the opposite direction to the base current. In the Dave's classic current mirror, the PNP Q3 does this. So, in regards to the current direction, both they act as *current inverters"... both they are current mirrors...

In regards to the current magnitude, the OP's "1-transistor current mirror" (like every BJT) is an amplifier (Ic = beta.Ib) while the Dave's classic current mirror is a follower. It is interesting to see how this current ampifier is made act as a follower since unraveling this mystery would be a possible scenario for the current mirror inventing (very important for understanding).

The trick is simple - the excessive base current is diverted by an additional element connected in parallel to the PNP base-emitter junction (current divider). In the simple case, it can be a resistor (as I suggested above). Only, the resistor is linear while the base-emitter junction is non-linear and its resistance should be carefully adjusted (still it is used in MOSFET current mirrors).

A diode can serve as a good diverting element since actually the base-emitter junction is a "diode"... but they are not exactly the same. The perfect diverting element is a transistor made act as a diode - the so-called "active diode" (Q2).

On April 8, 2008, I conducted three consecutive labs dedicated to this kind of transistor current sources. After that, I wrote, with the help of my students, three exciting Wikibooks stories about how they and I "invented" the famous current mirror circuit:

To write them, I recorded these "lab brainstorming sessions" on a solid-state recorder and made photos in the lab.

## As a conclusion

Basically, both circuits do the same - they measure the load current by measuring the voltage drop across a stable (160 ohm) current-sensing resistor. The difference is that the OP's "amplifying current mirror" is inside the negative feedback loop while the Dave's true current mirror is outside the loop. So the former can be imperfect while the latter must be perfect. From this point of view, one can reach the paradoxical conclusion that, in a sense, the OP circuit is better:)

The problem of the simple BJT mirror is that it is based on the passive compensation (without negative feedback). But the simple op-amp differential amplifier is also based on this passive principle and it requires precise matching the four resistors.

• Actually, a huge problem with the design is the measuring circuit. The current drawn away from the load varies when the load voltage varies (due to load changes.) So it will never be right. What the OP should want to do is to draw a fixed current away from both sides of the measuring resistor. This means a constant current mirror situation (full Wilson would be nice) as the only real avenue. That current can be set to an acceptable "offsetting" value and it will NOT vary as the load voltage varies, then. Get the basics right, first. Then work out the rest, I think.
– jonk
Apr 24, 2021 at 19:57
• But I'm using a NPN that "dumps" the voltage on the gate for the PNP transistor?
– DanM
Apr 24, 2021 at 20:30