Intermediate
30 min
0

Efficiently regulate negative voltages with MCP16331 and PIC24EP512GU814

Voltage flexibility unleashed

MCP16331 INV Click with UNI-DS v8

Published Aug 03, 2023

Click board™

MCP16331 INV Click

Development board

UNI-DS v8

Compiler

NECTO Studio

MCU

PIC24EP512GU814

Experience efficient conversion of input voltages to desired negative levels while benefiting from the dynamic buck-boost capability that ensures stability and accuracy, enabling reliable operation across various applications

A

A

Hardware Overview

How does it work?

MCP16331 INV Click is based on the MCP16331, a step-down (buck) switching regulator from Microchip. However, with the help of a few external components, MCP16331 INV Click can regulate voltage levels lower and higher than the input voltage, working as an inverted boost-buck voltage regulator. The MCP16331 INV click is designed to output a negative voltage with respect to the GND. A negative voltage is often used in the analog electronics domain to power up devices requiring both positive and negative voltages. A good example would be an operational amplifier (opamp) which amplifies an AC signal. The signal goes in both positive and negative directions with respect to the GND. Processing this kind of signal using a single voltage source is difficult and requires workarounds such as capacitors, charge pumps, and virtual GNDs. Using a symmetrical power supply reduces the required components and simplifies the design. Several additional components, such as the ADM8828 voltage inverter IC and the LM318, a dual operational amplifier, must be added to deliver a negative voltage. The ADM8828 voltage inverter IC provides a negative component of the symmetrical power supply used for the LM318 dual opamp. One integrated opamp from the LM318 IC is used to invert the output from the DAC.

The other opamp from the LM318 IC is used to invert the output from the voltage divider, located on the output rail of the MCP16331, so that it can be used by the MCU, which uses a single voltage power source. To set the output voltage of the MCP16331 INV click, the MCP4921 - a low-power 12-Bit dual voltage output DAC is used in the feedback loop. As already mentioned, it is necessary to invert this signal as the MCP4921 is supplied from a single-voltage power supply, and it cannot bring the signal lower than the GND. Since MCP16331 works in the negative voltage domain, the feedback voltage applied to the FB pin of this IC also needs to be negative with respect to the GND. One of the LM318's integrated opamps, configured as a unity gain inverter, is used to invert the DAC output voltage. Since the DAC drives the FB pin of the MCP16331 IC, it is enough to set the DAC to a specific value to control the output voltage of the click board™. Communication with the MCP4921 DAC is done via the SPI interface. SPI bus pins of the MCP4921 are routed to the mikroBUS™ for an easy and secure connection with the host MCU. The AN pin of the mikroBUS™ is routed to a middle point of a voltage divider at the output. This voltage divider is used to scale down the output voltage so the ADC of the host MCU can successfully convert it.

The voltage on the divider also has to be inverted since it is coming out from the negative voltage domain. This is achieved by the second operational amplifier of the LM318 IC, which also works as a unity gain inverter. This value can be used to monitor and correct the output voltage if needed. The EN pin of the MCP16331 switching regulator is routed to the mikroBUS™ RST pin. By pulling this pin to a HIGH logic level, the internal sections of the regulator are enabled. The EN pin is internally pulled to a HIGH logic level, so the device will be enabled, even if this pin is left floating. Therefore, a correct startup sequence must be used to avoid undesirable effects (in the NOTE below). Although it is designed to work as the negative power supply, the MCP16331INV click can also be used to drive a regular load, connecting its positive input terminal to the GND of the click board™ and using the negative output of the MCP16331INV click as the GND. MCP16331 INV Click with two screw terminals to connect the input and the output voltage rails. This click board™ uses only +5V rail from the mikroBUS™. Provided libraries demonstrate the functionality of the MCP16331 INV click and offer an easy and simple way of setting it up.

MCP16331 INV Click hardware overview image

Features overview

Development board

UNI-DS v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports a wide range of microcontrollers, such as different STM32, Kinetis, TIVA, CEC, MSP, PIC, dsPIC, PIC32, and AVR MCUs regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer over WiFi. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, UNI-DS v8 provides a fluid and immersive working experience, allowing access anywhere and under any

circumstances at any time. Each part of the UNI-DS v8 development board contains the components necessary for the most efficient operation of the same board. An advanced integrated CODEGRIP programmer/debugger module offers many valuable programming/debugging options, including support for JTAG, SWD, and SWO Trace (Single Wire Output)), and seamless integration with the Mikroe software environment. Besides, it also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector. Communication options such as USB-UART, USB

HOST/DEVICE, CAN (on the MCU card, if supported), and Ethernet is also included. In addition, it also has the well-established mikroBUS™ standard, a standardized socket for the MCU card (SiBRAIN standard), and two display options for the TFT board line of products and character-based LCD. UNI-DS v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.

UNI-DS v8 horizontal image

Microcontroller Overview

MCU Card / MCU

default

Type

8th Generation

Architecture

dsPIC

MCU Memory (KB)

512

Silicon Vendor

Microchip

Pin count

144

RAM (Bytes)

53248

Used MCU Pins

mikroBUS™ mapper

Voltage Sense
RA6
AN
Output Enable
RJ5
RST
SPI Chip Select
RJ4
CS
SPI Clock
RG6
SCK
NC
NC
MISO
SPI Data IN
RG8
MOSI
Power Supply
3.3V
3.3V
Ground
GND
GND
NC
NC
PWM
NC
NC
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

MCP16331 INV Click Schematic schematic

Step by step

Project assembly

Fusion for PIC v8 front image hardware assembly

Start by selecting your development board and Click board™. Begin with the UNI-DS v8 as your development board.

Fusion for PIC v8 front image hardware assembly
GNSS2 Click front image hardware assembly
SiBRAIN for PIC32MZ1024EFK144 front image hardware assembly
GNSS2 Click complete accessories setup image hardware assembly
v8 SiBRAIN 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 Compiler Selection Step Image hardware assembly
NECTO Output Selection Step Image hardware assembly
Necto image step 6 hardware assembly
Necto image step 7 hardware assembly
Necto image step 8 hardware assembly
Necto image step 9 hardware assembly
Necto image step 10 hardware assembly
Necto PreFlash Image hardware assembly

Track your results in real time

Application Output

After pressing the "FLASH" button on the left-side panel, it is necessary to open the UART terminal to display the achieved results. By clicking on the Tools icon in the right-hand panel, multiple different functions are displayed, among which is the UART Terminal. Click on the offered "UART Terminal" icon.

UART Application Output Step 1

Once the UART terminal is opened, the window takes on a new form. At the top of the tab are two buttons, one for adjusting the parameters of the UART terminal and the other for connecting the UART terminal. The tab's lower part is reserved for displaying the achieved results. Before connecting, the terminal has a Disconnected status, indicating that the terminal is not yet active. Before connecting, it is necessary to check the set parameters of the UART terminal. Click on the "OPTIONS" button.

UART Application Output Step 2

In the newly opened UART Terminal Options field, we check if the terminal settings are correct, such as the set port and the Baud rate of UART communication. If the data is not displayed properly, it is possible that the Baud rate value is not set correctly and needs to be adjusted to 115200. If all the parameters are set correctly, click on "CONFIGURE".

UART Application Output Step 3

The next step is to click on the "CONNECT" button, after which the terminal status changes from Disconnected to Connected in green, and the data is displayed in the Received data field.

UART Application Output Step 4

Software Support

Library Description

This library contains API for MCP16331 INV Click driver.

Key functions:

  • mcp16331inv_enable_vin - This function enables or disables internal VIN pull up

  • mcp16331inv_set_dac_vout - This function determines DAC output voltage value

  • mcp16331inv_generic_transfer - Generic SPI transfer, for sending and receiving packages

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 Mcp16331Inv Click example
 * 
 * # Description
 * This application enables usage of this click as a buck-boost voltage regulator.
 *
 * The demo application is composed of two sections :
 * 
 * ## Application Init 
 * Initializes click driver and enables VIN Pull Up.
 * 
 * ## Application Task  
 * Sets DAC output voltage on 3500mV, when gain is set up on 1x VREF,
 * on 4s delay time, and then sets DAC output voltage on 5000mV, when gain is now set up on 2x VREF,
 * on also 4s delay time. VIN Pull Up voltage must be greater than 4V.
 * 
 * 
 * \author MikroE Team
 *
 */
// ------------------------------------------------------------------- INCLUDES

#include "board.h"
#include "log.h"
#include "mcp16331inv.h"

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

static mcp16331inv_t mcp16331inv;
static log_t logger;

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

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

    mcp16331inv_cfg_setup( &cfg );
    MCP16331INV_MAP_MIKROBUS( cfg, MIKROBUS_1 );

    Delay_ms( 100 );

    mcp16331inv_init( &mcp16331inv, &cfg );

    Delay_ms( 100 );

    mcp16331inv_enable_vin( &mcp16331inv, MCP16331INV_ENABLE_VIN_PULL_UP );
}

void application_task ( void )
{
    //  Task implementation.

    mcp16331inv_set_dac_vout( &mcp16331inv, MCP16331INV_3500_MV_1X_GAIN, MCP16331INV_GAIN_1X_VREF, MCP16331INV_ACTIVE_MODE );
    Delay_ms( 4000 );
    mcp16331inv_set_dac_vout( &mcp16331inv, MCP16331INV_5000_MV_2X_GAIN, MCP16331INV_GAIN_2X_VREF, MCP16331INV_ACTIVE_MODE );
    Delay_ms( 4000 );
}

void main ( void )
{
    application_init( );

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


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

Additional Support

Resources