Beginner
10 min

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

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

R Meter Click with UNI Clicker

Published Sep 28, 2023

Click board™

R Meter Click

Dev Board

UNI Clicker

Compiler

NECTO Studio

MCU

STM32F446ZE

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

UNI Clicker is a compact development board designed as a complete solution that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It supports a wide range of microcontrollers, such as different ARM, PIC32, dsPIC, PIC, and AVR from various vendors like Microchip, ST, NXP, and TI (regardless of their number of pins), four mikroBUS™ sockets for Click board™ connectivity, a USB connector, LED indicators, buttons, a debugger/programmer connector, and two 26-pin headers for interfacing with external electronics. Thanks to innovative manufacturing technology, it allows you to build

gadgets with unique functionalities and features quickly. Each part of the UNI Clicker development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the UNI Clicker programming method, using a third-party programmer or CODEGRIP/mikroProg connected to onboard JTAG/SWD header, the UNI Clicker board also includes a clean and regulated power supply module for the development kit. It provides two ways of board-powering; through the USB Type-C (USB-C) connector, where onboard voltage regulators provide the appropriate voltage levels to each component on the board, or using a Li-Po/Li

Ion battery via an onboard battery connector. All communication methods that mikroBUS™ itself supports are on this board (plus USB HOST/DEVICE), including the well-established mikroBUS™ socket, a standardized socket for the MCU card (SiBRAIN standard), and several user-configurable buttons and LED indicators. UNI Clicker is an integral part of the Mikroe ecosystem, allowing you to create a new application in minutes. Natively supported by Mikroe software tools, it covers many aspects of prototyping thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

UNI clicker double image

Microcontroller Overview

MCU Card / MCU

default

Type

8th Generation

Architecture

ARM Cortex-M4

MCU Memory (KB)

512

Silicon Vendor

STMicroelectronics

Pin count

144

RAM (Bytes)

131072

Used MCU Pins

mikroBUS™ mapper

Analog Output
PA3
AN
Select Input 3
PE11
RST
SPI Chip Select
PA4
CS
SPI Clock
PA5
SCK
SPI Data OUT
PA6
MISO
NC
NC
MOSI
NC
NC
3.3V
Ground
GND
GND
Select Input 1
PD12
PWM
Select Input 2
PD3
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

UNI Clicker front image hardware assembly

Start by selecting your development board and Click board™. Begin with the UNI Clicker as your development board.

UNI Clicker front image hardware assembly
GNSS2 Click front image hardware assembly
SiBRAIN for STM32F745VG front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
UNI Clicker Access MB 1 - 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
Necto image step 7 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