Login / Signup

Analog to Digital Converter & Digital to Analog Converter - Overview

  • user warning: Table './devemc/sessions' is marked as crashed and last (automatic?) repair failed query: SELECT COUNT(sid) AS count FROM sessions WHERE timestamp >= 1422504419 AND uid = 0 in /home/devemc/public_html/dev/includes/session.inc on line 157.
  • user warning: Table './devemc/sessions' is marked as crashed and last (automatic?) repair failed query: SELECT COUNT(DISTINCT s.uid) FROM sessions s WHERE s.timestamp >= 1422504419 AND s.uid > 0 in /home/devemc/public_html/dev/modules/user/user.module on line 790.
Analog to Digital Converter & Digital to Analog Converter - Overview

Analog to Digital Converter & Digital to Analog Converter - Overview

1. General Aspects
On the other hand, computers are digital systems, that's why we absolutely need to find a way to get analogue signals and convert them as digital data, and the other way around, get digital data and convert them to analogue signals. That's where analog to digital converters (ADCs) and digital to analog converters (DACs) come handy.


An analog signal is represented by a continuous value, like temperature. A digital signal is a discrete value in time, encoded as a binary value in computer systems.

Analog to Digital - Digital to Analog

2. Analog to Digital Converters - Architectures

2.1 Counting ADC

Counting ADC


The measured signal is provided at Vi input. After the counter is reset, using “clear” signal, a clock pulse is used to increment the counter value. On the same time the counter value is served as input for the DAC and it is converted into an analogue value. This analogue output value is increasing and is compared at every step with the Vi; when Vdac>Vi, the comparator turns the output off and the counter value is frozen. The digital output of the counter is exactly the binary representation of the Vi analogue input which was required for conversion.

  • T = period of the clock signal->clock signal period
  • N = number of counter bits->counter bits number
  • Time Conversion = T * pow(2,N) seconds.

2.2 Tracking ADC

Tracking ADC

It is very similar to the previous model, but it has the advantage that when Vi>Vdac the counter is incremented and when Vidac the counter is decremented. This ADC is faster, since it keeps on tracking the analog signal. Drawback is that its output is not stable. The cost and complexity are reduced because “clear” signal and the comparator are eliminated.


2.3 Successive Approximation ADC

 Successive Approximation ADC

The voltage to be converted, Vi, is compared with the voltage generated from the DAC circuit. The sign of the Vi-Vdac operation is represented by the comparator output; this operation is done for every bit of the input DAC value.

2.4 Flash ADC

Flash ADC

It is the fastest converter because the input voltage Vi is applied in parallel to all comparators. For an n-bit ADC we need pow(2,n) - 1 comparators, which represent a big price. Digital data is represented with Y[2:0] on the above picture making it a 3 bits ADC.

2.5 Subranging Flash ADC

Subranging Flash ADC

The input value is converted by ADC1 resulting as a N1 bits digital value. The DAC receives this last code and convert back to an analogue value which is fed to the comparator. Actually the analogue value passed through ADC and then DAC will not be similar to the Vi from the input. This difference is represented by the comparator output which is converted by the ADC2 into a digital value with N2 bits. The trick is that N1 represents the MSB part of the final value and N2 represents the LSB part.
Merging these 2 groups, the desired digital data of N1+N2 bits is obtained.

2.6 Dual Slope ADC

Dual Slope ADC

Using an analog integrator we can obtain the time integral of the Vi input value:

dVo/dt = Vi/RC

When the circuit is switched on, the output voltage of the integrator ramps up for a T1 period. When this voltage is bigger than Vref the logic will be reverted and the integrator output will ramp down until 0 and will stop. The idea is to count the number of pulses on T1 ramp-up period and on T2 ramp-down period.

  • T1/T2 = periods of ramp-up/down
  • N1/N2 = number of pulses on these 2 periods
  • Vref = reference voltage
  • Vi = N2*(Vref/N1) -> N2

3. Application

Using PIC16F876A microcontroller let’s make an embedded system to control a lamp. The desired behaviour is to have an automatic turn on/off for a lamp, depending by the day/nigh alternation.
The luminosity sensor is a photo-resistor connected to ADC1 channel of microcontroller and the lamp is controlled with a triac. Please consider that the scheme is minimal; for maximum protection and accuracy better using some filters for analogue input and optic-isolation between uC and triac.

ADC Application
void init_adc(void)
	ADCON0 = 0x00;	/* select Fosc/2 */
	ADCON1 = 0x80;	/* select left justify result. A/D port configuration 0 */
	ADON = 1;       /* turn on the A2D conversion module */
unsigned int read_adc(unsigned char channel)
unsigned int val;
	channel &= 0x07;             /* truncate channel to 3 bits */
	ADCON0 &= 0xC5;              /* clear current channel select */
	ADCON0 |= (channel <<3 );  /* apply the new channel select */
	ADGO = 1;                        /* initiate conversion on the selected channel */
	while( ADGO)
	val = ADRESL;
	val = val + (ADRESH << 8);
	return val;	 
int luminosity_read()
	unsigned int luminosity;
	/* voltage increase as the luminosity increase also */
	/* Vout = Vcc * (RL / (r + RL) );  (most cases Vcc = 5V)
	/* Test case:
		Maximum luminosity RL = 27 Kohm => Vout = 0.17V
		Minimum luminosity  RL = 20 Ohm =>  Vout = 4.90V
	luminosity = read_adc(1);
	return luminosity;
#define turn_on_lamp 1000
void main(void)
int luminosity = 0;
	TRISB = 0x00;	/* configure PORTB as output */
	GIE = 0;		/* disable interrupts */
	init_adc();                   /*  init ADC module */
	while (1)
	{ /* continue read the sensor */
		/* RA1 = ADC input for luminosity sensor */
		luminosity = luminosity_read();
		/* When luminosity decrease to 0 the 
			voltage read from the sensor increase. 
			If voltage value is bigger then the adc value is bigger also.
		if (luminosity > turn_on_lamp)
			RB0 = 1; /* turn on the lamp */
		} else {
			RB0 = 0; /* turn off the lamp */
		DelayS(60);  /* read ADC once at every minute */
Luminosity vs Voltage
Luminosity vs Voltage


Great article!.

I was going to do an in depth on ADC's on my site but you have saved me the trouble.

Dale G

Who's online

There are currently users and guests online.

Recent comments