Intermediate
30 min

Save time with efficient and accurate weight measurement using MAX11270 and PIC18F57Q43

Unlocking potential in every gram

Load Cell 6 Click with Curiosity Nano with PIC18F57Q43

Published Feb 13, 2024

Click board™

Load Cell 6 Click

Dev. board

Curiosity Nano with PIC18F57Q43

Compiler

NECTO Studio

MCU

PIC18F57Q43

Improve inventory management through consistent weight tracking

A

A

Hardware Overview

How does it work?

Load Cell 6 Click is based on the MAX11270, a pin-programmable, ultra-low power 24-bit ΣΔ ADC that resolves a very high dynamic range from Analog Devices. The MAX11270 achieves excellent 130dB SNR while dissipating an ultra-low 10mW. It allows users to select a programmable gain amplifier with gain settings between 1x to 128x, unity-gain buffer, or connect signals directly to the delta-sigma sampling network. This ADC can resolve micro-volt level changes to the analog input, making it a good fit for seismic, instrumentation, and ATE applications. The MAX11270 measures differential analog inputs (S+, S-) in buffered, direct connect, or PGA. The default configuration is directly connected, with PGA and input buffers powered down. These optional buffers isolate the signal inputs from the switched capacitor sampling network, which allows the MAX11270 to be used with high-impedance sources without compromising the available

dynamic range. The ADC input range is programmable for unipolar (0 to VREF) ranges set by the reference voltage value obtained by the MAX6126, a 3V high-precision voltage reference, also routed to the E+ terminal. Load Cell 6 Click communicates with MCU through a standard SPI interface that enables high clock speeds up to 5MHz. The MAX11270 is highly configurable via the internal registers, accessed via the SPI interface. It operates in two modes: Conversion mode or Register-Access mode, selected by the command byte. Those registers include PGA gain selection, offset and gain calibration, and a scalable sample rate to optimize performance. It also offers software-selectable output data rates, up to 12.8 kps with no data latency and 64 kps continuous, to optimize data rate and noise. In addition, the Reset pin, routed to the RST pin of the mikroBUS™ socket, is used for a complete reset of all digital functions, resulting in a Power-On reset default

state, while the Data-Ready signal, labeled as RDY and routed to the INT pin of the mikroBUS™ socket, notifies the host MCU when the data is ready. The Sync Reset signal is also used, labeled as SYN, and routed to the PWM pin of the mikroBUS™ socket, which resets both the digital filter and modulator. It also has a GPIO header with two general-purpose pins from the MAX11270, which are user-configurable. Even though this board uses both mikroBUS™ power rails, this Click board™ can only be operated with a 3.3V logic voltage level (5V is used only as a voltage reference power supply). The board must perform appropriate logic voltage level conversion before using MCUs with different logic levels. 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 6 Click top side image
Load Cell 6 Click bottom side image

Features overview

Development board

PIC18F57Q43 Curiosity Nano evaluation kit is a cutting-edge hardware platform designed to evaluate microcontrollers within the PIC18-Q43 family. Central to its design is the inclusion of the powerful PIC18F57Q43 microcontroller (MCU), offering advanced functionalities and robust performance. Key features of this evaluation kit include a yellow user LED and a responsive

mechanical user switch, providing seamless interaction and testing. The provision for a 32.768kHz crystal footprint ensures precision timing capabilities. With an onboard debugger boasting a green power and status LED, programming and debugging become intuitive and efficient. Further enhancing its utility is the Virtual serial port (CDC) and a debug GPIO channel (DGI

GPIO), offering extensive connectivity options. Powered via USB, this kit boasts an adjustable target voltage feature facilitated by the MIC5353 LDO regulator, ensuring stable operation with an output voltage ranging from 1.8V to 5.1V, with a maximum output current of 500mA, subject to ambient temperature and voltage constraints.

PIC18F57Q43 Curiosity Nano double side image

Microcontroller Overview

MCU Card / MCU

default

Architecture

PIC

MCU Memory (KB)

128

Silicon Vendor

Microchip

Pin count

48

RAM (Bytes)

8196

You complete me!

Accessories

Curiosity Nano Base for Click boards is a versatile hardware extension platform created to streamline the integration between Curiosity Nano kits and extension boards, tailored explicitly for the mikroBUS™-standardized Click boards and Xplained Pro extension boards. This innovative base board (shield) offers seamless connectivity and expansion possibilities, simplifying experimentation and development. Key features include USB power compatibility from the Curiosity Nano kit, alongside an alternative external power input option for enhanced flexibility. The onboard Li-Ion/LiPo charger and management circuit ensure smooth operation for battery-powered applications, simplifying usage and management. Moreover, the base incorporates a fixed 3.3V PSU dedicated to target and mikroBUS™ power rails, alongside a fixed 5.0V boost converter catering to 5V power rails of mikroBUS™ sockets, providing stable power delivery for various connected devices.

Curiosity Nano Base for Click boards accessories 1 image

Used MCU Pins

mikroBUS™ mapper

NC
NC
AN
Reset
PA7
RST
SPI Chip Select
PD4
CS
SPI Clock
PC6
SCK
SPI Data OUT
PC5
MISO
SPI Data IN
PC4
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
Filter/Modulator Reset
PB0
PWM
Data-Ready
PA6
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

Click board™ Schematic

Load Cell 6 Click Schematic schematic

Step by step

Project assembly

Curiosity Nano Base for Click boards front image hardware assembly

Start by selecting your development board and Click board™. Begin with the Curiosity Nano with PIC18F57Q43 as your development board.

Curiosity Nano Base for Click boards front image hardware assembly
Charger 27 Click front image hardware assembly
PIC18F47Q10 Curiosity Nano front image hardware assembly
Prog-cut hardware assembly
Charger 27 Click complete accessories setup image hardware assembly
Curiosity Nano with PICXXX 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
PIC18F57Q43 Curiosity 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 6 Click driver.

Key functions:

  • loadcell6_get_weight - Load Cell 6 get weight function

  • loadcell6_calibration - Load Cell 6 calibration function

  • loadcell6_tare - Load Cell 6 tare the scales 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 LoadCell6 Click example
 *
 * # Description
 * This library contains API for the Load Cell 6 Click driver.
 * The library initializes and defines the SPI bus drivers to read status and ADC data. 
 * The library also includes a function for tare, calibration and weight measurement.
 *
 * The demo application is composed of two sections :
 *
 * ## Application Init
 * Initialization of SPI module and log UART.
 * After driver initialization, app performs the power on
 * sets tare the scale, calibrate scale and start measurements.
 *
 * ## Application Task
 * This is an example that demonstrates the use of the Load Cell 6 click board™.
 * The Load Cell 6 click board™ can be used to measure 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 Nenad Filipovic
 *
 */

#include "board.h"
#include "log.h"
#include "loadcell6.h"

static loadcell6_t loadcell6;
static log_t logger;
static loadcell6_data_t cell_data;

void application_init ( void )
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    loadcell6_cfg_t loadcell6_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.
    loadcell6_cfg_setup( &loadcell6_cfg );
    LOADCELL6_MAP_MIKROBUS( loadcell6_cfg, MIKROBUS_1 );
    if ( SPI_MASTER_ERROR == loadcell6_init( &loadcell6, &loadcell6_cfg ) )
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }
    
    if ( LOADCELL6_ERROR == loadcell6_default_cfg( &loadcell6 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }
    Delay_ms( 1000 );
    
    log_printf( &logger, "-------------------------\r\n");
    log_printf( &logger, "     Tare the scale :    \r\n");
    log_printf( &logger, "- - - - - - - - - - - - -\r\n");
    log_printf( &logger, " >> Remove all object << \r\n");
    log_printf( &logger, "- - - - - - - - - - - - -\r\n");
    log_printf( &logger, " In the following 10 sec \r\n");
    log_printf( &logger, " please remove all object\r\n");
    log_printf( &logger, "     from the scale.     \r\n");
    Delay_ms( 10000 );

    log_printf( &logger, "-------------------------\r\n");
    log_printf( &logger, "    Start tare scales    \r\n");
    loadcell6_tare( &loadcell6, &cell_data );
    Delay_ms( 500 );

    log_printf( &logger, "-------------------------\r\n");
    log_printf( &logger, "   Tarring is complete   \r\n");
    log_printf( &logger, "-------------------------\r\n");
    log_printf( &logger, "    Calibrate Scale :    \r\n");
    log_printf( &logger, "- - - - - - - - - - - - -\r\n");
    log_printf( &logger, "   >>> Load etalon <<<   \r\n");
    log_printf( &logger, "- - - - - - - - - - - - -\r\n");
    log_printf( &logger, " In the following 10 sec \r\n");
    log_printf( &logger, "place 200g weight etalon\r\n");
    log_printf( &logger, "    on the scale for     \r\n");
    log_printf( &logger, "   calibration purpose.  \r\n");
    Delay_ms( 10000 );

    log_printf( &logger, "-------------------------\r\n");
    log_printf( &logger, "    Start calibration    \r\n");

    if ( LOADCELL6_OK == loadcell6_calibration( &loadcell6, LOADCELL6_WEIGHT_200G, &cell_data )  ) 
    {
        log_printf( &logger, "-------------------------\r\n");
        log_printf( &logger, "    Calibration  Done    \r\n");
        log_printf( &logger, "- - - - - - - - - - - - -\r\n");
        log_printf( &logger, "  >>> Remove etalon <<<  \r\n");
        log_printf( &logger, "- - - - - - - - - - - - -\r\n");
        log_printf( &logger, " In the following 5 sec  \r\n");
        log_printf( &logger, "    remove 200g weight   \r\n");
        log_printf( &logger, "   etalon on the scale.  \r\n");
        Delay_ms( 5000 );
    }
    else 
    {
        log_printf( &logger, "-------------------------\r\n");
        log_printf( &logger, "   Calibration  Error   \r\n");
        for ( ; ; );
    }

    log_printf( &logger, "-------------------------\r\n");
    log_printf( &logger, "   Start measurements :  \r\n");
    log_printf( &logger, "-------------------------\r\n");
}

void application_task ( void )
{
    static float weight_g;
    
    if ( LOADCELL6_OK == loadcell6_get_weight( &loadcell6, &cell_data, &weight_g ) )
    {
        log_printf(&logger, "   Weight : %.2f g\r\n", weight_g ); 
    }
}

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.