====== AD7124 IIO Sigma-Delta ADC Linux Driver ====== ===== Supported Devices ===== This driver supports the * [[adi>AD7124-4]] * [[adi>AD7124-8]] ===== Evaluation Boards ===== * [[adi>EVAL-AD7124-4]] * [[adi>EVAL-AD7124-8]] ===== Description ===== This is a Linux industrial I/O ([[software:linux:docs:iio:iio|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 [[software:linux:docs:iio:iio|IIO]] for more information. ===== Status ===== ^ Source ^ Mainlined? ^ | [[git.linux.org>drivers/iio/adc/ad7124.c|git]] | [[git.linux.org>drivers/iio/adc/ad7124.c|Yes]] | ===== Files ===== ^ Function ^ File ^ | driver | [[git.linux.org>drivers/iio/adc/ad7124.c]] | | devicetree bindings | [[git.linux.org>Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml | Documentation/devicetree/bindings/iio/adc/adi,ad7124.yaml]] | ====== Driver testing ====== {{page>software:linux:docs:iio:iio_snippets#iio device files&noheader&firstseconly&noeditbtn}} **TIP:** An example program which uses the interface can be found here: * [[resources:tools-software:linux-software:iio_oscilloscope|IIO Oscilloscope]] \\ 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 ====== {{page>software:linux:docs:iio:iio_snippets#iio pointers&noheader&firstseconly&noeditbtn}} 百度