38 Replies Latest reply on May 13, 2020 10:31 AM by Jan Cumps

# Differential amplifier problem

I'm working with a DAC and experimenting with removing the zero scale error - the actual output at a zero input code.  I'm on a breadboard so it isn't particularly accurate but the ZSE is 5mV to 11mV.

I set up a differential amplifier as follows - image is copied from a website, but I've confirmed and re-confirmed that my setup matches:

So, I have the following inputs:

V1 = 0.005mV

V2 = DACoutput

R = 100K.  All of them.

Opamp is an LM741 which is all I have on-hand, V+ = 5V, V- = ground .  It has a max offset voltage of 6mV.

Given that, I would expect Vout = V2 - V1.  Vout is connected to a 1K resistor to ground.

So the reality is that the R values are not perfectly 100K but are within the 10% spec.  Thus I wouldn't expect Vout to be an exact difference, but 'more-or-less'.

This is what I'm measuring:

DACout (V2) = 4.06V, Vout = 4.04V

DACout (V2) = 0.011V, Vout = 3.6V

I've tried working out why with a low DACout I'm still getting a large Vout.  Measuring the resistors and plugging them into the gain formula:

Vout = -0.005 * (99.03/99.5) + 0.011 * (99.21/(99.05+99.21)) * ((99.5+99.03)/99.5)

Vout = (-0.005 * 0.995) + (0.011 * 0.500 * 1.995)

Vout = -0.005 + 0.011 = 0.006

So, essentially, my calculation confirms what I would expect the amplifier to do with a -0.005mV and 0.011mV input.

I can't figure out where I've gone wrong, can anyone give me some pointers?

• ###### Re: Differential amplifier problem

calling in jc2048 - opamp expert.

Vout is connected to a 1K resistor to ground.

This should not have impact - the output of an opamp is low impedance and as long as it can drive the 1K load, this is fine...

So we should focus on the input and feedback resistors ...

1 of 1 people found this helpful
• ###### Re: Differential amplifier problem

Yep, I confirmed early on that with or without the 1K resistor it makes no difference.

1 of 1 people found this helpful
• ###### Re: Differential amplifier problem

This is the offset circuit I designed:

It uses a decicated OpAmp and an available programmable DAC to "offset the offset" of another DAC, by injecting the voltage in an OpAmp subtract configuration.

It didn't correct the 0 point errors I have in my DC load, but it fixes the DAC offset.

A potentiometer and manual trimming would fix that too, but this solution allows to use calibration firmware to offset the offset.

My advise here is of a generic OpAmp user. It would be great to see comments from designers hat used precision DACs and precision OpAmps in a measurement design ...

That's the secret sauce.

2 of 2 people found this helpful
• ###### Re: Differential amplifier problem

I'd followed that bit of your implementation and was trying to do something without an extra DAC - in theory it ought to work.

Interestingly (to me at least), I'd realised that with 5 DACs one could output a linear scale from 0V to Full Scale:

One to output the linear region with software compensated offset and gain

One to output the pre-linear region (0 to start-of-linear, say 12mV) compensated by the output of a second DAC to limit to 0V to 12mV.

One to output the post-linear region (say, 4V to 4.096V) compensated by the output of a second DAC.

Software directs the required code to the right DAC and you'd only need 20 DACs to output 4 accurate DAC channels

Using an Op Amp, at least in theory, should allow me to drive from 0mV to full scale - zero scale error.  That, of course, widens the full scale error so it's not perfect and I guess you decide which end of the scale is most important.

What I'd really like is an OpAmp configuration that would stretch zero scale error to 0V whilst also stretch full scale error to full scale whilst keeping it all monotonic.  But I'll settle for understanding what I'm doing wrong here first!

It might help with a photo of the breadboard (without the 1K load):

2 of 2 people found this helpful
• ###### Re: Differential amplifier problem

Yes, we're doing it the naive way. That's why I hope that analog / DAC experts chime in and show the shining path to real world solutions.

In the eLoad we made, things like OpAmp offset, quiescent current and other attributes played a significant role. Particular at the near 0 current point....

The 741 is not the best in class for input current specs. More modern OpAmps dealt with that problem. But as you've noticed, there's more to solve.

I kind of like that these things don't solve easily in firmware with calibration and corrections. They are real electronics problems. That's what I'm here for ...

2 of 2 people found this helpful
• ###### Re: Differential amplifier problem

Agreed, that's why I'm making my control board a little more complex by looking at a variety of potential issues.  I'm limited to a LM471 right now because that's all I have and it fits a breadboard - I had thought of an OP388 for actual use.  So I'm testing the theory right now before committing to a PCB for better prototyping.  Good job too it seems

1 of 1 people found this helpful
• ###### Re: Differential amplifier problem

Using a non-ideal OpAmp is the best way to learn.

Solving it by using a better OpAmp (as I did ) is a cop-out. You learn nothing. And the problems are still there when you care about the full "close to 0 range".

I think that if you can solve the apparent OpAmp pitfalls with a 741, you've upped your OpAmp understanding in a way that will never be achieved by just replacing it with a newer one ...

That said, I'd never use a 741 in a design anymore. The newer ones are vastly better...

1 of 1 people found this helpful
• ###### Re: Differential amplifier problem

I see you used an 741 when you were testing your fix as well   (The UA741 is the same as the one I used in fact!)

• ###### Re: Differential amplifier problem

I did. I have a few lying around here to test things out.

In this case it's a slow (almost DC) signal far away from both rails (virtually in the middle of both).

And both inputs driven by DACs that have it easy to drive a 741.

For the final design I made a little pcb that could be glued on the DC load analog board, with a OP2170.

The brain wasn't extemely active at the time though. I forgot to place decouple caps and pads for the wires ...

This is how the load looks now:

• ###### Re: Differential amplifier problem

Hello Andrew,

What do you use for the supply rails for your LM741 opamp?

Thanks,

- Wolfgang.

• ###### Re: Differential amplifier problem

What power do you have connected to the 741 - it's not rail to rail capable it needs positive and negative supplies, +/- 10V is the minimum recommended.

The input common mode range is +/- 12V when running with +/- 15V supplies - that means that the amp won't work properly if either input is closer to a supply rail than 3V.

The LM741 was designed (by David Fullagar at  Fairchild) in 1968 - 52 years ago - we have better parts now

Just seen your photo - single rail supply ?

The poor old 741 can't work like that, but you won't get any (even rail to rail IO types) op amp to do get the output right down to zero.

MK

6 of 6 people found this helpful
• ###### Re: Differential amplifier problem

Wolfgang/Michael,

it's using 5V+, 0V- so no -ve supply rail; I could run it from a 12V+ which would keep DACout max well below that limit.  I did wonder about a -Ve supply rail originally, but as I wasn't asking it to output a -ve voltage I didn't think it would matter.

The LM741 is all I have to hand and was something I got hold of when I first started out learning this stuff.  I'm prototyping ideas at the moment before getting a prototype PCB made up.  One of my ideas involves buffering an ADC input so I had sort of settled on getting a OP388 for that and I'd thought if this zero code error compensation worked I would get another (OP4388) for that purpose.

1 of 1 people found this helpful
• ###### Re: Differential amplifier problem

If you want to sink any current at 0V you need a negative supply. You could consider using +/- 5V supplies (+/- 10 if you stick with the 741 )

You can do a lot of this without spending money by using a simulator - LTSpice is free and good - (from www.analog.com)

The OP388 parts are interesting but they are chopper amps which means that they bring their own special problems and they are not that cheap.

One (of many) things to be concerned about is that the DAC will be non linear at low outputs if its a single rail part !

If you really want to play with actual parts rather than simulate then get some Microchip op amps (because some come in DIL packages).

MCP6002 are dirt cheap, rail to rail IO, not too fast so won't be too hard to handle on bread board. Single rail max supply 6V.

Offsets not that good but bias current is tiny.

1292245 from Farnell at £0.26 for a dual op amp means you won't be too sad when you blow one.

I'm not sure what your goal with this work is - if you can explain a bit more I might be able to offer more useful suggestions.

MK

6 of 6 people found this helpful
• ###### Re: Differential amplifier problem

Basically, I'm having a play around with DACs and ADCs creating my own version of Jan' and Peter's Boost board for their eload.  Ultimately, I'll probably add a DC load onto this as well but right now, I'm just trying to get a better understanding of these devices and how I might improve the output.  That's fairly simplistic because I am trying to make a control board with other things as well, but here is what I'm trying to do specifically with the DAC / ADC side of things.

The 12-bit DAC, with a 4.096 external reference, I have is 'ok' - pretty cheap, not highly accurate and I will change it for another shortly - and I can measure it's output as 5mV to around 4.080V.  So there is a Zero Scale Error of around 5mV and a Full Scale Error of 26mV.  Sticking with the ZCE: what this means is that if I try and output codes 0 to 5 I get 5mV, 6 I get 6mV etc.  My idea was to use a differential amplifier with a 0.005mV input on the inverting side to 'subtract' this from the output of the DAC on the non-inverting side.

The 16-bit ADC isn't too bad and I know that will come with its own errors.  I had thought I would buffer the ADC inputs with a simple RC filter on the buffer output to filter any noise.  For this, I had thought to use an OP388 as TI promote it for such a purpose:

"The OPAx388 (OPA388, OPA2388, and OPA4388) series of precision operational amplifiers are ultra-low noise, fast-settling, zero-drift, zero-crossover devices that provide rail-to-rail input and output operation. These features and excellent ac performance, combined with only 0.25 μV of offset and 0.005 μV/°C of drift over temperature, makes the OPAx388 a great choice for driving high-precision, analog-to-digital converters (ADCs) or buffering the output of high- resolution, digital-to-analog converters (DACs). This design results in excellent performance when driving analog-to-digital converters (ADCs) without degradation of linearity."

There are things that I don't yet understand but that's why I'm doing it - for fun and learning, so I don't mind spending a bit of money to work things out.  I'm trying some things I can do on a breadboard first and then reading around potential solutions for what I'm seeing.  At some point I want to actually produce a PCB because it's as cheap to do that as to get DIL adapters for the ICs!

5 of 5 people found this helpful
• ###### Re: Differential amplifier problem

ultra-low noise, fast-settling, zero-drift, zero-crossover

This is where jc2048 advice is welcome, because another player is the current on both OpAmp input sides.

They have impact on behaviour, and on the resistors you (can) choose to define input impedance and feedback ..

A lovely subject. It can be analysed without a breadboard, by using a simulator (as suggested by michaelkellett). But if you have the hardware you can see the effects for real too.

• ###### Re: Differential amplifier problem

I was going the same route as Michael, he already gave the correct hint in his question.

This is the relevant datasheet section for a +-15V supply:

And the 741 could not be run with +5V/0V at all:

5 of 5 people found this helpful
• ###### Re: Differential amplifier problem

Dammit, I know this!  All the past experiments I've run with this op amp have been at a higher input voltage.

• ###### Re: Differential amplifier problem

Michael, if I understand what you are saying, trying to use an OpAmp of any sort to get rid of a, say, 5mV ZSE is not going to be possible?  My thought was a theoretical 0mV should be <1mV (uV in other words) rather than an actual 0V.

• ###### Re: Differential amplifier problem

The problem is this:

Suppose you use an MCP4822 dual 12 bit DAC, the output offset max at zero code is +/- 1% of full scale = 20.48mV or 41 bits.

A typical rail to rail input amplifier will have a common mode range that goes down to maybe 0.3V below ground (although performance may not be well specified there.)

Your diff amp will be OK - the voltage on the positive input will be max 10mV to -10mV. To null that you'll need + or - 10mV on the other pin but there is a flaw in this reasoning !

It won't work - think about that weasel spec, the code is zero and the offset is -20mV or -41 bits . But the DAC only has 0 - 5V supply rails - its output can't go negative !!

So if you set any code in between 0 and 41 the DAC output just sits at 0V - so you can't null the zero offset of a single rail DAC.

MK

2 of 2 people found this helpful
• ###### Re: Differential amplifier problem

I had realised that I couldn't get rid of that 0 to 41 code range by software compensation; the output is never 0mV (or -ve) with this type of delta-sigma DAC, it's always positive in some form (as I understand from how these types of DACs work.)  The MCP4728 I use doesn't state a ZSE in the datasheet but the Offset error is 5mV (typical) to 20mV (max.)  At this point, I was looking at reducing it through the diff. amp such that, to take your example, 0 to 41 is 0mV, 42 becomes 1mV, 43 becomes 2 and so on.  I realise this is taken the full scale range further below where it currently sits because it will subtract 5mV from all output values.  In my actual case, that zero scale error was 5mV (or 11mV it's not always so stable on the breadboard) so I was trying to 'subtract' 5mV thus a code of 0 to 5 become 0V, 6 becomes 1mV and so on.

I'm not sure yet whether this is possible or not given what you've said, perhaps I'm still misunderstanding something?  Clearly I need something better than the op amp I have so thanks for clearing that up, that's been really useful.  I'll have a play around in LTSpice and see what I come up with.

Thanks for the input.

• ###### Re: Differential amplifier problem

What DAC are you using (and planning to use) - precision non audio DACs are almost never delta sigma types.

(I'm going home now so won't see any more till tomorrow.)

MK

• ###### Re: Differential amplifier problem

Yes, sorry, it's a resistor string architecture - I've been reading too much recently.  The DAC is an MCP4728 and I'm thinking of a ADS5694R-B or AD5696R-B (same datasheet as the ..4R-B)  These latter ones have a +Ve ZSE and a max +-1.5 offset error.

It's the ADC I've been using, MCP3428, which is Sigma-Delta.

• ###### Re: Differential amplifier problem

I've made a brief test with a -12V and +12V rail to the op amp and it works more as expected, that is a low mV input stays low and a large V input stays large!  Not precise, but I can't do more today so I'll carry on tomorrow.

• ###### Re: Differential amplifier problem

To follow this up.  I ran a small test with V+ at +15V and V- at -15V.

As predicted by others in this thread the op amp isn't really up to the job.  The original issue which drew my question is solved - it needs the -ve rail - but it shows its limitations.  I can't even null the offset error.

Here's the results of two tests for given inputs, the resulting output:

1. DACout 12.6mV, Voffset 12.6mV, Vout = 44.6mV
2. DACout 4.0631V, Voffset 14.2mV, Vout = 4.0948V

So it's not exactly subtracting!

I also created an LTSpice simulation for these tests:

Test 1

The -4.5v drop at the start limits the V scale, but the cursor measurement shows a drop to <1mV

Test 2

Here, it shows a correct subtraction.

So LTSpice simulation is proving the principle even if a physical part can't quite live up to it.  I'm now looking into Op Amps in more detail to get a better idea.  Thanks to Michael and Wolfgang for their input on this.

• ###### Re: Differential amplifier problem

Can you post your LTSpice model ?

Thanks.

MK

• ###### Re: Differential amplifier problem

I used the one in the LTSpice example folder which I've attached to the post.  Changed the input voltages and Spice directives as necessary but changed nothing else.

• ###### Re: Differential amplifier problem

Sorry Andrew, I can't see the attachment.

You could just paste the .ascii file in from LTSpice.

Thanks.

MK

• ###### Re: Differential amplifier problem

I can see it as a ZIP file attachment (.asc file) to the original post but here's the ascii version:

Version 4

SHEET 1 3268 1552

WIRE 2416 384 1744 384

WIRE 3264 384 2496 384

WIRE 1856 464 1616 464

WIRE 2032 464 1856 464

WIRE 2096 464 2032 464

WIRE 2288 464 2096 464

WIRE 2448 464 2288 464

WIRE 2816 464 2448 464

WIRE 3040 464 2816 464

WIRE 1616 480 1616 464

WIRE 2096 496 2096 464

WIRE 2288 496 2288 464

WIRE 2448 496 2448 464

WIRE 2816 496 2816 464

WIRE 2176 544 2160 544

WIRE 2224 544 2176 544

WIRE 2528 544 2512 544

WIRE 2752 544 2528 544

WIRE 1616 576 1616 560

WIRE 3040 576 3040 464

WIRE 2448 624 2448 592

WIRE 2528 624 2528 544

WIRE 2528 624 2448 624

WIRE 2816 624 2816 592

WIRE 2816 624 2560 624

WIRE 2928 624 2816 624

WIRE 2976 624 2928 624

WIRE 1616 656 1456 656

WIRE 1744 656 1744 384

WIRE 1744 656 1696 656

WIRE 1856 656 1744 656

WIRE 2256 656 1856 656

WIRE 1456 672 1456 656

WIRE 2928 672 2928 624

WIRE 2096 688 2096 592

WIRE 2096 688 1936 688

WIRE 2176 688 2176 544

WIRE 2176 688 2096 688

WIRE 2704 688 2688 688

WIRE 2816 688 2816 624

WIRE 2816 688 2784 688

WIRE 2816 720 2816 688

WIRE 3040 720 3040 672

WIRE 3040 720 2992 720

WIRE 1936 736 1936 688

WIRE 2176 736 2176 688

WIRE 2448 736 2448 624

WIRE 3040 752 3040 720

WIRE 2688 768 2688 688

WIRE 2752 768 2688 768

WIRE 1632 784 1536 784

WIRE 1776 784 1712 784

WIRE 1856 784 1776 784

WIRE 1872 784 1856 784

WIRE 2256 784 2256 656

WIRE 2256 784 2240 784

WIRE 1456 816 1456 752

WIRE 2560 816 2560 624

WIRE 1536 832 1536 784

WIRE 2688 832 2688 768

WIRE 2704 832 2688 832

WIRE 2816 832 2816 816

WIRE 2816 832 2784 832

WIRE 1776 848 1776 784

WIRE 1936 864 1936 832

WIRE 2176 864 2176 832

WIRE 2928 864 2928 768

WIRE 3040 864 3040 832

WIRE 3040 864 2928 864

WIRE 3136 864 3040 864

WIRE 3264 864 3264 384

WIRE 3264 864 3136 864

WIRE 3040 880 3040 864

WIRE 2112 912 2000 912

WIRE 2288 912 2288 592

WIRE 2288 912 2112 912

WIRE 2816 912 2816 832

WIRE 2816 912 2672 912

WIRE 2672 928 2672 912

WIRE 1536 960 1536 912

WIRE 2032 960 2032 464

WIRE 2176 976 2176 960

WIRE 2560 976 2560 880

WIRE 2560 976 2176 976

WIRE 2608 976 2560 976

WIRE 3040 976 3040 960

WIRE 1776 992 1776 928

WIRE 1936 1008 1936 960

WIRE 1968 1008 1936 1008

WIRE 2816 1024 2816 912

WIRE 2976 1024 2816 1024

WIRE 2816 1056 2816 1024

WIRE 1936 1088 1936 1008

WIRE 2176 1088 2176 976

WIRE 2448 1088 2448 816

WIRE 2448 1088 2368 1088

WIRE 2672 1104 2672 1024

WIRE 2752 1104 2672 1104

WIRE 2288 1120 2288 912

WIRE 2448 1120 2448 1088

WIRE 2032 1136 2032 1056

WIRE 2032 1136 2000 1136

WIRE 2112 1136 2032 1136

WIRE 2560 1136 2560 976

WIRE 2368 1168 2368 1088

WIRE 2368 1168 2352 1168

WIRE 2384 1168 2368 1168

WIRE 2816 1184 2816 1152

WIRE 2816 1184 2624 1184

WIRE 1936 1216 1936 1184

WIRE 2032 1216 2032 1136

WIRE 2176 1216 2176 1184

WIRE 2672 1216 2672 1104

WIRE 2816 1216 2816 1184

WIRE 2288 1232 2288 1216

WIRE 1856 1328 1712 1328

WIRE 1936 1328 1936 1296

WIRE 1936 1328 1856 1328

WIRE 2032 1328 2032 1296

WIRE 2032 1328 1936 1328

WIRE 2176 1328 2176 1296

WIRE 2176 1328 2032 1328

WIRE 2288 1328 2288 1312

WIRE 2288 1328 2176 1328

WIRE 2448 1328 2448 1216

WIRE 2448 1328 2288 1328

WIRE 2560 1328 2560 1232

WIRE 2560 1328 2448 1328

WIRE 2672 1328 2672 1296

WIRE 2672 1328 2560 1328

WIRE 2816 1328 2816 1296

WIRE 2816 1328 2672 1328

WIRE 3040 1328 3040 1072

WIRE 3040 1328 2816 1328

WIRE 1712 1344 1712 1328

WIRE 1712 1440 1712 1424

FLAG 1856 784 3

FLAG 1856 656 2

FLAG 1712 1440 0

FLAG 3136 864 Vout

FLAG 1616 576 0

FLAG 1536 960 0

FLAG 1856 464 7

FLAG 1856 1328 4

FLAG 1776 992 0

FLAG 1456 816 0

SYMBOL NPN 1872 736 R0

SYMATTR InstName Q1

SYMATTR Value NP

SYMBOL npn 2240 736 M0

SYMATTR InstName Q2

SYMATTR Value NP

SYMBOL PNP 2112 960 M180

WINDOW 0 60 72 Left 2

WINDOW 3 64 20 Left 2

SYMATTR InstName Q5

SYMATTR Value PN

SYMBOL pnp 2000 960 R180

WINDOW 0 60 72 Left 2

WINDOW 3 64 20 Left 2

SYMATTR InstName Q6

SYMATTR Value PN

SYMBOL npn 2000 1088 M0

SYMATTR InstName Q7

SYMATTR Value NP

SYMBOL npn 2112 1088 R0

SYMATTR InstName Q8

SYMATTR Value NP

SYMBOL npn 1968 960 R0

SYMATTR InstName Q3

SYMATTR Value NP

SYMBOL pnp 2160 592 R180

WINDOW 0 60 72 Left 2

WINDOW 3 64 20 Left 2

SYMATTR InstName Q4

SYMATTR Value PN

SYMBOL RES 1920 1200 R0

SYMATTR InstName R1

SYMATTR Value 1K

SYMBOL res 2016 1200 R0

SYMATTR InstName R2

SYMATTR Value 50K

SYMBOL res 2160 1200 R0

SYMATTR InstName R3

SYMATTR Value 1K

SYMBOL pnp 2224 592 M180

WINDOW 0 60 72 Left 2

WINDOW 3 64 20 Left 2

SYMATTR InstName Q9

SYMATTR Value PN

SYMBOL pnp 2512 592 R180

WINDOW 0 60 72 Left 2

WINDOW 3 64 20 Left 2

SYMATTR InstName Q10

SYMATTR Value PN

SYMBOL pnp 2752 592 M180

WINDOW 0 60 72 Left 2

WINDOW 3 64 20 Left 2

SYMATTR InstName Q11

SYMATTR Value PN

SYMBOL npn 2384 1120 R0

WINDOW 0 56 20 Left 2

SYMATTR InstName Q12

SYMATTR Value NP

SYMBOL npn 2352 1120 M0

SYMATTR InstName Q13

SYMATTR Value NP

SYMBOL res 2272 1216 R0

SYMATTR InstName R4

SYMATTR Value 5K

SYMBOL npn 2752 720 R0

SYMATTR InstName Q14

SYMATTR Value NP

SYMBOL npn 2752 1056 R0

SYMATTR InstName Q15

SYMATTR Value NP

SYMBOL npn 2608 928 R0

SYMATTR InstName Q16

SYMATTR Value NP

SYMBOL res 2656 1200 R0

SYMATTR InstName R5

SYMATTR Value 50K

SYMBOL res 2800 1200 R0

SYMATTR InstName R6

SYMATTR Value 50

SYMBOL npn 2624 1136 M0

SYMATTR InstName Q17

SYMATTR Value NP

SYMBOL cap 2544 816 R0

SYMATTR InstName C1

SYMATTR Value 30p

SYMBOL res 2800 816 R90

WINDOW 0 0 56 VBottom 2

WINDOW 3 32 56 VTop 2

SYMATTR InstName R7

SYMATTR Value 7.5K

SYMBOL res 2800 672 R90

WINDOW 0 0 56 VBottom 2

WINDOW 3 32 56 VTop 2

SYMATTR InstName R8

SYMATTR Value 4.5K

SYMBOL npn 2976 576 R0

SYMATTR InstName Q18

SYMATTR Value NP

SYMBOL pnp 2976 1072 M180

WINDOW 0 60 72 Left 2

WINDOW 3 64 20 Left 2

SYMATTR InstName Q19

SYMATTR Value PN

SYMBOL res 3024 736 R0

SYMATTR InstName R9

SYMATTR Value 25

SYMBOL res 3024 864 R0

SYMATTR InstName R10

SYMATTR Value 50

SYMBOL npn 2992 672 M0

SYMATTR InstName Q20

SYMATTR Value NP

SYMBOL VOLTAGE 1712 1328 R0

SYMATTR InstName V1

SYMATTR Value -15

SYMBOL voltage 1616 464 R0

SYMATTR InstName V2

SYMATTR Value 15

SYMBOL res 2512 368 R90

WINDOW 0 0 56 VBottom 2

WINDOW 3 32 56 VTop 2

SYMATTR InstName R11

SYMATTR Value 100K

SYMBOL res 1712 640 R90

WINDOW 0 0 56 VBottom 2

WINDOW 3 32 56 VTop 2

SYMATTR InstName R12

SYMATTR Value 100K

SYMBOL voltage 1536 816 R0

SYMATTR InstName DACout

SYMATTR Value 4.0631

SYMBOL res 2432 720 R0

SYMATTR InstName R13

SYMATTR Value 39K

SYMBOL res 1728 768 R90

WINDOW 0 0 56 VBottom 2

WINDOW 3 32 56 VTop 2

SYMATTR InstName R14

SYMATTR Value 100K

SYMBOL res 1760 832 R0

SYMATTR InstName R15

SYMATTR Value 100K

SYMBOL voltage 1456 656 R0

WINDOW 0 46 47 Left 2

WINDOW 3 46 76 Left 2

SYMATTR InstName Voffset

SYMATTR Value 14.2m

TEXT 1768 768 Left 2 ;IN+

TEXT 1776 640 Left 2 ;IN-

TEXT 3168 848 Left 2 ;OUT

TEXT 2840 1392 Left 2 ;.step param V1 0 4.096 0.5

TEXT 2344 1432 Top 1 ;This example schematic is supplied for informational/educational purposes only.

TEXT 1784 1312 Left 2 ;V-

TEXT 1784 416 Left 2 ;V+

TEXT 1896 1360 Left 2 !.model NP NPN(BF=125 Cje=.5p Cjc=.5p Rb=500)\n.model PN LPNP(BF=25 Cje=.3p Cjc=1.5p Rb=250)

TEXT 2840 1352 Left 2 !.tran 40u startup

• ###### Re: Differential amplifier problem

I'm preparing my board for some measurement.

Soldered in a measurement wire at the subtractor output:

A DMM on DAC A - the one that I use to set the dc load point

One on DAC B, - the one I use to offset A's DC offset

One on that output of the opamp wire I just soldered in ...

set

I can now use the GUI to talk to the individual DACs. I created SCPI commands for that in the firmware:

... and then measure the effect ...

• ###### Re: Differential amplifier problem

So it's actually working:

the photo shows the meters in volt range. The measurements below are done with all in mV range.

Initially, I get about 2 mV out off the subtractor

I've set the DAC1 to 200. That's the region where mine is in the linear part. Under that, it doesn't move below the offset.

• DEVE:DAC1 200

DAC 1 outputs 4.92 mV

DAC 2 1.64 mV

OpAmp is still at 2 mV

At this point, any change in DAC1 increases the output.

This is the range I want to work from - starting DAC1 from 200 - and consider that 0.

So I have to work away the 2 mV offset with DAC 2.

Starting with value 10:

• DEVE:DAC2 10

DAC2 is now 2.04 mV

OpAmp is at 1.55 mV

• DEVE:DAC2 20

DAC2 is now 2.42 mV

OpAmp 1.19 mV

• DEVE:DAC2 30

DAC2 is now 2.85 mV

OpAmp 0.75 mV

• DEVE:DAC2 40

DAC2 is now 3.24 mV

OpAmp 0.35 mV

• DEVE:DAC2 45

DAC2 is now 3.46 mV

OpAmp 0.13 mV

• DEVE:DAC2 50

DAC2 is now 3.65 mV

OpAmp -0.06 mV <- overcompensated

The following two are the closest I can get to 0...

• DEVE:DAC2 48

DAC2 is now 3.56 mV

OpAmp 0.02 mV

• DEVE:DAC2 49

DAC2 is now 3.62 mV

OpAmp -0.02 mV

In theory, I could automate this by connecting the last uncommitted ADC I have on the board to the output of the subtractor and let the system run through the paces itself until it settles for the lowest linear point, then 0 it out ...

1 of 1 people found this helpful
• ###### Re: Differential amplifier problem

Is that last 20uV the INL and DNL error possibly?  I'd say it was a good result.  I presume you're also losing 3.56mV off the FSR?  Will that have any impact?  It would be useful to stretch the output to a genuine 0mV and full scale range V but I suspect you may lose some output accuracy at various points in that range.

As I was experimenting with the OpAmp to do this with a voltage divider I was able to link in my head what I was trying to achieve with what you were doing with the DAC offset compensation board you created (I'd read that a while ago.)  As I've thought about it more over the last day and a bit, I think your approach is likely to be the more accurate as the resistor/potentiometer is unlikely to be as good in terms of drift AND I can't automatically determine and adjust compensation.

I'd further thought that I could use an ADC input to change the compensating DAC output so that it stayed as accurate as possible - I think that's what you are eluding to in your last sentence.  I was intending to set the software up to run automatic compensation for offset and gain errors across all DAC outputs so that as, say, temperatures rose, it could try and maintain some accuracy.  This would just be an additional step to make sure that it could output close to 0mV as possible.  This could be done at regular intervals, say when output was turned off and nothing was being driven.

I can't see having an extra DAC on the board any more expensive in terms of cost or real estate than a set of voltage dividers and because I'm thinking of starting in a more accurate place I will have a spare DAC, and maybe ADC.

• ###### Re: Differential amplifier problem
Is that last 20uV the INL and DNL error possibly?  I'd say it was a good result.

The offset of DAC 1 is higher than that. But because DAC 2 also has offset by itself, it has already handled part of the work by just plugging it into the opamp.

I presume you're also losing 3.56mV off the FSR?  Will that have any impact?

Yes I'm loosing range. No it's not impacting because I have enough range over to drive the circuit and FET as required (there's headroom at the high end - also a waste of resolution of course. Playing with the circuit's gain can tune this to maximum viable).

I don't know if I made that clear but, although this fixes the offset of DAC 1, it doesn't fix another issue I have in the eLoad, where it behaves bad at the 0 range.

But that's not a DAC issue. That has to do with the analog control circuit.

I haven't found the reason for that yet...

As I was experimenting with the OpAmp to do this with a voltage divider I was able to link in my head what I was trying to achieve with what you were doing with the DAC offset compensation board you created (I'd read that a while ago.)  As I've thought about it more over the last day and a bit, I think your approach is likely to be the more accurate as the resistor/potentiometer is unlikely to be as good in terms of drift AND I can't automatically determine and adjust compensation.

I think it will - except if you use a 10-turn trimmer. It was not the reason for my approach though.

I wanted to introduce a programmable compensation instead of manual trimmers. More for my own learning than for practical purpose ...

I'd further thought that I could use an ADC input to change the compensating DAC output so that it stayed as accurate as possible - I think that's what you are eluding to in your last sentence

Yes. And I have the hardware to do that. Just have to bodge yet another wire in - but that's prototyping.

I've currently disabled the last free ADC in the firmware because it's unconnected, and sampling takes time. But with the last improvement I did in the ADC process, I have enough resources to do that.

I'd just need the burning desire to get on with it ...

I can't see having an extra DAC on the board any more expensive in terms of cost or real estate than a set of voltage dividers and because I'm thinking of starting in a more accurate place I will have a spare DAC, and maybe ADC.

peteroakes and I decided to go for 4 channel DAC and ADC. While we only needed one DAC and 3 (initial 2, before we introduced temperature protection) ADCs.

Because this isn't a commercial product, and we wanted to play with those ICs (they are expensive - but those are the decisions you make when it's educational), we didn't have to worry about that a lot.

In the end it turned out to be a good thing for this design, because it allows for additional experimentation.

There's also a i2c bus extender there. 8 pins of which only one is used for enabling the load on command.

The 7 others are free and could be used for GPIO, fan control, ... . The firmware would have to be altered, but this would not be intrusive...

They are on the isolated side of the circuit so safe to use. I didn't put breakout pads but you can remove their associated resistor (needed when not in use to ease the expander) and use the resistor pad to get at the I/O.

Not 100% hack friendly, but it gets you a long way ...

• ###### Re: Differential amplifier problem

Nice one.  I'm busy pulling together a more 'final' schematic to turn into a PCB for more work - I'm going to go the same route as yourself for compensating rather than the divider route: I really want to have programmable compensation.  It'll be interesting as there will be offset, gain, INL and DNL errors on all DACs and ADCs so there is some compounding going on as well!  I have 2 spare digital outputs on my isolator available if I need them, which I suspect I will right now.

The post you made here ought to get x-refd from your main blog as it's very useful.

• ###### Re: Differential amplifier problem

If I understand correctly what you are trying to do it might be a lot simpler and cheaper to use a singe DAC with 2 more bits and a deliberate fixed offset on the output and do the compensation entirely in software.

You could still make it fully automatic by adding an ADC but this needs to be good compared with the DAC.

Don't forget the voltage reference - it's quite tricky to get even 12 bit accuracy over  a modest temperature range.

MK

2 of 2 people found this helpful
• ###### Re: Differential amplifier problem

Thanks Michael,

I’ve pretty much decided to go the same way as Jan did as I now have a spare ADC and DAC on hand.  I also have a REF5040 on hand which I’m currently using with those two components - the new ADC and DACs I’m thinking about have internal references which have better stats than the REF5040, at first check but I need to reconfirm as part of final checking.  I just need to gird my loins for soldering a DFN package!

• ###### Re: Differential amplifier problem

Had another thought about this jancumps.  Under normal operating conditions you get the DAC output compensated.  We've talked a bit about software compensation for this - I'd assumed, and certainly what my intention was, that this would involve running compensation routines (at startup at least and occasionally as temperature change) to calculate the offset for the compensating DAC to apply under those normal operating conditions.  This would require the load output to be enabled in order for the DAC output to be determined to calculate the necessary compensation - inevitably that would feed through to your DC load which would drive whatever is connected.  That compensation routine would drive from a 0 input code to a Full Scale range code.  Do you have a means of disconnecting the control board from the power circuit under software control?

We are way off my original topic here - this would be better discussed on your booster pack thread really!