0
0
Embedded Cprogramming~10 mins

ADC conversion process (sample and hold) in Embedded C - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - ADC conversion process (sample and hold)
Start ADC Conversion
Sample Input Voltage
Hold Sampled Voltage
Convert Analog to Digital
Store Digital Value
End
The ADC process starts by sampling the input voltage, holding it steady, converting it to a digital value, and then storing the result.
Execution Sample
Embedded C
void ADC_Convert() {
  float sample = SampleInput();
  HoldVoltage(sample);
  int digitalValue = ConvertToDigital(sample);
  StoreValue(digitalValue);
}
This code samples an analog input, holds it, converts it to digital, and stores the result.
Execution Table
StepActionInput/VariableResult/Output
1Start ADC Conversion-Begin process
2Sample Input VoltageAnalog input voltagesample = 2.5V
3Hold Sampled Voltagesample = 2.5VVoltage held steady at 2.5V
4Convert Analog to Digitalsample = 2.5VdigitalValue = 512 (10-bit ADC)
5Store Digital ValuedigitalValue = 512Value stored in ADC register
6End-Conversion complete
💡 Conversion ends after storing the digital value.
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4Final
sampleundefined2.5V2.5V2.5V2.5V
digitalValueundefinedundefinedundefined512512
Key Moments - 2 Insights
Why do we need to hold the voltage after sampling?
Holding the voltage keeps the sampled value steady during conversion, as shown in step 3 of the execution table.
What does the digitalValue represent after conversion?
digitalValue is the number representing the analog voltage in digital form, as seen in step 4 and 5.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the value of 'sample' after step 2?
Aundefined
B512
C2.5V
D0V
💡 Hint
Check the 'sample' variable in the variable_tracker after step 2.
At which step is the analog voltage converted to a digital value?
AStep 4
BStep 3
CStep 2
DStep 5
💡 Hint
Look at the 'Action' column in the execution_table for conversion.
If the input voltage changes during holding, what would happen to the digitalValue?
AdigitalValue would be accurate regardless
BdigitalValue would be incorrect because voltage is not steady
CdigitalValue would be zero
DConversion would stop immediately
💡 Hint
Refer to the importance of holding voltage steady in step 3.
Concept Snapshot
ADC Conversion Process (Sample and Hold):
1. Start conversion
2. Sample input voltage
3. Hold voltage steady
4. Convert analog to digital
5. Store digital value
Holding ensures stable conversion.
Full Transcript
The ADC conversion process begins by starting the conversion. The system samples the analog input voltage, for example 2.5 volts. Then it holds this sampled voltage steady to prevent changes during conversion. Next, the analog voltage is converted into a digital number, such as 512 for a 10-bit ADC. Finally, the digital value is stored in a register, completing the conversion process. Holding the voltage is important to get an accurate digital value. If the voltage changes during holding, the digital result would be incorrect.