Measure a Bipolar Signal with an Arduino Board

Arduino is a popular family of open source microcontroller boards. Hobbyists, students and engineers all over the world use this platform to quickly design and prototype a microcontroller driven circuit. One of its interfaces with the analog world is the ADC. Since these boards are mostly designed around an ATMEL ATmega32 or ATmega168 microcontroller, the ADC has 8 inputs and 10-bit resolution, making it suitable for many applications.

From time to time I receive a message through my Contact page with the question, how to interface a sensor, or an outside circuit with the Arduino ADC? In most cases the answer is an interface between a bipolar circuit and the Arduino board. As the bipolar circuit output varies from some negative to a positive level, the Arduino ADC cannot measure this signal directly, because the ADC inputs can only be between 0V and the reference voltage.

In one of these messages a reader asked me how to build an interface between a board that has an output voltage of -2.5V to +2.5V and the Arduino ADC. He told me that the Arduino reference voltage is AVCC = 5V. He would like to measure the +/-2.5V signal with the Arduino board and direct the microcontroller to take some action based on the result.

Read more…

An ADC and DAC Least Significant Bit (LSB)

Articles on Internet and books show how to calculate the Least Significant Bit (LSB), but they take into consideration either the voltage reference (Vref) or the full scale (FS) of the ADC or DAC.  Many times this leads to confusion, as a few messages I received from my readers show.  Therefore, this article shows both ways of defining the LSB, so that people will have a clear understanding how to treat an ADC’s (Analog-to-Digital-Converter) or DAC’s (Digital-to-Analog-Converter) LSB.

Read more…

An ADC and DAC Differential Non-Linearity (DNL)

As in the case of INL, DNL is an important parameter of an ADC or DAC because it is a measure of their non-linearity.  DNL stands for Differential Non-Linearity and quantifies the ADC or DAC precision.

The term differential refers to the values an ADC takes between two consecutive levels.  When the input signal swings in any direction, the ADC samples the signal and its output is a stream of binary numbers.  An ideal ADC will step up or down one Least Significant Bit (LSB), without skipping any level and without holding the same decimal number past two or three LSBs. However, due to technological limitations, ADCs and even DACs are not ideal.  When that happens, the ADC’s linearity is severely impacted.  Therefore, DNL is defined as the maximum deviation from one LSB between two consecutive levels, over the entire transfer function.

In an electronic system, linearity is important.  When an ADC is non-linear, it brings imprecision in measurements.  If a DAC is non-linear, it restores a dynamic signal with high distortions.  Moreover, an accumulation of skipped levels, or high DNL, can increase the INL as well.

Figuring out the DNL value is quite simple. One has to measure the ADC response to a voltage value that would correspond to one LSB. For example, if we have a 12-bit ADC and the voltage reference is 2.5V, one LSB is given by the following equation.

image001

So, for each 0.6103 mV increase in the ADC input, the output hexadecimal value will increase with one.

figure-1

Figure 1

An ideal ADC transfer function is shown in Figure 1.  This is a 12-bit ADC, but the steps are exaggerated for better viewing.  There is no deviation from 1 LSB step, so the DNL is zero.

figure-2_2

Figure 2

In Figure 2, the ADC holds the 0x800 hex output for two full steps. Since the deviation is towards the positive values on the X scale, and the ADC output holds the same value for an extra LSB, the Differential Non-Linearity is +1 LSB.

figure-2_3

Figure 3

Figure 3 shows that the DNL migrated towards negative values for one LSB. Therefore, DNL in Figure 3 is -1 LSB. Since 0x800 is missing, there the ADC is categorized with missing codes.  Such an ADC cannot be used for high precision applications.

The DNL in Figure 4 is -0.75, because the 0x800 is still there, but for a shorter voltage range than one LSB.  The code is still there, so the ADC can be used in precision applications.

figure-3_2

Figure 4

In Figure 5, the 0x800 step appears at lower voltage inputs than one LSB.  The DNL is -1.25 LSB. It is clear that the ADC is highly non-linear.  Moreover, it is categorized non-monotonic.  High DNL values, positive or negative can increase the INL as well.

figure-2_4

Figure 5

A non-monotonic DAC is highly undesirable, especially if the DAC is used in a closed loop application like servo or process controls.  With a non-monotonic DAC the system may become unstable, or the control may suffer from jumpiness, jitteriness and overall difficult control handling.

The main rule for precision applications is to choose a component with a DNL less than one LSB. In this case, the ADC or DAC is assured monotonicity, no missing codes and a good linearity.

An ADC and DAC Integral Non-Linearity (INL)

What is INL?  This term describes the non-linearity of Analog to Digital Converters (ADC) and Digital to Analog Converters (DAC).  INL stands for Integral Non-Linearity.  Is this term important? Should we be concerned about this specification?  The answer is yes.

INL is considered an important parameter because it is a measure of an ADC or DAC non-linearity error.  However, as in any Analog or Mixed-Signal Design project, some specifications are important, some are not.  It all depends on the project requirements regarding accuracy and precision.  Understanding INL enables the circuit designer to avoid surprises in his or her project.

The Integral Non-Linearity is defined as the maximum deviation of the ADC transfer function from the best-fit line.  An ADC function is to digitize a signal into a stream of digital words called samples.  The ADC output is discrete as opposed to the input, which is continuous.  It is used at the boundary between the analog and digital realms.

The ADC input is usually connected to an operational amplifier, maybe a summing or a differential amplifier which are linear circuits and process an analog signal.  As the ADC is included in the signal chain, we would like the same linearity to be maintained at the ADC level as well.  However, inherent technological limitations make the ADC non-linear to some extent and this is where the INL comes into play.

figure-1

Figure 1

Figure 1 shows the ADC transfer function.  For each voltage in the ADC input there is a corresponding word at the ADC output.  The figure shows a 12-bit ADC where the steps were exaggerated for better viewing.  The y axis, the output, is digital, so that the values are represented in hexadecimal format.  If the ADC is ideal, the steps shown are perfectly superimposed on a line.

figure-2

Figure 2

Figure 2 shows an ADC with a slight non-linearity.  To express the non-linearity in a standard way, manufacturers draw a line through the ADC transfer function, called the best fit line.  The maximum deviation from this line is called INL, which can be expressed in percentage of the full scale or in LSBs (List Significant Bit). INL is measured from the center of each step to that point on the line, where the center of the step would be if the ADC was ideal.

This parameter is important because it cannot be calibrated out.  The ADC non-linearity is unpredictable.  We don’t know where on the ADC scale the maximum deviation from the ideal line is.  Therefore, if one of the design requirements is good accuracy, we need to choose an ADC with the INL within the accuracy specifications, or a lot less than the specified error.

For example, let’s say the electronic device we design has an ADC that needs to measure the input signal with a precision of 0.5% of full-scale.  Due to the ADC quantization, if we choose a 12-bit ADC, the initial measurement error is +/- 1/2 LSB which is called the quantization error.

image0031

With the ADC quantization error almost 40 times lower than the design requirements, a 12-bit ADC can do a good job for us.  However, if the INL is large, the actual ADC error may come close to the design requirements of 0.5%.  We would like to keep each component error in the circuit as low as possible, so that the total combined error of the electronic device we design is less than 0.5%.  Gain or offset errors in an ADC can be calibrated out, but INL cannot.  If we need to live with an evil, at least we need to choose an ADC with a small INL.  This may increase the cost we allocate for the ADC in the system, but it is worthwhile if we are to keep our promises and design a device within specifications.

The DAC Integral Non-Linearity can be viewed the same as for an ADC.  The only difference is that, with a DAC, the INL may not be as important.  If the DAC is used to set a few voltage levels in a system, those values may be easily calibrated, so we can choose a low cost DAC.  However, if the DAC is used to accurately restore a dynamic signal, the INL cannot be easily calibrated.  In that case, we need to choose a high precision DAC, with a good INL.

Show Buttons
Hide Buttons
'