AD3530R/AD3530

AD3530R/AD3530 IIO DAC Linux Driver.

The AD3530R/AD3530 are low power, 8-channel, 16-bit, buffered voltage output, digital-to-analog converters (DACs) that include a 2.5 V, TBD ppm/°C internal reference (disabled by default), and a gain bit field, resulting in a full-scale output span of 2.5 V (gain = 1) or 5 V (gain = 2) for a reference voltage of 2.5 V. These devices operate from a single, 2.7 V to 5.5 V supply range and are guaranteed monotonic by design.

Supported Devices

Evaluation Boards

Description

This is a Linux industrial I/O (Linux Industrial I/O Subsystem) subsystem driver, targeting single-channel serial interface DACs. 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 Linux Industrial I/O Subsystem for more information.

Source Code

Status

Source

Mainlined?

git

WIP

Files

Example platform device initialization

Devicetree

Required device tree properties:

  • compatible: Needs to be adi, followed by the name of the device. E.g. adi,ad3530r

  • reg: The chipselect number used for the device

  • spi-max-frequency: Maximum SPI clock frequency

Optional device tree properties:

  • ref-supply: Reference Input/Output. The voltage at the REF pin sets the full-scale range of all channels. If not provided the internal reference is used and also provided on the VREF pin.

  • reset-gpios: Active low signal that is falling edge sensitive. When it is deasserted, the digital core initialization is performed and all DAC registers except the Interface Configuration A register are reset to their default values.

  • ldac-gpios: LDAC pin to be used as a hardware trigger to update the DAC channels. If not present, the DAC channels are updated by Software LDAC.

  • adi,range-double: Configure the output range for all channels. If the property is present, the output will range from 0V to 2Vref. If the property is not present, the output will range from 0V to Vref.

Example Overlay

&spi0 {
    #address-cells = <1>;
    #size-cells = <0>;
    status = "okay";

    ad3530r: ad3530r@0 {
        compatible = "adi,ad3530r";
        reg = <0>;
        spi-max-frequency = <1000000>;

        #address-cells = <1>;
        #size-cells = <0>;
};

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.

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

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

root@analog:/sys/bus/iio/devices/iio:device0# ls -l
total 0
-rw-r--r-- 1 root root 4096 Dec 17 09:31 muxout_select
-r--r--r-- 1 root root 4096 Dec 17 09:31 muxout_select_available
-r--r--r-- 1 root root 4096 Dec 17 09:31 name
lrwxrwxrwx 1 root root    0 Dec 17 09:31 of_node -> ../../../../../../../../firmware/devicetree/base/soc/spi@7e204000/dac@0
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage0_offset
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage0_powerdown
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage0_powerdown_mode
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage0_raw
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage0_scale
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage1_offset
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage1_powerdown
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage1_powerdown_mode
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage1_raw
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage1_scale
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage2_offset
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage2_powerdown
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage2_powerdown_mode
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage2_raw
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage2_scale
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage3_offset
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage3_powerdown
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage3_powerdown_mode
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage3_raw
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage3_scale
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage4_offset
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage4_powerdown
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage4_powerdown_mode
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage4_raw
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage4_scale
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage5_offset
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage5_powerdown
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage5_powerdown_mode
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage5_raw
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage5_scale
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage6_offset
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage6_powerdown
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage6_powerdown_mode
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage6_raw
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage6_scale
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage7_offset
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage7_powerdown
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage7_powerdown_mode
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage7_raw
-rw-r--r-- 1 root root 4096 Dec 17 09:31 out_voltage7_scale
-r--r--r-- 1 root root 4096 Dec 17 09:31 out_voltage_powerdown_mode_available
drwxr-xr-x 2 root root    0 Dec 17 09:31 power
lrwxrwxrwx 1 root root    0 Dec 17 09:31 subsystem -> ../../../../../../../../bus/iio
-rw-r--r-- 1 root root 4096 Dec 17 09:31 uevent
-r--r--r-- 1 root root 4096 Dec 17 09:31 waiting_for_supplier
root@analog:/sys/bus/iio/devices/iio:device0#

Show device name

root@analog:/sys/bus/iio/devices/iio:device0> cat name
ad3530r

Show scale

Description: /sys/bus/iio/devices/iio:deviceX/out_voltageY_scale

Scale to be applied to out_voltageY_raw in order to obtain the measured voltage in millivolts.

root@analog:/sys/bus/iio/devices/iio:device0> cat out_voltage0_scale
0.038146972
Show offset

Description: /sys/bus/iio/devices/iio:deviceX/out_voltageY_offset

Raw offset to be applied to out_voltageY_raw in order to obtain the measured voltage in millivolts. The offset is applied before scale is applied.

root@analog:/sys/bus/iio/devices/iio:device0> cat out_voltage0_offset
0
Set channel Y output voltage

Description: /sys/bus/iio/devices/iio:deviceX/out_voltageY_raw

Raw (unscaled, no bias etc.) output voltage for channel Y.

root@analog:/sys/bus/iio/devices/iio:device0> echo 10000 > out_voltage0_raw

V = (out_voltage0_raw + out_voltage0_offset) * out_voltage0_scale = (10000 - 0) * 0.038146972 = ** 381.46972 mV**

Enable power down mode on output Y

Description: /sys/bus/iio/devices/iio:deviceX/out_voltageY_powerdown

Writing 1 causes output Y to enter the power down mode. Clearing returns to normal operation.

root@analog:/sys/bus/iio/devices/iio:device0> echo 1 > out_voltage0_powerdown
root@analog:/sys/bus/iio/devices/iio:device0> cat out_voltage0_powerdown
1
root@analog:/sys/bus/iio/devices/iio:device0> echo 0 > out_voltage0_powerdown
root@analog:/sys/bus/iio/devices/iio:device0> cat out_voltage0_powerdown
0
Muxout Select

Description: Selects which of the multiplexer’s input signals will be monitored on the MUX_OUT pin.

root@analog:/sys/bus/iio/devices/iio:device0> cat muxout_select_available
powered_down vout0 iout0_source iout0_sink vout1 iout1_source iout1_sink vout2 iout2_source iout2_sink vout3 iout3_source iout3_sink vout4 iout4_source iout4_sink vout5 iout5_source iout5_sink vout6 iout6_source iout6_sink vout7 iout7_source iout7_sink die_temp agnd
root@analog:/sys/bus/iio/devices/iio:device0> echo vout0 > muxout_select
root@analog:/sys/bus/iio/devices/iio:device0> cat muxout_select
vout0

Hardware Interface

Using:

Wiring/Connection

Evaluation Board

RPI4

P4 PIN 6/SCK

SCLK SPI0

P4 PIN 5/SDO

MISO SPI0

P4 PIN 4/SDI

MOSI SPI0

P4 PIN 3/CS

CE SPI0

P2 PIN 2/IOREF

3.3V

P7 PIN 1/EXT_VDD

5V

P7 PIN 2/PGND

GND

https://wiki.analog.com/_media/resources/tools-software/linux-drivers/iio-dac/ad3530r_wiring2.png

More Information