# Error Calculation

Written by

Unfortunately, all electronic components, even those labelled “precision” exhibit errors and uncertainties that you need to be aware of when designing circuits. Importantly, you need to be able to see how individual errors accumulate as components interact. This is a big topic, and maybe not the most exciting, but it is well worth understanding at least the basics.

I am going to use the simple circuit of Figure 1 as an example. We want to monitor a variable voltage at Vin and indicate if it is greater than one volt. Let’s see how accurately we can do this with “jellybean” components. Let’s further assume we want to operate at a nominal temperature of 25˚C but consider operation 20˚C either side of this (over the range 5˚C to 45˚C).  Initially we will use a low-cost LM324 op amp for the gain stage, a classic LM393 comparator, a low cost LM404B 2.5V voltage reference and 1% resistors. The LM324 stage has a gain of 2.5 to scale the input to suit the reference.

Each of the components will contribute some degree of error to the overall error in the 1V detection threshold.  The way we accumulate errors depends on whether the error quantities are adding (or subtracting) or multiplying (or dividing).

Figure 2 shows that when quantities add, the resulting error is the sum of absolute errors of the input. For example, if two resistances, R1 and R2 , each with uncertainties ∆R1 and ∆R2 respectively are in series, the equivalent total resistance RT will be R1+R2 and the uncertainty (error) ∆RT will be ∆R1+∆R2.

Figure 3 shows that it’s a bit more complex for quantities that multiply. In this case we have a voltage VI with an uncertainty ∆VI multiplied by a gain K with an uncertainty ∆K. The maths shows us the resulting error term ∆VO is VI•∆K + K•∆VI + ∆VI•∆K. If the errors are relatively small, the last term can be ignored. If we now look at the error term as a relative error, we can see that the total relative error is the sum of relative errors of the inputs, in this case ∆V/V + ∆K/K .

The upshot of this is that we have to add absolute errors when adding or subtracting quantities and add relative errors when multiplying or dividing quantities. Relative errors are usually expressed in percentages or parts per million (ppm). Remember this latter is an approximation since we ignored a term, but its good enough if the errors are less than few percent.

Table 1 shows how we put this into practice to calculate the errors in out circuit. In each case we take the error data from the datasheet and convert it to an absolute or relative error depending on what we need. We also look at the temperature dependencies and calculate the worst case error over the range of temperatures of interest.

In the first part of the table, we find the error in the reference path up to the inverting input of the comparator (including the comparator input offset error). This is shaded blue since we are adding errors. The reference error is ±5mV at 25˚C but could be as much as ±10mV at the temperature extremes. The input offset voltage (±2.5mV at 25˚C and ±4mV over temperature) appears as a voltage source in series with the reference at the inverting input of the comparator. The resulting error on the 2.5V reference at the comparator input over the temperature range of interest is therefore  ±14mV or 5,600ppm or 0.056% if you prefer.

Now let us look at the op amp gain stage. We have to work backwards here, dividing the comparator input voltage back through the op amp stage. This means we need to use relative errors, so the next part of the table is shaded green. The biggest source of error is the resistor ratio that sets the gain (the ratio of two 1% resistors requires us to add their relative errors) with an error of 2% or 20,000ppm at 25˚C. Over the temperature range this rises to 22,000ppm.

Since the input voltage is the op amp output voltage divided by the gain, we have to add the relative errors of the op amp gain and the comparator input voltage, giving ±27,600ppm relative error. In absolute terms, this represents ±27.6mV since we are now dealing with a full scale quantity of 1V.

But of course, our op amp is not ideal – it has an input offset voltage and current, and an input bias current, all of which have temperature coefficients. The currents will induce an error voltage at the op amp input as they flow through the gain setting resistors. The last section of the error table shows how these contribute to the overall accuracy of the circuit. This section is shaded blue since we are adding absolute errors again.

The net result is that we will have a worst case error of ±31mV (3.1% on 1V) on the detection of the 1.0V threshold.

If this is not good enough, the first thing we would do is to use better matched resistors. Switching to resistors matched to 0.1%,  with 10ppm/˚C drift would improve the circuit error to ±1.1% or ±11 mV. To do better than that we would need to look at high precision components.

These calculations are of course a worst case situation, where all the errors are at their maxima and accumulating in the same direction. In addition, the data sheets have much better “typical” values. Are we being too pessimistic?

This is a statistical game. Chances are that if we build one circuit it will behave much better than this analysis suggests. But if you build 10,000 units, the chances are you will be scrapping several hundred that don’t meet spec.

Data sheet typical values should be considered as being for marketing purposes only. They are likely to be set at one standard deviation away from the mean. This means that typical covers roughly 68% of all cases, meaning 32% of devices will fall outside this range. Use the maximum error values and watch out for temperature. In our example circuit the error at 5˚C or 45˚C  is 20% worse than the error at 25˚C.

Calculating errors can be tedious, but in precision designs it is an important process, not only because it lets you know the total error. Probably more importantly it helps pinpoint the critical contributors to error.

References
“LM4040.Pdf.” Accessed August 21, 2023. https://www.diodes.com/assets/Datasheets/LM4040.pdf

“LM324.Pdf.” Accessed August 21, 2023. https://www.ti.com/lit/ds/symlink/lm224.pdf?HQS=dis-dk-null-digikeymode-dsf-pf-null-wwe&ts=1692585664880.

“LM193.Pdf.” Accessed August 21, 2023. https://www.ti.com/lit/ds/symlink/lm193.pdf?ts=1640569642482.

 Keep up-to-date with our FREE Weekly Newsletter! Don't miss out on upcoming issues of Circuit Cellar. Subscribe to Circuit Cellar Magazine Note: We’ve made the Dec 2022 issue of Circuit Cellar available as a free sample issue. In it, you’ll find a rich variety of the kinds of articles and information that exemplify a typical issue of the current magazine. Would you like to write for Circuit Cellar? We are always accepting articles/posts from the technical community. Get in touch with us and let's discuss your ideas.