Influence of ADC decision and its reference
Engineers at all times wish to get all they’ll from their circuits; this holds for analog-to-digital converters (ADCs). To maximise efficiency from an ADC, decision is probably the first spec to concentrate on. Nevertheless, the unhappy reality is that we now have outlined the utmost single-read decision as soon as we choose the ADC and its reference. For instance, let’s say we use a 10-bit ADC with a 5-V reference. Because of this our studying decision is 5 V / (1023) or 4.888 mV per digital step. However what if we had this ADC system and needed to apply it to a sensor that had an output of 0 to 1 V? The ADC decision stays at 4.888 mV, however which means there are just one V /4.888 ms, or ~205 usable steps, so in essence, we now have lowered the sensor’s decision to 1 half in 205.
What if we have been designing a tool to measure the voltage throughout an inductor when a DC step voltage is utilized by a collection resistor? You possibly can see within the curve beneath (Determine 1), within the first couple of seconds we most likely would get respectable information level readings, however after that, most of the information factors would have the identical worth because the slope is shallow. In different phrases, the relative error can be excessive.
Determine 1 Pattern inductor voltage versus time curve for a circuit measuring the voltage throughout an inductor when a DC step voltage is utilized by a collection resistor. Notice the flat slope after 3 seconds, which can improve the relative error of the measurement.
Wow the engineering world along with your distinctive design: Design Concepts Submission Information
There are two primary methods to vary this:
- Change the ADC to at least one with extra bits (reminiscent of 12, 14, or 16 bits) or,
- Change the ADC’s reference voltage.
(There are additionally extra unique methods to vary decision, reminiscent of utilizing delta-sigma converters.) Altering the variety of bits would imply an exterior ADC or a special microcontroller. So, what if we designed a system with an adjustable reference? This decision might change routinely as wanted—let’s name this adaptive decision.
Adaptive decision demo
Let’s have a look at a simple technique first. The Microchip ATMEGA328P has three settings for the interior ADC reference: the Vcc voltage, an inside 1.1-V reference, and an exterior reference pin (REF). So, for demonstration, the only setup is to make use of an Arduino Nano, which makes use of the ATMEGA328P.
The demonstration makes use of one of many analog inputs, which might hook up with a 10-bit ADC, to measure voltage or the sensor output. The trick right here is to set the reference to Vcc (+5 V on this design) and take an ADC studying of the analog enter.
If the studying, after being transformed to a voltage, is bigger than 1.1 V, use that worth as your measurement. If it’s not higher than 1.1 V, change the reference to the interior 1.1-V band-gap voltage and retake the studying. Now, assuming your sensor or measured voltage is slow-moving relative to your pattern charge, you’ve a higher-resolution studying than you’d have had with the 5-V reference.
Referring to our inductor instance, Determine 2 illustrates how this adaptive decision will change because the voltage drops.
Determine 2 Change in adaptive decision utilizing the Microchip ATMEGA328P’s inside ADC with both reference Vcc voltage of 5 V or inside reference of 1.1 V.
Adaptive decision code
The next is a bit of C code to exhibit the idea of adaptive decision.
[An aside: As a test, I used Microsoft Copilot AI to write the basic code, and it did a surprisingly good job with good variable names, comments, and offered a clean layout. It also converted the ADC digital to the analog voltage correctly. As I was trying to get Copilot to add some logic changes, it got messier, so at that point, I hand-coded the modifications and cleanup.]
// Outline the analog enter pin
const int analogPin = A0;
// Variable to retailer the reference voltage (in mV)
const float referenceVoltage5V = 4753.0; // Enter the precise mv worth right here
const float referenceVoltage1p1V = 1099.0; // Enter the precise mv worth right here
// Sorts and variable to trace reference state
enum ReferenceState {Ref_5, Ref_1p1};
ReferenceState reference = Ref_5;
void setup() {
// Initialize serial communication at 9600 bits per second
Serial.start(9600);
// Set the analog reference to 5V (default)
analogReference(DEFAULT);
reference = Ref_5; // Set reference state
}
void loop() {
int sensorValue = 0;
int junk = 0;
float voltage = 0;
sensorValue = analogRead(analogPin); // Take a studying utilizing the present reference
if (reference == Ref_5) {
voltage = (sensorValue / 1023.0) * referenceVoltage5V; //Convert studying
if (voltage < 1100) { // Test if the voltage is lower than 1.1V
// Change the ref voltage to 1.1v and take a brand new studying
analogReference(INTERNAL); // Set the analog reference to 1.1V (inside)
reference = Ref_1p1; // Set reference state
junk = analogRead(analogPin); // Take a throw-away learn after ref change
sensorValue = analogRead(analogPin); // Take a brand new studying utilizing 1.1v ref
voltage = (sensorValue / 1023.0) * referenceVoltage1p1V; //Convert studying
}
}
else // Reference is presently set to 1.1v
voltage = (sensorValue / 1023.0) * referenceVoltage1p1V; //Convert studying
if (sensorValue == 1023) { // Test if the ADC is at most (>= 1.1v)
// Voltage is 1.1 volts or higher, so change to 5v ref and reread
analogReference(DEFAULT); // Set the analog reference to 5V (default)
reference = Ref_5; // Set reference state
junk = analogRead(analogPin); // Take a throw-away learn after reference change
sensorValue = analogRead(analogPin); // Take a studying utilizing the 5v reference
voltage = (sensorValue / 1023.0) * referenceVoltage5V; //Convert studying
}
// Print the analog worth and voltage to the serial monitor
if (reference == Ref_5) Serial.print("Analog worth with 5V reference: ");
else Serial.print("Analog worth with 1.1V reference: ");
Serial.print(sensorValue);
Serial.print(", Voltage: ");
Serial.println(voltage / 1000,4);
// Delay for a second earlier than the subsequent loop
delay(1000);
}
This code repeatedly reads the ADC linked to analog pin A0. It begins by utilizing Vcc (~5 V) because the reference for the ADC. If the studying is lower than 1.1 V, the ADC reference is switched to the 1.1-V inside reference. This reference is sustained for use till the ADC returns its most binary worth of 1023, which implies the A0 voltage have to be 1.1 V or higher. So, on this case, the reference is switched to Vcc once more. After taking a sound voltage studying, the code prints the reference worth used together with the studying.
The 5 V and 1.1 V references have to be calibrated earlier than use to get correct readings. This ought to be accomplished utilizing a fairly good voltmeter (I used a calibrated 5½ digit meter). These measured voltages can then be entered into the code.
Notice that in direction of the highest of the code, the 5-V reference voltage variable (“referenceVoltage5V”) is about to the precise voltage as measured on the REF pin of the Arduino Nano, when the enter on A0 is bigger than 1.1 V. The 1.1-V reference voltage variable (“referenceVoltage1p1V”) must also be set by measuring the voltage on the REF pin when the A0 voltage is lower than 1.1 V. Determine 3 beneath illustrates this idea.
Determine 3 This code repeatedly reads the ADC linked to analog pin A0. If A0 voltage < 1.1 V, the ADC reference is switched to 1.1 V. If A0 > 1.1 V, the ADC reference is switched to Vcc.
Relative error between 1.1 V and 5 V references
A number of items of information exhibiting the advance of this adaptive decision are as follows: Round 1.1-V, the 5-V referenced studying can have a decision error of as much as 0.41% whereas the 1.1-V reference studying can have as much as a 0.10% error. At 100 mV, a studying that references 5 V might have as much as a 4.6% error, whereas a 1.1-V referenced studying might have as much as a 1.1% error. Once we attain a 10-mV enter sign, the 5 V reference might err by 46% whereas the 1.1 V reference studying shall be 10.7% or much less.
Increasing reference ranges
Exterior DAC technique
If wanted, this idea might be expanded so as to add extra ranges of reference, though I wouldn’t go greater than 3 or 4 ranges on a 10-bit ADC as a result of diminishing returns. The next are a number of examples of how this might be accomplished.
The primary makes use of a DAC with its personal reference tied to the Nano’s REF pin. The DAC managed by the Nano might then be adjusted to offer any variety of reference values. An instance of such a DAC is the MAX5362 DAC with I2C management (though its inside reference is 0.9xVcc, so the max studying can be roughly 4.5 V). On this design, the Nano’s REF pin can be set to “EXTERNAL.” See Determine 4 beneath for extra readability.
Determine 4 Utilizing an exterior DAC (MAX5362) managed by the Arduino Nano to offer extra reference ranges.
Nano’s PWM output technique
One other technique to create a number of reference voltages might be by utilizing the Arduino Nano’s PWM output. This could require utilizing a high-frequency PWM and superb filtering to acquire a pleasant flat DC sign, which is proportional to the 5-V reference worth. You’ll desire a ripple voltage of about 1 mV (-74 dB down) or much less to get a clear, usable output. The outputs would additionally have to be measured to calibrate it within the code. This method would require minimal components however would provide you with many alternative ranges of reference voltages to make use of. Determine 5 exhibits a block diagram of this idea.
Determine 5 Utilizing the Arduino Nano’s PWM output and a lowpass filter to acquire the specified DC sign to make use of as a voltage reference.
Resistor ladder technique
One other risk for an adjustable reference is utilizing a resistor ladder and an analog swap to pick out completely different nodes within the ladder. One thing just like the TI TMUX1204 could also be applicable for this idea. The resistor ladder values will be chosen to fulfill your reference necessities. Determine 6 exhibits that two digital outputs from the Nano are additionally used to pick out the suitable place within the resistor ladder.
Determine 6 Utilizing a resistor ladder and an analog swap, e.g., TI TMUX1204, to pick out completely different nodes on the ladder to generate tailor-made voltage reference values.
You get the thought
There are different methods to assemble the reference voltages, however you get the thought. The larger image right here is utilizing a number of references to enhance the decision of your voltage readings. This can be an answer on the lookout for an issue, however isn’t that what engineers do—match up issues with options?
Damian Bonicatto is a consulting engineer with many years of expertise in embedded {hardware}, firmware, and system design. He holds over 30 patents.
Phoenix Bonicatto is a contract author.
Associated Content material
- Not all oscilloscopes are made equal: Why ADC and low noise flooring matter
- Measure twice reduce as soon as: Selecting the proper ADC analog enter kind to cut back danger of redesign
- 15-bit voltage-to-time ADC for “Correct Perform” anemometer linearization
- Constructing a low-cost, precision digital oscilloscope – Half 2
- Understanding noise, ENOB, and efficient decision in ADCs
- Create a DAC from a microcontroller’s ADC
- Designing antialias filters for ADCs
The submit Adaptive decision for ADCs appeared first on EDN.