Digilent provides the ZmodADC1410 Library used to access ZmodADC1410 functionality.
It is part of a pack of libraries to handle the Zmod modules functionality. They cover both Linux and baremetal (standalone) platforms.
The Zmod Base Library implements the functionality that is common to all Zmods.
For each Zmod, separate libraries are implemented, based on the Zmod Base Library. This document describes the ZmodADC1410 Library.
The current usage instructions / demos are provided for the ZmodADC1410 attached to Eclypse board, still ZmodADC1410 can be attached to any Zynq board providing the SYZYGY connector.
Note: At the time of writing, the ZmodADC1410 library only supports the Zmod Scope 1410-105 (formerly known as the Zmod ADC 1410.
The following image shows the overall structure of Zmod Libraries.
The ZmodADC1410 and Zmod Base Library run on the Zynq PS (processing system).
A ZmodADC1410 specific IP core needs to be instantiated in the programmable logic (PL). This IP core can be accessed from the Zynq PS through its registers. The IP core is able to communicate with the memory through a DMA engine. Each Zmod has one particular AXI DMA IP core associated.
Basically:
Read more on ZMODADC1410 IP behaviour below in the page.
The ZMODADC1410 Library implementation uses the Zmod Base Library, which provides the needed functionality in order to access hardware resources in a consistent manner. No hardware related functionality is implemented on ZMODADC1410 Library.
The ZMODADC1410 Library implementation consists of:
The ZMODADC1410 class constructor calls the ZMOD base class constructor providing all the required parameters. For these parameters and how they can be obtained by the user, read ZMOD class Constructor / Destructor chapter.
The constructor also calls initCalib calibration initialziation function, providing the ZmodADC1410 unique ID and the length of the ZmodADC1410 calibration area (see Calibration functions of ZMOD class).
ZMODADC1410 class provides functions that implement the analog to digital converter function.
Read ZMODADC1410 IP behaviour chapter for details about ZMODADC1410 IP functionality.
The acquisition related functions of ZMODADC1410 class are implemented using basic ZMOD class functionality.
The following functions are only defined for Baremetal platform, because the ZMODADC1410 IP Buffer full interrupt is not implemented on Linux:
The Calibration functions of ZMOD class chapter provides information about all the calibration functionality provided by the base ZMOD class.
The readUserCalib function calls the base class function readUserCalib in order to populate the calibration data, then interprets the calibration data as ZMODADC1410 calibration, computes and sets the ZMODADC1410 IP calibration coefficients.
The ZMODADC1410 class provides setCalibValues function that allows the user to set the calibration pair values (gain, additive) for a specific channel (1, 2) and gain (LOW, HIGH). This function only changes the calibration data image, so in order to actually apply the changes, the writeUserCalib function must be called.
The writeUserCalib function should be used very careful, as it may alter the calibration values. Note that calibration values can be always restored using restoreFactoryCalib function.
As explained in the IP Register access functions of ZMOD class, the ZMOD class provides read/write register and read/write register bit field functions, both in signed and unsigned versions: readReg, writeReg, readRegFld, writeRegFld, readSignedRegFld and writeSignedRegFld.
The registers and register bit fields common to all Zmods are defined in the base class header zmod.h and are prefixed by ZMOD_REG and ZMOD_REGFLD.
The registers and register bit fields specific to ZMODADC1410 are defined in the ZMODADC1410 class header (zmodadc1410.h) and are prefixed by ZMODADC1410_REG and ZMODADC1410_REGFLD.
The following table lists the common and ZMODADC1410 specific register definitions. The ZMODADC1410 specific register definitions are highlighted in green.
| Address | Register | Bit Field | |||
|---|---|---|---|---|---|
| Bit Field name | Start bit | Length | Description | ||
| 0x00 | ZMOD_REG_ADDR_CR | ZMOD_REGFLD_CR_CMD_RUNSTP | 1 | 1 | CMD_RUNSTP field of CR register |
| ZMOD_REGFLD_CR_CMD_READ_EN | 2 | 1 | CMD_READ_EN field of CR register | ||
| ZMOD_REGFLD_CR_INTR_EN | 3 | 1 | INTR_EN field of CR register | ||
| ZMODADC1410_REGFLD_CR_RUNSTOP | 4 | 1 | RUNSTOP field of CR register | ||
| ZMODADC1410_REGFLD_CR_TEST_MODE | 5 | 1 | TEST_MODE field of CR register | ||
| ZMOD_REGFLD_CR_RST | 31 | 1 | RST field of CR register | ||
| 0x04 | ZMOD_REG_ADDR_SR | ZMOD_REGFLD_SR_TX_DONE | 0 | 1 | TX_DONE field of SR register |
| ZMOD_REGFLD_SR_CMD_RUNNING | 2 | 1 | CMD_RUNNING field of SR register | ||
| ZMOD_REGFLD_SR_CMD_TX_COUNT | 3 | 7 | CMD_TX_COUNT field of SR register | ||
| ZMODADC1410_SR_BIT_BUF_FULL | 21 | 1 | BUF_FULL field of SR register | ||
| 0x08 | ZMOD_REG_ADDR_IER | ZMOD_REGFLD_IER_CMD_TX_DONE | 0 | 1 | CMD_TX_DONE field of IER register |
| ZMOD_REGFLD_IER_CMD_RX_DONE | 1 | 1 | CMD_RX_DONE field of IER register | ||
| ZMOD_REGFLD_IER_CMD_TX_RX_ERROR | 2 | 4 | CMD_TX_RX_ERROR field of IER register | ||
| ZMODADC1410_REGFLD_IER_BUF_FULL | 21 | 1 | BUF_FULL field of IER register | ||
| 0x14 | ZMOD_REG_ADDR_AXIS_S2MM_LENGTH | ZMOD_REGFLD_AXIS_S2MM_LENGTH_LENGTH | 0 | 26 | LENGTH field of AXIS_S2MM_LENGTH register |
| 0x18 | ZMOD_REG_ADDR_AXIS_MM2S_LENGTH | ZMOD_REGFLD_AXIS_MM2S_LENGTH_LENGTH | 0 | 26 | LENGTH field of AXIS_MM2S_LENGTH register |
| 0x1C | ZMODADC1410_REG_ADDR_TRIG | ZMODADC1410_REGFLD_TRIG_CHANNEL | 0 | 2 | CHANNEL field of TRIG register |
| ZMODADC1410_REGFLD_TRIG_MODE | 2 | 2 | MODE field of TRIG register | ||
| ZMODADC1410_REGFLD_TRIG_EDGE | 4 | 1 | EDGE field of TRIG register | ||
| ZMODADC1410_REGFLD_TRIG_LEVEL | 5 | 14 | LEVEL field of TRIG register | ||
| ZMODADC1410_REGFLD_TRIG_SC1_AC_DC | 19 | 1 | SC1_AC_DC field of TRIG register | ||
| ZMODADC1410_REGFLD_TRIG_SC2_AC_DC | 20 | 1 | SC2_AC_DC field of TRIG register | ||
| ZMODADC1410_REGFLD_TRIG_SC1_HG_LG | 21 | 1 | SC1_HG_LG field of TRIG register | ||
| ZMODADC1410_REGFLD_TRIG_SC2_HG_LG | 22 | 1 | SC2_HG_LG field of TRIG register | ||
| ZMODADC1410_REGFLD_TRIG_SYNC | 23 | 4 | SYNC field of TRIG register | ||
| 0x20 | ZMODADC1410_REG_ADDR_WINDOW | ZMODADC1410_REGFLD_WINDOW_WND | 0 | 24 | WND field of WINDOW register |
| 0x24 | ZMODADC1410_REG_ADDR_SC1LGMULTCOEF | ZMODADC1410_REGFLD_SC1LGMULTCOEF_VAL | 0 | 18 | VAL field of SC1LGMULTCOEF register |
| 0x28 | ZMODADC1410_REG_ADDR_SC1HGMULTCOEF | ZMODADC1410_REGFLD_SC1HGMULTCOEF_VAL | 0 | 18 | VAL field of SC1HGMULTCOEF register |
| 0x2C | ZMODADC1410_REG_ADDR_SC1LGADDCOEF | ZMODADC1410_REGFLD_SC1LGADDCOEF_VAL | 0 | 18 | VAL field of SC1LGADDCOEF register |
| 0x30 | ZMODADC1410_REG_ADDR_SC1HGADDCOEF | ZMODADC1410_REGFLD_SC1HGADDCOEF_VAL | 0 | 18 | VAL field of SC1HGADDCOEF register |
| 0x34 | ZMODADC1410_REG_ADDR_SC2LGMULTCOEF | ZMODADC1410_REGFLD_SC2LGMULTCOEF_VAL | 0 | 18 | VAL field of SC2LGMULTCOEF register |
| 0x38 | ZMODADC1410_REG_ADDR_SC2HGMULTCOEF | ZMODADC1410_REGFLD_SC2HGMULTCOEF_VAL | 0 | 18 | VAL field of SC2HGMULTCOEF register |
| 0x3C | ZMODADC1410_REG_ADDR_SC2LGADDCOEF | ZMODADC1410_REGFLD_SC2LGADDCOEF_VAL | 0 | 18 | VAL field of SC2LGADDCOEF register |
| 0x40 | ZMODADC1410_REG_ADDR_SC2HGADDCOEFF | ZMODADC1410_REGFLD_SC2HGADDCOEF_VAL | 0 | 18 | VAL field of SC2HGADDCOEF register |
The ZMODADC1410 library is delivered as part of the Zmod libraries pack.
The library usage is similar for all Zmod libraries, and it is explained in the
Library usage
chapter of Zmod Base Library user guide.
Basically, the ZMODADC1410 IP (labeled ZMOD_ADC Library block diagram of the Overview section) directly interfaces with the ZmodADC1410 device performing an initial configuration and providing an easy to use interface that the upper level IPs or software can use to transfer data or configuration information to the device. It exposes to the PS a set of command and status registers that the ZmodADC1410 library functions use to control the IP. The ZMODADC1410 Library uses these registers to control the IP and read its status.
Using these registers, the ADC acquisition can be configured, started or stopped. The ADC acquisition is composed of the following steps:
The ZMODADC1410 IP supports two gain range settings: HIGH and LOW. The HIGH input RANGE of the ADC (-25 to +25 V) corresponds to a LOW gain selection in the library functions - using the gain parameter in the setGain() function of the zmodadc1410 library files, while the LOW input RANGE of the ADC (-1V to +1V) corresponds to a HIGH setting value of the gain parameter inside the library mentioned above.
The raw data exported by the ZMODADC1410 should be further analyzed considering the gain parameter setting used for the acquisition.
For more details about the input ranges of the module, consult the ZMODADC1410 Reference Manual
For more details on ZmodADC1410 IP interface consult the ZmodADC1410 IP User Guide.
Read more on Parameters chapter below for more details.
| Term | Meaning |
|---|---|
| channel | ADC channels provided by ZmodADC1410: 0 - channel 1 1 - channel 2 |
| trigger level | The value specified by the trigger condition |
| trigger mode | The value indicating the trigger mode: 0 - normal 1 - no trigger |
| trigger edge | The value indicating the trigger edge: 0 - rising 1 - falling |
| internal buffer length | The length of the ZmodADC1410 IP internal buffer. Maximum value = 0x3FFE |
| transfer length | The number of samples to be transferred over AXI DMA. It has the same value as the internal buffer length. |
| window position | The position in the buffer where trigger condition is met. Maximum value = internal buffer length. |
| S2MM | Stream to Memory Mapped The AXI DMA Receive mode |
| gain | The gain setting, corresponding to a Low or High range of values 0 - LOW Gain 1 - HIGH gain |
| coupling | The coupling for ZmodADC1410: 0 - DC Coupling 1 - AC Coupling |
git clone --recursive https://github.com/Digilent/Eclypse-Z7-SW.git -b zmod_adc/master
| Download the ADC Demo files |
|---|
| ZMODADC1410 Demo Files |
The ADC Linux demo performs (repeatedly) un-triggered acquisitions and writes the data to a file and to the standard output.
The file only contains the content of one acquisition, as it is overwritten.
Function called from main is adcDemo(), with the following parameters:
This function further calls the writeADCData() function, which formats the data contained in the buffer and writes it to a file and to the standard output - SDK console.
The file is overwritten any time the function is called.
It displays the acquired value (in mV), raw value (as 14 bits hexadecimal value) and time stamp within the buffer (in time units) on the UART terminal.
Parameters transmitted from the user further to library functions:
The user is able to dynamically change the parameters values of adcDemo() function in order to analyze the module capabilities or use it in further projects. The application is contained in the generic workspace and is suggestively called ZmodADC1410_Demo_Linux. The location and name of the file containing one buffer acquisition is found in the location: /home/eclypse/buffer_data.csv
Steps to run the Demo:
The ADC Baremetal demo is in fact a simple ADC acquisition and test, performing a un-triggered acquisition. The demo also provides another function that is not called (testZMODADC1410Ramp_Auto) which puts the ADC in the test mode (ramp).
It also verifies the acquired data to be consistent with the conditions specified by the trigger settings.
Function called from main is adcDemo(), with the following parameters:
This function further calls the formatADCDataOverUART() function, which formats the data contained in the buffer and sends it over UART.
It displays the acquired value (in mV), raw value (as 14 bits hexadecimal value) and time stamp within the buffer (in time units) on the UART terminal.
Parameters transmitted from the user further to library functions:
The user could change the parameters values of adcDemo() function in order to analyze the module capabilities or use it in further projects. The application is contained in the generic workspace and is suggestively called ZmodADC1410_Demo_Baremetal
Steps to run the Demo: