Beginner
10 min

Achieve precise and reliable measurements of resistor values using AD8616 and PIC32MZ2048EFM100

Ohm's law made easy: Explore the power of our resistor value detector

R Meter Click with Curiosity PIC32 MZ EF

Published Sep 28, 2023

Click board™

R Meter Click

Dev Board

Curiosity PIC32 MZ EF

Compiler

NECTO Studio

MCU

PIC32MZ2048EFM100

Experience a new era of accuracy with our resistor measurement solution, designed to provide real-time data on resistor values for a wide range of applications

A

A

Hardware Overview

How does it work?

R Meter Click is based on the AD8616, a precision 20MHz CMOS rail-to-rail input/output operational amplifier from Analog Devices. This dual-channel amplifier features low offset voltage, wide signal bandwidth, and low input voltage and current noise. The analog output is fed to the MCP3201, a 12-bit AD converter with the SPI serial interface from Microchip. The MCP3201 provides a single pseudo-differential input, features on-chip sample and hold, a maximum sampling rate of up to 100ksps, and more. The MCP3201 gets the reference voltage from the MAX6106, a low-cost, micropower, low-dropout, high-output-current voltage reference from Analog Devices. Since the AD converter has a limited min-max range

of 0-2043, the R Meter Click employs the 74HC4053, a triple 2-channel analog multiplexer/demultiplexer from Nexperia. The multiplexer adjusts the input signal to the amplifier and thus allows the same ADC to measure different scopes of values (0-1K, 1K-100K, 100K-1M). The R Meter Click is a handy tool, but it’s not to be used as a precision instrument. The linearity of the OpAmp impacts the measurement. The R Meter Click uses the 3-Wire SPI serial interface of the MCP3201 to communicate with the host MCU, with a frequency of up to 1.6MHz and supporting SPI 0 and SPI 1 modes. The voltage amplified through the AD8616 can be directly monitored through the AN pin of the mikroBUS™

socket. The supplied firmware (available on Libstock) automatically scans the ADC value and switches the multiplexer output based on the resistor place. The multiplexer interfaces directly with the host MCU through the mikroBUS™ socket over S1, S2, and S3 pins. This Click board™ can be operated only with a 5V logic voltage level. The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. Also, it comes equipped with a library containing functions and an example code that can be used as a reference for further development.

R Meter hardware overview image

Features overview

Development board

Curiosity PIC32 MZ EF development board is a fully integrated 32-bit development platform featuring the high-performance PIC32MZ EF Series (PIC32MZ2048EFM) that has a 2MB Flash, 512KB RAM, integrated FPU, Crypto accelerator, and excellent connectivity options. It includes an integrated programmer and debugger, requiring no additional hardware. Users can expand

functionality through MIKROE mikroBUS™ Click™ adapter boards, add Ethernet connectivity with the Microchip PHY daughter board, add WiFi connectivity capability using the Microchip expansions boards, and add audio input and output capability with Microchip audio daughter boards. These boards are fully integrated into PIC32’s powerful software framework, MPLAB Harmony,

which provides a flexible and modular interface to application development a rich set of inter-operable software stacks (TCP-IP, USB), and easy-to-use features. The Curiosity PIC32 MZ EF development board offers expansion capabilities making it an excellent choice for a rapid prototyping board in Connectivity, IOT, and general-purpose applications.

Curiosity PIC32MZ EF double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

2048

Silicon Vendor

Microchip

Pin count

100

RAM (Bytes)

524288

Used MCU Pins

mikroBUS™ mapper

Analog Output
RPB4
AN
Select Input 3
RA9
RST
SPI Chip Select
RPD4
CS
SPI Clock
RPD1
SCK
SPI Data OUT
RPD14
MISO
NC
NC
MOSI
NC
NC
3.3V
Ground
GND
GND
Select Input 1
RPE8
PWM
Select Input 2
RF13
INT
NC
NC
TX
NC
NC
RX
NC
NC
SCL
NC
NC
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Schematic

R Meter Click Schematic schematic

Step by step

Project assembly

Curiosity PIC32MZ EF front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Curiosity PIC32 MZ EF as your development board.

Curiosity PIC32MZ EF front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Curiosity PIC32 MZ EF MB 1 Access - upright/background hardware assembly
Necto image step 2 hardware assembly
Necto image step 3 hardware assembly
Necto image step 4 hardware assembly
Necto image step 5 hardware assembly
Necto image step 6 hardware assembly
Curiosity PIC32 MZ EF MCU Step hardware assembly
Necto No Display image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Debug Image Necto Step hardware assembly

Track your results in real time

Application Output

After loading the code example, pressing the "DEBUG" button builds and programs it on the selected setup.

Application Output Step 1

After programming is completed, a header with buttons for various actions available in the IDE appears. By clicking the green "PLAY "button, we start reading the results achieved with Click board™.

Application Output Step 3

Upon completion of programming, the Application Output tab is automatically opened, where the achieved result can be read. In case of an inability to perform the Debug function, check if a proper connection between the MCU used by the setup and the CODEGRIP programmer has been established. A detailed explanation of the CODEGRIP-board connection can be found in the CODEGRIP User Manual. Please find it in the RESOURCES section.

Application Output Step 4

Software Support

Library Description

This library contains API for R Meter Click driver.

Key functions:

  • rmeter_get_ohms - Get resistance in OHMs function

  • rmeter_avg_volt - Get average voltage function

  • rmeter_calc - Calculations function

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
 * \brief R Meter Click example
 *
 * # Description
 * Demo app measures and displays resistance of a resistor connected 
 * to the R Meter click board.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initalizes SPI serial communication, LOG module and click driver.
 * Also sets the app callback handler.
 *
 * ## Application Task
 * This is an example that shows the capabilities of the R Meter click by 
 * measuring the target resistance.
 *
 * *note:*
 * R Meter click is a handy tool but it is not to be used as a high precision 
 * instrument! The linearity of the OP Amplifier impacts the measurement.
 * The range of resistance measurement goes from 1 ohm to 1M9 ohms.
 *
 * \author Nemanja Medakovic
 *
 */

#include "board.h"
#include "log.h"
#include "rmeter.h"

static rmeter_t rmeter;
static log_t logger;

void application_callback ( char *message )
{
    log_printf( &logger, "- %s\r\n", message );
}

void application_init ( void )
{
    log_cfg_t log_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... ----" );

    rmeter_cfg_t rmeter_cfg;

    //  Click initialization.

    rmeter_cfg_setup( &rmeter_cfg );
    RMETER_MAP_MIKROBUS( rmeter_cfg, MIKROBUS_1 );

    if ( rmeter_init( &rmeter, &rmeter_cfg ) == RMETER_INIT_ERROR )
    {
        log_info( &logger, "---- Application Init Error. ----" );
        log_info( &logger, "---- Please, run program again... ----" );

        for ( ; ; );
    }

    rmeter_set_callback_handler( &rmeter, application_callback );

    log_info( &logger, "---- Application Init Done. ----\n" );
}

void application_task ( void )
{
    uint16_t meas_value = rmeter_auto_scale_range_execution( &rmeter );

    float res_value;

    if ( rmeter_calculate_resistance( &rmeter, &res_value, meas_value ) == RMETER_OK )
    {
        log_printf( &logger, "  - Resistor value is %.1f ohms\r\n\n", res_value );
    }

    Delay_ms( 3000 );
}

void main ( void )
{
    application_init( );

    for ( ; ; )
    {
        application_task( );
    }
}


// ------------------------------------------------------------------------ END

Additional Support

Resources

Love this project?

'Buy This Kit' button takes you directly to the shopping cart where you can easily add or remove products.