The complete package for applications that necessitate combined ADC and DAC operation
A
A
Hardware Overview
How does it work?
ADAC 2 Click is based on the MAX22000, an industrial-grade, software-configurable analog input/output solution from Analog Devices. It provides a high-performance 18-bit DAC in the transmit path and a 24-bit delta-sigma ADC in the receive path. The transmit path (analog output) and the receive path (analog inputs) are entirely independent; thus, they can be programmed for different configurations and modes of operation. Thanks to its outstanding performance and features, this board is designed to support various industrial applications such as programmable logic controllers (PLCs), programmable automation controllers (PACs), and process control applications that require configurable analog I/O. This Click board™ communicates with an MCU through a standard SPI interface for all configuration and management information with a maximum frequency of 20MHz. The MAX22000 provides multiple voltages and current ranges for its inputs and outputs to maintain the best accuracy. It sets the linear range at 105% of the nominal range and the full scale at 125% of the nominal range.
For example, for a ±10V nominal range, the MAX22000 provides a linear range of ±10.5V and a full-scale range of ±12.5V. Other ranges can be achieved by configuring the appropriate registers. The MAX22000 also offers one output marked as CIO, configured as voltage or current output, alongside three analog inputs (AI4, AI5, and AI6) configurable as voltage or current inputs. Besides their use as general-purpose analog inputs, the AI5 and AI6 pins can also be configured as a differential programmable gain amplifier (PGA) for either low-voltage or high-voltage inputs to support RTD and thermocouple measurements. A high-performance filter allows the ADC to provide 50Hz/60Hz normal mode rejection at selected ADC data rates. Current measurement using the AI5 and AI6 pins relies on an external precision resistor to perform the current-to-voltage conversion. A GPIO pin on the additional GPIO header can control an external analog switch to connect or disconnect the current sense resistor electronically for current measurements that do not use a differential sensor.
In addition, several mikroBUS™ pins are used. An active-low reset signal routed on the RST pin of the mikroBUS™ socket activates a hardware reset of the system (all registers go to their power-on default states, analog output goes high impedance, analog inputs power down, and ADC conversion stops) while the INT pin on the mikroBUS™ socket represents a standard interrupt feature providing a user with feedback information. It also has an additional data-ready interrupt marked as RDY and routed on the AN pin of the mikroBUS™ socket, used to signal when a new ADC conversion result is available in the data register. This Click board™ can only be operated with a 3.3V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. However, the Click board™ comes equipped with a library containing functions and an example code that can be used as a reference for further development.
Features overview
Development board
EasyPIC v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports many high pin count 8-bit PIC microcontrollers from Microchip, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, EasyPIC v8 provides a fluid and immersive working experience, allowing access anywhere and under any
circumstances at any time. Each part of the EasyPIC v8 development board contains the components necessary for the most efficient operation of the same board. In addition to the advanced integrated CODEGRIP programmer/debugger module, which offers many valuable programming/debugging options and seamless integration with the Mikroe software environment, the board also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.
Communication options such as USB-UART, USB DEVICE, and CAN are also included, including the well-established mikroBUS™ standard, two display options (graphical and character-based LCD), and several different DIP sockets. These sockets cover a wide range of 8-bit PIC MCUs, from the smallest PIC MCU devices with only eight up to forty pins. EasyPIC v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU
Architecture
PIC
MCU Memory (KB)
32
Silicon Vendor
Microchip
Pin count
28
RAM (Bytes)
3648
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project assembly
Track your results in real time
Application Output via UART Mode
1. Once the code example is loaded, pressing the "FLASH" button initiates the build process, and programs it on the created setup.
2. After the programming is completed, click on the Tools icon in the upper-right panel, and select the UART Terminal.
3. After opening the UART Terminal tab, first check the baud rate setting in the Options menu (default is 115200). If this parameter is correct, activate the terminal by clicking the "CONNECT" button.
4. Now terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.
Software Support
Library Description
This library contains API for ADAC 2 Click driver.
Key functions:
adac2_set_active_ain_channel
This function sets the active analog input channel.adac2_read_voltage
This function reads the RAW ADC value of the previous conversion and converts it to voltage.adac2_write_dac
This function sets the analog output by writing to the AO_DATA_WR register.
Open Source
Code example
This example can be found in NECTO Studio. Feel free to download the code, or you can copy the code below.
/*!
* @file main.c
* @brief ADAC 2 Click example
*
* # Description
* This example demonstrates the use of ADAC 2 click board by setting the DAC output (CIO)
* and reading the ADC results from a single-ended channel (AI4) and from a differential
* channel (AI5+, AI6-) as well as toggling all GPIO pins.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and performs the click default configuration which enables
* DAC voltage output, sets the analog input mode to single-ended for AI4 and
* differential (AI5+, AI6-), and enables all GPIOs as output.
*
* ## Application Task
* Reads the ADC results from a single-ended (AI4) and a differential (AI5+, AI6-) channels,
* then sets the raw DAC output increasing the value by 10000 after each iteration, and toggles
* all GPIO pins. The results will be displayed on the USB UART approximately once per second.
*
* @author Stefan Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "adac2.h"
static adac2_t adac2;
static log_t logger;
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
adac2_cfg_t adac2_cfg; /**< Click config object. */
/**
* Logger initialization.
* Default baud rate: 115200
* Default log level: LOG_LEVEL_DEBUG
* @note If USB_UART_RX and USB_UART_TX
* are defined as HAL_PIN_NC, you will
* need to define them manually for log to work.
* See @b LOG_MAP_USB_UART macro definition for detailed explanation.
*/
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
adac2_cfg_setup( &adac2_cfg );
ADAC2_MAP_MIKROBUS( adac2_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == adac2_init( &adac2, &adac2_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( ADAC2_ERROR == adac2_default_cfg ( &adac2 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
float voltage;
if ( ADAC2_OK == adac2_set_active_ain_channel ( &adac2, ADAC2_CH_AI4_SINGLE_ENDED ) )
{
adac2_start_conversion ( &adac2, ADAC2_DATA_RATE_450_SPS );
// Waits for the availability of the conversion result
while ( adac2_get_rdy_pin ( &adac2 ) );
adac2_stop_conversion ( &adac2 );
if ( ADAC2_OK == adac2_read_voltage ( &adac2, ADAC2_FULL_SCALE_RANGE_12p5V, &voltage ) )
{
log_printf ( &logger, " Channel AI4 single-ended: %.2f V\r\n", voltage );
}
}
if ( ADAC2_OK == adac2_set_active_ain_channel ( &adac2, ADAC2_CH_AI5_AI6_DIFFERENTIAL_25V ) )
{
adac2_start_conversion ( &adac2, ADAC2_DATA_RATE_450_SPS );
// Waits for the availability of the conversion result
while ( adac2_get_rdy_pin ( &adac2 ) );
adac2_stop_conversion ( &adac2 );
if ( ADAC2_OK == adac2_read_voltage ( &adac2, ADAC2_FULL_SCALE_RANGE_25V, &voltage ) )
{
log_printf ( &logger, " Channel AI5-AI6 differential: %.2f V\r\n", voltage );
}
}
static int32_t dac = ADAC2_DAC_MIN_VALUE;
if ( ADAC2_OK == adac2_write_dac ( &adac2, dac ) )
{
log_printf ( &logger, " DAC: %ld\r\n", dac );
dac += 5000;
if ( dac > ADAC2_DAC_MAX_VALUE )
{
dac = ADAC2_DAC_MIN_VALUE;
}
}
uint32_t gpio_data;
if ( ADAC2_OK == adac2_read_register ( &adac2, ADAC2_REG_GEN_GPIO_CTRL, &gpio_data ) )
{
gpio_data ^= ADAC2_GPIO_ALL_MASK;
if ( ADAC2_OK == adac2_write_register ( &adac2, ADAC2_REG_GEN_GPIO_CTRL, gpio_data ) )
{
log_printf ( &logger, " GPIO: 0x%.2X\r\n\n", ( uint16_t ) ( gpio_data & ADAC2_GPIO_ALL_MASK ) );
}
}
Delay_ms ( 1000 );
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END