Wiki

This version is outdated by a newer approved version.DiffThis version (19 Oct 2018 10:26) was approved by Stefan Popa.

This is an old revision of the document!


AD7124 IIO Sigma-Delta ADC Linux Driver

Supported Devices

This driver supports the

Evaluation Boards

Description

This is a Linux industrial I/O (IIO) subsystem driver, targeting single channel serial interface ADCs. The industrial I/O subsystem provides a unified framework for drivers for many different types of converters and sensors using a number of different physical interfaces (i2c, spi, etc). See IIO for more information.

Status

Source Mainlined?
git [In progress…]

Files

Driver testing

Each and every IIO device, typically a hardware chip, has a device folder under /sys/bus/iio/devices/iio:deviceX. Where X is the IIO index of the device. Under every of these directory folders reside a set of files, depending on the characteristics and features of the hardware device in question. These files are consistently generalized and documented in the IIO ABI documentation. In order to determine which IIO deviceX corresponds to which hardware device, the user can read the name file /sys/bus/iio/devices/iio:deviceX/name. In case the sequence in which the iio device drivers are loaded/registered is constant, the numbering is constant and may be known in advance.

02 Mar 2011 15:16

TIP: An example program which uses the interface can be found here:


This specifies any shell prompt running on the target

root:/> cd /sys/bus/iio/devices/
root:/sys/bus/iio/devices> ls
iio:device0

root:/sys/bus/iio/devices> cd iio\:device0

root:/sys/bus/iio/devices/iio:device0> ls -l
drwxr-xr-x 2 root root    0 Jun 23 21:46 buffer
-r--r--r-- 1 root root 4096 Jun 23 21:46 dev
-rw-r--r-- 1 root root 4096 Jun 23 21:46 in_voltage0-voltage1_offset
-rw-r--r-- 1 root root 4096 Jun 23 21:46 in_voltage0-voltage1_raw
-rw-r--r-- 1 root root 4096 Jun 23 21:46 in_voltage0-voltage1_sampling_frequency
-rw-r--r-- 1 root root 4096 Jun 23 21:46 in_voltage0-voltage1_scale
-rw-r--r-- 1 root root 4096 Jun 23 21:46 in_voltage2-voltage3_offset
-rw-r--r-- 1 root root 4096 Jun 23 21:46 in_voltage2-voltage3_raw
-rw-r--r-- 1 root root 4096 Jun 23 21:46 in_voltage2-voltage3_sampling_frequency
-rw-r--r-- 1 root root 4096 Jun 23 21:46 in_voltage2-voltage3_scale
-rw-r--r-- 1 root root 4096 Jun 23 21:46 in_voltage4-voltage5_offset
-rw-r--r-- 1 root root 4096 Jun 23 21:46 in_voltage4-voltage5_raw
-rw-r--r-- 1 root root 4096 Jun 23 21:46 in_voltage4-voltage5_sampling_frequency
-rw-r--r-- 1 root root 4096 Jun 23 21:46 in_voltage4-voltage5_scale
-rw-r--r-- 1 root root 4096 Jun 23 21:46 in_voltage6-voltage7_offset
-rw-r--r-- 1 root root 4096 Jun 23 21:46 in_voltage6-voltage7_raw
-rw-r--r-- 1 root root 4096 Jun 23 21:46 in_voltage6-voltage7_sampling_frequency
-rw-r--r-- 1 root root 4096 Jun 23 21:46 in_voltage6-voltage7_scale
-r--r--r-- 1 root root 4096 Jun 23 21:46 name
lrwxrwxrwx 1 root root    0 Jun 23 21:46 of_node -> ../../../../../../../../firmware/devicetree/base/soc/spi@7e204000/ad7124-4@0
drwxr-xr-x 2 root root    0 Jun 23 21:46 power
drwxr-xr-x 2 root root    0 Jun 23 21:46 scan_elements
lrwxrwxrwx 1 root root    0 Jun 23 21:46 subsystem -> ../../../../../../../../bus/iio
drwxr-xr-x 2 root root    0 Jun 23 21:46 trigger
-rw-r--r-- 1 root root 4096 Jun 23 21:46 uevent

Show device name

This specifies any shell prompt running on the target

root:/sys/bus/iio/devices/iio:device0> cat name
ad7124-4

Show channel scale and offset

Description:
Scales and offsets to be applied to in_voltagex_voltagey_raw in order to obdatin the measured voltage in millivolts

This specifies any shell prompt running on the target

root:/sys/bus/iio/devices/iio:device0> cat in_voltage0-voltage1_scale 
0.000149011
root:/sys/bus/iio/devices/iio:device0> cat in_voltage0-voltage1_offset 
0
root:/sys/bus/iio/devices/iio:device0> cat in_voltage0-voltage1_raw 
2679470

Description: Channel Ainp0-Ainm1 is configured as unipolar, with a gain of 1
U = in_voltage0-voltage1_raw * in_voltage0-voltage1_scale - in_voltage0-voltage1_offset = 2679470 * 0.000149011 - 0 = 399.27 mV

This specifies any shell prompt running on the target

root:/sys/bus/iio/devices/iio:device0> cat in_voltage2-voltage3_scale 
0.000298023
root:/sys/bus/iio/devices/iio:device0> cat in_voltage2-voltage3_offset 
-2500
root:/sys/bus/iio/devices/iio:device0> cat in_voltage2-voltage3_raw 
9716211

Description: Channel Ainp2-Ainm3 is configured as bipolar, with a gain of 1
U = in_voltage2-voltage3_raw * in_voltage2-voltage3_scale - in_voltage2-voltage3_offset = 9716211* 0.000298023 - 2500= 395.65 mV

Set sampling frequency

Description: The output data rate depends on the master clock frequency (fclk) which in turn determines the power mode:

  • Full power (fCLK = 614.4 kHz): 9.38 SPS to 19,200 SPS
  • Mid power (fCLK = 153.6 kHz): 2.34 SPS to 4800 SPS
  • Low power (fCLK = 76.8 kHz): 1.17 SPS to 2400 SPS

This specifies any shell prompt running on the target

root:/sys/bus/iio/devices/iio:device0> cat in_voltage0-voltage1_sampling_frequency
10
root:/sys/bus/iio/devices/iio:device0> cat in_voltage2-voltage3_sampling_frequency
960
root:/sys/bus/iio/devices/iio:device0> echo 2400 > in_voltage0-voltage1_sampling_frequency
root:/sys/bus/iio/devices/iio:device0> cat in_voltage0-voltage1_sampling_frequency
2400
root:/sys/bus/iio/devices/iio:device0> echo 5000 > in_voltage2-voltage3_sampling_frequency
root:/sys/bus/iio/devices/iio:device0> cat in_voltage2-voltage3_sampling_frequency
4800

More Information

resources/tools-software/linux-drivers/iio-adc/ad7124.1539689385.txt.gz · Last modified: 16 Oct 2018 13:29 by Stefan Popa