Intermediate
30 min

Transform the RMS of input signals into a stable DC voltage with LTC1968 and PIC18F57Q43

From RMS to steady voltage

RMS to DC Click with Curiosity Nano with PIC18F57Q43

Published Feb 13, 2024

Click board™

RMS to DC Click

Dev Board

Curiosity Nano with PIC18F57Q43

Compiler

NECTO Studio

MCU

PIC18F57Q43

Experience a breakthrough in signal processing with our innovative RMS-to-DC voltage converter, delivering real-time insights through accurate voltage conversion, essential for advanced data analysis

A

A

Hardware Overview

How does it work?

RMS to DC Click is based on the LTC1968, a precise RMS-to-DC converter with the wide input signal bandwidth from the Analog Devices. This IC uses the proprietary delta-sigma computational techniques to achieve a highly linear DC voltage output at its output in respect with the RMS of the input signal. The RMS is typically associated with the alternating signals. This Click board™ is capable of measuring the RMS of both bipolar and unipolar periodically alternating signals, over a wide range of frequencies. The RMS or Root Mean Square is used to describe the power of the input signal: the RMS value of current is equal to a DC current value that would produce the same heat dissipation on the resistive load. Therefore, it is often important to know the RMS value of the signal. RMS to DC click allows measuring of the RMS value of a periodically repetitive signal. As mentioned before, the LTC1968 provides a highly accurate and linear conversion of the RMS value at its input, to a constant voltage at its output. The constant voltage directly depends on the RMS value of the input signal, thanks to the innovative

sigma-delta conversion technique of the LTC1968, which is described in details within the LTC1968 datasheet. Due to a high output voltage linearity, no compensation elements are required, except a single filtering capacitor. The output voltage of the LTC1968 is then fed to an analog-to-digital converter (ADC). For the voltage-to-digital conversion purposes, RMS to DC click utilizes the MCP3221, a 12-bit ADC with I2C interface, from Microchip. This ADC uses the voltage at its power supply pin as a conversion reference. This simplifies the Click board™ schematics, allowing the reference voltage to be changed along with the power supply voltage of the ADC. The communication logic voltage level, as well as the ADC power supply voltage, can be changed by switching the SMD jumper labeled as VCC SEL to either 3V3 position or 5V position. Note, however, that this will cause the reference ADC voltage to change accordingly. This should be accounted for when calculating the output value. The input signal can be connected to the two-pole input signal connector. The LTC1968 IC accepts both

bipolar and unipolar signals at its input, thanks to the differential input. The negative differential input is used as the reference input on this Click board™, therefore it is offset at 2.5V in respect to GND, while the positive differential input is decoupled by a 100nF capacitor, allowing only the AC component of the input signal to be processed. This allows signal input within the ±2.5 range to be applied. RMS to DC click also features an #ENABLE pin, used to enable or disable the LTC1968 when used in power sensitive applications. This pin is pulled to a LOW logic level by a resistor, so the IC is enabled by default. The user can disable the IC by pulling the #ENABLE pin to a HIGH logic level. This pin is routed to the CS pin, and it is labeled as EN on this Click board™. Due to an overall circuit simplicity allowed by the LTC1968 IC, the ADC directly outputs the RMS value of the input signal. However, the Click board™ is supported by a mikroSDK compatible library, which contains functions that simplify the development even further, allowing the RMS data to be read in almost a single line of code.

RMS to DC Click hardware overview 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
NC
NC
RST
LTC1968 Enable
PD4
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
PB2
SCL
I2C Data
PB1
SDA
Power Supply
5V
5V
Ground
GND
GND
1

Take a closer look

Click board™ Schematic

RMS to DC 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 via Debug Mode

1. Once the code example is loaded, pressing the "DEBUG" button initiates the build process, programs it on the created setup, and enters Debug mode.

2. After the programming is completed, a header with buttons for various actions within the IDE becomes visible. Clicking the green "PLAY" button starts reading the results achieved with the Click board™. The achieved results are displayed in the Application Output tab.

DEBUG_Application_Output

Software Support

Library Description

This library contains API for RMS to DC Click driver.

Key functions:

  • rms2dc_read_adc - ADC Read function

  • rms2dc_vout_adc - Get Output Voltage function

  • rms2dc_enable - Enable 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 RmstoDc Click example
 * 
 * # Description
 * This application convert the RMS of the input signal into a DC voltage.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes I2C interface and turns ON the device.
 * 
 * ## Application Task  
 * Reads DC output voltage calculated to mV and
   sends results to the serial terminal.
 * 
 * Note : The input voltage frequency should be in the range from 50Hz to 250kHz.
 * Also the input voltage amplitude must be lower than 5V.
 * In this conditions the device can convert the RMS signal, in every form, to DC signal.
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "rmstodc.h"

// ------------------------------------------------------------------ VARIABLES

static rmstodc_t rmstodc;
static log_t logger;

static uint16_t out_volt_dc;

// ------------------------------------------------------ APPLICATION FUNCTIONS


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

    rmstodc_cfg_setup( &cfg );
    RMSTODC_MAP_MIKROBUS( cfg, MIKROBUS_1 );
    rmstodc_init( &rmstodc, &cfg );
    
    rms2dc_enable( &rmstodc, RMS2DC_DEVICE_EN );
}

void application_task ( void )
{
    out_volt_dc = rms2dc_vout_adc( &rmstodc, RMS2DC_VCC_3V3 );
    
    log_printf(&logger,"%u mV\n",out_volt_dc);
    
    Delay_ms( 500 );
}

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.