Beginner
10 min

Achieve high-precision weight measurement by amplifying and correcting signals from various weight sensors with the ZSC31050 and PIC32MX470F512H

Highly accurate amplification and sensor-specific correction of a bridge and temperature sensor signals

Load Cell 8 Click with 6LoWPAN clicker

Published May 30, 2024

Click board™

Load Cell 8 Click

Dev. board

6LoWPAN clicker

Compiler

NECTO Studio

MCU

PIC32MX470F512H

Deliver weight and force readings for various applications

A

A

Hardware Overview

How does it work?

Load Cell 8 Click is based on the ZSC31050, an advanced differential sensor signal conditioner from Renesas. The ZSC31050 provides precise amplification and sensor-specific corrections for bridge and temperature sensor signals. Featuring a 16-bit RISC MCU, it runs a polynomial correction algorithm to digitally compensate for sensor offset, sensitivity, temperature changes, and non-linearity. It supports a wide range of resistive bridge sensors with signal spans from 1mV/V to 275mV/V, making it ideal for industrial, medical, and consumer applications. This IC is made for sensors that measure pressure, force, and position, among others. The ZSC31050 integrates both analog and digital pathways, where the analog section is configured differentially to enhance noise rejection. This setup enables the amplification of both positive and negative signals within the common mode range. The differential signal undergoes initial amplification by a programmable gain amplifier (PGA), followed by multiplexing (MUX)

that channels signals from various sources to the ADC for digital conversion. Using a standard I2Cinterface, Load Cell 8 Click communicates with the host MCU in order to program a set of calibration coefficients into an on-chip EEPROM. It supports communication frequencies up to 400kHz and uses an EN pin of the mikroBUS™ socket as a IC enabling function. Load Cell 8 Click offers diverse output modes such as analog voltage, current loop (4 to 20 mA), and PWM. The route of the output signal is selectable via the OUT SEL jumper, directing it through either the AN pin on the mikroBUS™ socket or the OUT pin on the unpopulated J2 header for external applications. Other jumpers include VBR SEL for selecting the ADC's external reference voltage, which is recommended for ratiometric bridges when set to VDDA position, and IN3 SEL, which allows for the use of the IN3 pin for external voltage mode operations, external clocking, or as a ratiometric signal measurement point. This Click board™ can

also interface with temperature sensors via the IR TEMP jumper, which selects the input for temperature-related measurements essential for calibration and correction processes. Selection is made between an internal sensor in the form of a D1 diode or an external using an external resistor for temperature measurement that needs to be populated on RT. It also includes configurable IO1 and IO2 LEDs for indicating alarm statuses and unpopulated headers, J1 and J2, with various signals, some as duplicates from already used signals of the ZSC31050 and some for use as external ones. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VCC SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this 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.

Load Cell 8 Click hardware overview image

Features overview

Development board

6LoWPAN Clicker is a compact starter development board that brings the flexibility of add-on Click boards™ to your favorite microcontroller, making it a perfect starter kit for implementing your ideas. It comes with an onboard 32-bit PIC microcontroller, the PIC32MX470F512H from Microchip, a USB connector, LED indicators, buttons, a mikroProg connector, and a header for interfacing with external electronics. Along with this microcontroller, the board also contains a 2.4GHz ISM band transceiver, allowing you to add wireless communication to your target application. Its compact design provides a fluid and immersive working experience, allowing access anywhere

and under any circumstances. Each part of the 6LoWPAN Clicker development kit contains the components necessary for the most efficient operation of the same board. In addition to the possibility of choosing the 6LoWPAN Clicker programming method, using USB HID mikroBootloader, or through an external mikroProg connector for PIC, dsPIC, or PIC32 programmer, the Clicker board also includes a clean and regulated power supply module for the development kit. The USB Micro-B connection can provide up to 500mA of current for the Clicker board, which is more than enough to operate all onboard and additional modules, or it can power

over two standard AA batteries. All communication methods that mikroBUS™ itself supports are on this board, including the well-established mikroBUS™ socket, reset button, and several buttons and LED indicators. 6LoWPAN 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.

6LoWPAN clicker double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC32

MCU Memory (KB)

512

Silicon Vendor

Microchip

Pin count

64

RAM (Bytes)

131072

Used MCU Pins

mikroBUS™ mapper

Analog Output
RG9
AN
Device Enable
RD6
RST
ID COMM
RE5
CS
NC
NC
SCK
NC
NC
MISO
NC
NC
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
NC
NC
INT
NC
NC
TX
NC
NC
RX
I2C Clock
RD10
SCL
I2C Data
RD9
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

Load Cell 8 Click Schematic schematic

Step by step

Project assembly

PIC32MZ clicker front image hardware assembly

Start by selecting your development board and Click board™. Begin with the 6LoWPAN clicker as your development board.

PIC32MZ clicker front image hardware assembly
GNSS2 Click front image hardware assembly
Prog-cut hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
Micro B Connector Clicker 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
Flip&Click PIC32MZ 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

1. Application Output - In Debug mode, the 'Application Output' window enables real-time data monitoring, offering direct insight into execution results. Ensure proper data display by configuring the environment correctly using the provided tutorial.

2. UART Terminal - Use the UART Terminal to monitor data transmission via a USB to UART converter, allowing direct communication between the Click board™ and your development system. Configure the baud rate and other serial settings according to your project's requirements to ensure proper functionality. For step-by-step setup instructions, refer to the provided tutorial.

3. Plot Output - The Plot feature offers a powerful way to visualize real-time sensor data, enabling trend analysis, debugging, and comparison of multiple data points. To set it up correctly, follow the provided tutorial, which includes a step-by-step example of using the Plot feature to display Click board™ readings. To use the Plot feature in your code, use the function: plot(*insert_graph_name*, variable_name);. This is a general format, and it is up to the user to replace 'insert_graph_name' with the actual graph name and 'variable_name' with the parameter to be displayed.

Software Support

Library Description

This library contains API for Load Cell 8 Click driver.

Key functions:

  • loadcell8_read_raw_adc - This function reads raw ADC value by using I2C serial interface.

  • loadcell8_tare_scale - This function calculates the cell_data which is the raw ADC readings of the empty container by using I2C serial interface.

  • loadcell8_calibration_weight - This function calibrates the weight by calculating the cell_data for the input calibration weight by using I2C serial interface.

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 Load Cell 8 Click example
 *
 * # Description
 * This example demonstrates the use of Load Cell 8 click by measuring the weight
 * in grams of the goods from the load cell sensor connected to the click board.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initializes the driver and reads the tare scale of the empty container, and after
 * that, it calibrates the weight scale with a known calibration weight.
 *
 * ## Application Task
 * The demo application measures weight and shows the measurement of scales in grams [ g ].
 * Results are being sent to the Usart Terminal where you can track their changes.
 *
 * @author Stefan Ilic
 *
 */

#include "board.h"
#include "log.h"
#include "loadcell8.h"

static loadcell8_t loadcell8;
static log_t logger;

static loadcell8_data_t cell_data;

void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    loadcell8_cfg_t loadcell8_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.
    loadcell8_cfg_setup( &loadcell8_cfg );
    LOADCELL8_MAP_MIKROBUS( loadcell8_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == loadcell8_init( &loadcell8, &loadcell8_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( LOADCELL8_ERROR == loadcell8_default_cfg ( &loadcell8 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    
    log_printf( &logger, " Remove all goods from the scale in the following 5 sec.\r\n" );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    
    log_printf( &logger, " Calculating tare scale...\r\n" );
    if ( LOADCELL8_OK == loadcell8_tare_scale( &loadcell8, &cell_data ) )
    {
        log_printf( &logger, " Tarring complete!\r\n\n" );
    }
    else 
    {
        log_error( &logger, " Calculating tare scale." );
        for ( ; ; );
    }

    log_printf( &logger, " Place a %ug calibration weight on the scale in the following 5 sec.\r\n", 
                ( uint16_t ) LOADCELL8_WEIGHT_100G );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );

    log_printf( &logger, " Calibrating weight...\r\n" );
    if ( LOADCELL8_OK == loadcell8_calibration_weight( &loadcell8, LOADCELL8_WEIGHT_100G, &cell_data ) ) 
    {
        log_printf( &logger, " Calibration complete!\r\n\n" );
    } 
    else 
    {
        log_error( &logger, " Calibrating weight." );
        for ( ; ; );
    }

    log_printf( &logger, " ___________________\r\n" );
    log_printf( &logger, " Start measurements:\r\n" );
    log_printf( &logger, " ___________________\r\n" );
    Delay_ms ( 500 );
}

void application_task ( void ) 
{
    float weight_g = 0;
    if ( LOADCELL8_OK == loadcell8_get_weight( &loadcell8, &cell_data, &weight_g ) )
    {
        log_printf( &logger, " Weight : %.2f g \r\n", weight_g );
    }
    Delay_ms ( 100 );
}

int main ( void ) 
{
    /* Do not remove this line or clock might not be set correctly. */
    #ifdef PREINIT_SUPPORTED
    preinit();
    #endif
    
    application_init( );
    
    for ( ; ; ) 
    {
        application_task( );
    }

    return 0;
}

// ------------------------------------------------------------------------ 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.