Help electronics understand and work with information from the real world
A
A
Hardware Overview
How does it work?
ADC Click is based on the MCP3204, a 4-channel 12-bit A/D converter with SPI serial interface from Microchip. The MCP3204 contains an input channel selection multiplexer (CH0, CH1, CH2, CH3) which for reference can use the VCC (3.3V or 5V) or a 4.096V of the MCP1541 voltage reference from Microchip. The voltage reference determines the analog voltage range and can be selected via REFERENCE onboard jumper. To connect the
analog voltages to the ADC Click, utilize the four labeled terminals CH0-3 along with two GND terminals for referencing the ground. Each analog input pin goes through the MCP6284, a 5MHz rail-to-rail OpAmp from Microchip. The ADC Click uses a standard 4-Wire SPI serial interface to communicate with the host MCU, supporting both 0 and 3 of the SPI modes and operating at clock rates of up to 2MHz. Communication with the ADC
Click is initiated by bringing the CS line LOW. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the PWR SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. However, the Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used, as a reference, for further development.
Features overview
Development board
EasyPIC v7a is the seventh generation of PIC development boards specially designed for the needs of rapid development of embedded applications. It supports a wide range of 8-bit PIC microcontrollers from Microchip and has a broad set of unique functions, such as the first-ever embedded debugger/programmer over USB-C. The development board is well organized and designed so that the end-user has all the necessary elements in one place, such as switches, buttons, indicators, connectors, and others. With four different connectors for each port, EasyPIC v7a allows you to connect accessory boards, sensors, and custom electronics more efficiently than ever. Each part of the EasyPIC v7a 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 various external power sources, including an external 12V power supply, 7-23V AC or 9-32V DC via DC connector/screw terminals, and a power source via the USB Type-C (USB-C) connector. Communication options such as USB-UART and RS-232 are also included, alongside the well-
established mikroBUS™ standard, three display options (7-segment, graphical, and character-based LCD), and several different DIP sockets. These sockets cover a wide range of 8-bit PIC MCUs, from PIC10F, PIC12F, PIC16F, PIC16Enh, PIC18F, PIC18FJ, and PIC18FK families. EasyPIC v7a 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)
2048
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ 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 ADC Click driver.
Key functions:
adc_get_single_ended_ch
- Get Single-Ended Channel functionadc_get_differential_ch
- Get Pseudo-Differential Pair function
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* \file main.c
* \brief ADC Click example
*
* # Description
* This example demonstrates the use of ADC Click board.
* The all channels can be configured as single-ended or pseudo-differential
* pair.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes SPI driver, performs the reference voltage selection and
* initializes UART console for results logging.
*
* ## Application Task
* Reads voltage level of channels 0 and 1 in the both configurations,
* single-ended and pseudo-differential pair, every 1 second.
* All channels results will be calculated to millivolts [mV].
*
* *note:*
* In single-ended mode the all channels must be in the range from Vss (GND)
* to Vref (3V3 by default).
* In pseudo-differential mode the IN- channel must be in the range from
* (Vss - 100mV) to (Vss + 100mV). The IN+ channel must be in the range from
* IN- to (Vref + IN-).
* If any of conditions are not fullfilled, the device will return 0 or Vref
* voltage level, and measurements are not valid.
*
* \author Nemanja Medakovic
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "adc.h"
// ------------------------------------------------------------------ VARIABLES
static adc_t adc;
static log_t logger;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init( void )
{
log_cfg_t log_cfg;
adc_cfg_t cfg;
/**
* 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.
adc_cfg_setup( &cfg );
ADC_MAP_MIKROBUS( cfg, MIKROBUS_1 );
adc_init( &adc, &cfg );
}
void application_task( void )
{
adc_get_single_ended_ch( &adc, ADC_CH0_OR_CH01 );
adc_get_single_ended_ch( &adc, ADC_CH1_OR_CH10 );
adc_get_single_ended_ch( &adc, ADC_CH2_OR_CH23 );
adc_get_single_ended_ch( &adc, ADC_CH3_OR_CH32 );
adc_get_differential_ch( &adc, ADC_CH0_OR_CH01 );
log_printf( &logger, "* CH0 = %u mV\r\n", adc.ch0 );
log_printf( &logger, "* CH1 = %u mV\r\n", adc.ch1 );
log_printf( &logger, "* CH2 = %u mV\r\n", adc.ch2 );
log_printf( &logger, "* CH3 = %u mV\r\n", adc.ch3 );
log_printf( &logger, "* CH0 - CH1 = %d mV\r\n", adc.ch01 );
log_printf( &logger, "-----------------------------\r\n" );
Delay_ms( 1000 );
}
void main( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END