AD4130 IIO Application#

Supported Hardware#

Supported Devices:

Supported Evaluation Boards:

Supported Carrier Boards:

Introduction#

This guide gives an overview of using the IIO firmware application with Analog Devices AD4130 Evaluation board and SDP-K1 (or other compatible) MCU controller board, leveraging Mbed-OS as a primary software platform. This firmware application leverages the ADI developed IIO (Industrial Input Output) ecosystem to evaluate the AD4130 (IIO) device by providing device configuration and data capture support.

The interface used for communicating with PC based IIO clients is either Virtual Serial Or UART. IIO Firmware leverages the ADI created no-os and platform driver software layers to communicates with IIO device.

Note

This code has been developed and tested on the SDP-K1 Controller Board with Arduino headers. However, the same code can be used with minimal modifications on any Mbed enabled board which has Arduino Header support on it. To find out all supported Mbed boards, refer this link: https://os.mbed.com/platforms/

Hardware Connections#

Jumper Settings#

SDP-K1:

Connect the VIO_ADJUST jumper on the SDP-K1 board to 3.3V position to drive SDP-K1 GPIOs at 3.3V

EVAL-AD4130 (Rev D):

Note

Below jumper settings of AD4130 EVB are specific to sensor demo modes supported in the firmware. Change the jumper settings according to your requirements/demo configurations.

Jumper

User Default Config

Thermistor

RTD

Thermocouple

ECG

Power Test

LK1, LK2, LK3

Short

Short

Short

Short

Short

Short

LK4

A

A

Open

Open

Open

A

LK5

Open

Open

Open

Open

Open

Open

LK6

Short

Short

Open

Open

Open

Open

LK7

A

A

A

A

A

A

LK8, LK9, LK10, LK11

Open

Open

Open

Open

Open

Short

LK12

Open

Open

Open

Open

Open

Open

LK14

Open

Open

Open

Open

Open

Open

LK15, LK16

A

A

A

A

A

A

LK17, LK18, LK19, LK20

A

A

A

A

A

A

LK21

Open

Open

Open

Open

Open

Open

LK22

Open

Open

Open

Short

Short

Open

LK23, LK24

Open

Open

Open

Open

Open

Open

LK25

Open

Open

Open

Open

Open

Open

LK26

Short

Short

Short

Short

Short

Short

LK27

B

B

B

B

B

B

LK28

B

B

B

B

B

B

LK29

Short

Short

Short

Short

Short

Short

LK30, LK31, LK32

Open

Open

Open

Open

Open

Open

LK35

Open

Open

Short

Open

Open

Open

LK36

Open

Open

Short

Short

Short

Open

LK37

Open

Short

Open

Open

Open

Open

LK45

Open

Open

Open

Open

Open

Open

J4

Open

NA

NA

NA

NA

NA

J5

Open

NA

NA

NA

NA

NA

AVDD SW

3.3v POS

3.3v POS

3.3v POS

3.3v POS

NA

3.3v POS

IOVDD SW

3.3v POS

3.3v POS

3.3v POS

3.3v POS

NA

3.3v POS

REFIN+/- SW

REFIN1+/-

REFIN1+/-

REFIN1+/-

REFIN1+/-

NA

REFIN1+/-

T_AVDD

A

A

A

A

NA

A

T_IOVDD

A

A

A

A

NA

A

Communication Interface#

Note

For data transmission to IIO clients, IIO firmware applications uses Virtual Serial Or UART as primary communication links. Firmware by default uses the Virtual Serial interface for higher speed data transmission as SDP-K1 MCU board and Mbed firmware supports both Virtual Serial and UART interface. If you target a different MCU board that does not support Virtual Serial, just set UART as communication link in the firmware (app_config.h file).

SDP-K1 is powered through USB connection from the computer. SDP-K1 MCU board acts as a serial device when connected to PC, which creates a serial ports to connect to IIO client application running on PC. The serial port assigned to a device can be seen through the device manager for windows-based OS as shown below:

../../../_images/serial_ports_view.png

Note

The serial port naming is used differently on different operating systems. For example, Linux uses terms such as dev/ttyUSB* and Mac uses terms such as dev/tty.USB*. Please check serial port naming for your selected OS.

Identifying Virtual Serial Port (Windows-OS):

To identify if serial port is virtual, right click on the port name and select ‘Properties’. Select ‘Events’ from menu option and check for below highlighted VIDs/PIDs and firmware name which is currently running on MCU.

../../../_images/identifying_virtual_serial_port.png

SDP-K1 can support high speed Virtual Serial USB interface, so by default Virtual Serial is configured as default interface in the Mbed firmware. The interface can be set to Physical (UART) serial port by defining macro USE_PHY_COM_PORT in the app_config.h file.

/* Enable the UART/VirtualCOM port connection (default VCOM) */
//#define USE_PHY_COM_PORT           // Uncomment to select UART

Build Guide#

Build Prerequisites#

Prior to building a firmware project, it is required to set up an environment so that the build process may find the necessary tools (compiler, linker, SDK etc.). Use the following steps to prepare your environment for building firmware projects for respective platform.

  • Clone Precision Converters Firmware repository with the –recursive flag (not needed if building with web IDE for Mbed platform):

git clone --recursive https://github.com/analogdevicesinc/precision-converters-firmware
  • If however you’ve already cloned the repository without the –recursive flag, you may initialize all the submodules in an existing cloned repo with:

git submodule update --recursive --init
  • Install Make in the root of ‘C’ drive without any spaces in the installation path. The path must be C:\GnuWin32\…. Add this path into the system environmental path variable (as shown in below screenshot).

  • Install Git and add a path of C:\Program Files\Git\usr\bin\ directory into system environmental path variable (please verify your git installation path is correct).

  • Install Mbed CLI 1 as per guide here.

  • Install GNU Arm Embedded compiler (for the development, 9-2019-q4-major version is used) and add a path of GNU Arm Embedded Toolchain bin directory into the system environmental path variable (as shown in below screenshot).

  • Configure the compiler location with Mbed CLI. This can be carried out by running the mbed config -G GCC_ARM_PATH <path-to-your-gcc-compiler> in Command Prompt. For example you can run mbed config -G GCC_ARM_PATH “C:\Program Files (x86)\GNU Tools ARM Embedded\9 2019-q4-major\bin” in command prompt. It will set mentioned compiler path to all the Mbed Projects.

Building a project#

Once the build enviornment is setup, follow the guide below to build your project and generate executable file (.bin/.hex)

  • Clone the Precision Converters Firmware repository into Keil Studio using “File->clone…” menu.

  • Once the project repository is imported, wait until all library dependencies are imported as shown in below screenshot. Now, open the ‘.medignore’ file present in the root directory of repository. Add comment syntax (two forward slashes) in front of the project name which you want to build. This will ignore all other projects and build only the comment syntax selected project.

  • Select the target device (default used for development is SDP-K1) and click on ‘Clean build’ option to build the project. After a successful build a binary will be downloaded to your computer- store this on your drive. Drag and drop this binary to the USB drive hosted by your controller board to flash the MCU.

Note

If you intend to build different project, then modify the .medignore file in the root directory as mentioned in step2 and clean build project as mentioned in step3

  • Open Git bash and change current directory to project directory (eg. precision-converters-firmware/projects/ad4130_iio directory) which you want to build.

  • Type make on the git bash command prompt to build a project.

  • After successful build, binary file will be created into the Project_Name/build directory.

  • If you want to clean build, type make reset on git bash command which deletes all generated build files for the given project.

Note

Default TARGET_BOARD is SDP_K1 and COMPILER is GCC_ARM. Current Make based build only support GCC_ARM Compiler.

  • By default project is built for “SDP_K1” Board and “GCC_ARM” Compiler. If you want to build for other Mbed Board, For example If you want to build the project for “DISCO_F769NI” Board then run make TARGET_BOARD=DISCO_F769NI command in git bash command prompt. If you want to clean build, run make reset TARGET_BOARD=DISCO_F769NI command to delete the generated build files for the given project.

  • Open the respective project directory by navigating into the “precision_converters_firmware/projects/” folder.

  • In the “STM32” folder present within the project directory, double click and open the .ioc file present within.

  • Click on the “Generate Code” option seen on the top right corner

  • Upon successful generation of drivers for the selected MCU, the autogenerated files would be seen in the same directory where the .ioc file was present. Double click and open the “.project” file seen in the list of files

  • After the project is loaded to the STM32CubeIDE, unfold the adxxxx_iio project seen in the project explorer, right click the “app” folder, select “Settings” under the “C/C++ Build” section on the left pane and un-check the “Exclude resources from build” checkbox. This would ensure that the project specific files are included by the build system

  • In order to choose STM32 platform in the firmware, select the “ACTIVE_PLATFORM” as “STM32_PLATFORM” in the app_config.h from the respective project. Alternately , add compiler flag “ACTIVE_PLATFORM=value of STM32_PLATFORM in app_config.h” for selecting stm32 platform.

  • Add compiler flags “-u _printf_float” to the project settings.

  • Program by clicking on the “Run adxxxx_iio” option seen or by performing a copy->paste option of the .hex file seen in the STM32/Debug folder

Running a project#

Once the firmware build is successful and binary file is generated, copy the generated binary into USB drive hosted by your MCU board (e.g. USB drive hosted by SDP-K1 board on windows). This will flash the binary file into MCU present on the controller board. Programming might vary based on the tools used for building a project. The ‘Project Build’ section above talks about this exception at the end of all build steps.

Using the IIO Ecosystem#

IIO (Industrial Input/Output) is a flexible ecosystem that allows various client tools to communicate with IIO device to configure the device, capture device data, generate waveforms, access registers, etc. Below diagram demonstrates the high level architecture of IIO ecosystem.

https://wiki.analog.com/resources/tools-software/linux-software/libiio

IIO Tools:#

IIO Oscilloscope ADI IIO Oscilloscope is a cross platform GUI application, which demonstrates how to interface different evaluation boards within an IIO ecosystem. It supports raw data capture, FFT analysis, DMM measurement, device configuration, register read/write and data streaming.

pyadi-iio: Python interfaces Analog Devices python interfaces for hardware with Industrial I/O drivers. It provides python based scripts for raw data capture, device configuration and register read/write.

ACE ADI’s “Analysis, Control, Evaluation” (ACE) is a desktop software application which allows the evaluation and control of multiple evaluation systems.

Precision Converters MATLAB Toolbox Toolbox created by ADI to be used with MATLAB and Simulink with ADI Precision products.

IIO Command Line Command line interface for accessing IIO device parameters.

Pocketlab ADI Pocketlab is a display based GUI client. It supports raw data capture, FFT analysis, DMM measurement, device configuration, register read/write.

Note

These are the general evaluation and prototyping tools for Precision Converters but not all converters are supported. In some cases these tools provide generic IIO support (e.g. ACE, IIO Oscilloscope) and can provide basic functionality with any IIO based system. In other cases if a part is not currently supported, it is possible to add support for converters that you need due to the open source nature of the tools.

AD4130 Sensor Demo Modes#

AD4130 IIO firmware provides support for interfacing different sensors to analog inputs and perform the measurement on them. Below sensor demo modes are supported in the firmware.

  • User Default Config (All channels test)

  • 2-wire/3-wire/4-wire RTD (Default is PT100)

  • Thermistor (Default is 10K NTC)

  • Thermocouple (Default is T type TC and PT1000 RTD as CJC)

  • Load Cell (4-wire bridge)

  • Noise Test (AIN0-AIN1 shorted)

  • ECG

  • Power Test (ADC internal channels voltage/current measurement)

Note

The demo mode configurations can be changed from respective user_config header files and some sensor specific parameters can be updated from ad4130_temperature_sensor.cpp file.

Demo Mode Selection#

The sensor mode selection is done from “app_config.h” file using “ACTIVE_DEMO_MODE_CONFIG” macro. The selection is done at compilation time, that means only one sensor demo mode is active at a time. Whenever demo mode is changed from app_config.h file, the code must be compiled again to generate a new binary file for that.

Demo Mode User Configuration#

Firmware maintains the unique user configuration file for each sensor demo mode as per below table. The configurations can be updated by using .c and .h user config files.

Demo Mode

User Config Files

2-wire/3-wire/4-wire RTD

ad4130_rtd_config.c/.h

Thermistor

ad4130_thermistor_config.c/.h

Thermocouple

ad4130_thermocouple_config.c/.h

Load Cell

ad4130_loadcell_config.c/.h

Noise Test

ad4130_noise_test_config.c/.h

ECG

ad4130_ecg_config.c/.h

Power Test

ad4130_power_test_config.c/.h

Sensor Measurement#

Sensor measurement for RTD, Thermistor, Thermocouple, Noise Test, ECG, Power Test and User Default Config can be done using the IIO oscilloscope GUI client application or by executing python scripts from the ‘scripts’ folder. Temperature result for RTD, TC and Thermistor would be in degree Celsius. The result for other configs would in voltage/current.

Refer to this guide here to setup IIO enviornment for sensor measurements if not already done: Setting-up IIO Ecosystem

Sensor measurement for Load Cell can be done by executing the python script available in the project “scripts” folder. IIO oscilloscope can only support measurement for voltage, current and temperature quantities and therefore python code is developed to support measurement for other sensor types.

$ python ad4130_sensor_measurement.py
../../../_images/ad4130_sensor_demo_console.png

Sensor Channels Calibration#

It is possible to calibrate the device channels which are connected to external sensors. The sensors calibration (gain and offset) is done by executing the python script “ad4130_calibration.py”.

IIO Firmware Structure#

Below diagram illustrates the architecture of Precision Converters IIO firmware applications.

../../../_images/firmware_architecture.png

Support#

Feel free to ask questions in the EngineerZone