Analog-to-Digital Converters

Overview

figures/physical-qty.png

Overview

  • These physical values are always varying time to time.
  • Transducers/sensors convert these physical values into analog electrical values, not consumable by microcontroller.
  • ADC transforms analog electrical values to digital values.
  • The no. of signals that an ADC can handle is called, channels.
  • Vice versa is also happening in case of speaker using DAC.

Overview

figures/flow.png

Overview

  • For a change in physical quantity a corresponding change in voltage will be observed.
figures/sensor.png

ADC

figures/adc-steps.png

Applications

Various usage

  • Connecting sensors,
    • Temperature sensor
    • LDR
    • POT
  • Music recording

ADC in Target Board

Target

  • 3 ADCs.
  • 18 channels.
  • 2 of 18 channels are connected to Potentiometer and LDR.

ADC in Linux

Sysfs interface

  • In Linux, ADC devices are accessed via sysfs
  • Listed under /sys/bus/iio/devices
  • Files in this directory represents digital value corresponds to analog voltage.

Sysfs Files

  • in_voltageX_raw - contains the converted digital value.
  • in_voltage_scale - contains the step constant.

Calculation

figures/adc-scale.png

Accessing LDR

  • LDR - Light Dependent Resistor.
  • When exposed to bright light, provides low voltage.
  • When it is dark, provides high voltage.
figures/ldr.png

Accessing LDR

  • Digital value.
# cat /sys/bus/iio/devices/iio\:device2/in_voltage0_raw
  • Scale value.
# cat /sys/bus/iio/devices/iio\:device2/in_voltage_scale

ADC library

  • Accessing LDR using ADC library.
  • LDR is connected to channel 0.
  • Download ADC library.
>>> from adc import *
>>> ldr = 0
>>>
>>> while True:
>>>     print("{}".format(adc_read_value(ldr)))

Try Out

  • Accessing Potentiometer using ADC library.
  • Potentiometer is connected to channel 1.
  • Get the voltage value using adc_read_voltage(pot)

Try Out-1

figures/backlight.png