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). The AD3530R includes a 2.5 V internal reference with 5 ppm/°C typical drift, disabled by default; the AD3530 uses an external reference. Both devices have 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 multi-channel serial interface DACs (eight channels for AD3530/AD3530R and four for AD3531/AD3531R). 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?

ADI tree

Yes

Files

Function

Status

driver

dt-bindings

Hardware configuration

Using:

Wiring/Connection

Disconnect the SDP-K1 controller before connecting an external controller to the PMOD interface. Supply the evaluation board from its external USB-C connector or terminal block when using this interface.

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

Adding Linux driver support

Devicetree configuration

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

  • vdd-supply: Phandle to the analog power supply regulator.

  • iovdd-supply: Phandle to the digital I/O power supply regulator.

  • ref-supply: Required external reference regulator for non-R models (AD3530/AD3531). Optional for R models, which use the internal 2.5 V reference when it is absent.

Optional device tree properties:

  • 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 platform device initialization

Example Overlay

This AD3530R fragment uses the internal reference. The board must define spi0 and the vdd and iovdd regulator labels for the supplies connected to the device. Adapt these labels to the actual board; non-R models also require an external reference supplied through ref-supply.

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

    ad3530r: ad3530r@0 {
        compatible = "adi,ad3530r";
        reg = <0>;
        spi-max-frequency = <1000000>;
        vdd-supply = <&vdd>;
        iovdd-supply = <&iovdd>;
    };
};

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#

Identify the device

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

Basic operation

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

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

More Information