Efficient, reliable, and ready to take your devices to the next level!
A
A
Hardware Overview
How does it work?
VREG 2 Click is based on the outstanding performance of the LM317, a well-established adjustable voltage regulator from Texas Instruments. The circuit on this Click board™ consists of two voltage regulators, one of which is a linear voltage regulator. At the same time the second is a switching step-down converter, also known as the buck converter. Such topology combines the benefits of both worlds: linear regulator offers low voltage ripple and noise, while the switching regulator provides optimal working conditions, avoiding large voltage differences between the input and output voltage of the linear regulator. Unlike the buck converter, a significant difference between the linear regulator's input and output voltage leads to significant dissipation losses. The Click board™ also uses the LM2596, a 3A step-down voltage regulator working at 150 kHz, from Texas Instruments. It belongs to the Simple Switcher™ line of products and supports both continuous and discontinuous modes. This buck DC-DC
converter can handle from 4.5V up to 40V, but the circuit works reliably with voltages between 9V and 35V. This IC has a reasonably simple layout with just a few external pins. The feedback loop regulates the output voltage of the DC-DC converter. Normally, there is a voltage divider with its center pin routed to the FB pin of the LM2596, but on this Click board™, there is a PNP BJT with the 2.7V Zener diode on its emitter, which is used to provide about 3V more voltage on its output, than the desired target voltage. This provides an ideal voltage headroom for the linear regulator, allowing for greater efficiency and less power dissipation. The input voltage is provided from the LM2596, and as already mentioned, this voltage is about 3V greater than the target regulation voltage, allowing optimal headroom for LM317 IC. The ADJ pin is used to set the output voltage on this IC. The output of the first op-amp of the LM358 IC, a dual operational amplifier from Texas Instruments, drives it. The PWM signal from the MCU controls this op-amp's non-inverting
input; therefore, the mikroBUS™ PWM pin is routed to this non-inverting input. By applying an additional RC filter, the PWM signal is converted to a constant linear voltage ranging up to 3.3V, as it is limited by another Zener diode on this input. The inverting pin of this op-amp is connected to an output voltage divider, with its center tap at 3.3V for the maximum output voltage of 15V. This allows the output voltage to be measured by the host MCU. Therefore, this pin is routed to the mikroBUS™ AN pin. The short circuit protection section is designed with the second op-amp of the LM358 IC, working as a comparator. When the current starts flowing through the 0.5Ω resistor, in the event of a short circuit on the output, it will cause the op-amp output voltage to rise. The red LED indicator labeled OCP will be lit, indicating the short circuit condition. This will also cause the rising of the FB voltage of the buck regulator, effectively blocking its operation and cutting the power to the output.
Features overview
Development board
EasyPIC PRO v7 is the seventh generation of PIC development boards specially designed to develop embedded applications rapidly. It supports a wide range of 8-bit PIC microcontrollers from Microchip and a broad set of unique functions, such as a powerful onboard mikroProg programmer and In-Circuit debugger over USB-B. 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. With two different connectors for each port, EasyPIC PRO v7 allows you to connect accessory boards, sensors, and custom electronics more efficiently than ever. Each part of the EasyPIC PRO v7 development board contains
the components necessary for the most efficient operation of the same board. An integrated mikroProg, a fast USB 2.0 programmer with mikroICD hardware In-Circuit Debugger, offers many valuable programming/debugging options and seamless integration with the Mikroe software environment. Besides it also includes a clean and regulated power supply block for the development board. It can use a wide range of external power sources, including an external 12V power supply, 7-23V AC or 9-32V DC via DC connector/screw terminals, and a power source via the USB Type-B (USB-B) connector. Communication options such as USB-UART, RS-232, and Ethernet are also included, including the well-established
mikroBUS™ standard, two display options (graphical and character-based LCD), and a standard TQFP socket for the seventh-generation MCU cards. This socket covers a wide range of 8-bit PIC MCUs, from PIC18LF, PIC16LF, PIC16F, and PIC18F families. EasyPIC PRO v7 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.
Microcontroller Overview
MCU Card / MCU
Type
7th Generation
Architecture
PIC
MCU Memory (KB)
32
Silicon Vendor
Microchip
Pin count
80
RAM (Bytes)
2048
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Schematic
Step by step
Project 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.
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.
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".
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.
Software Support
Library Description
This library contains API for VREG 2 Click driver.
Key functions:
vreg2_set_duty_cycle
- This function sets the PWM duty cycle in percentagesvreg2_pwm_start
- This function starts the PWM module outputvreg2_pwm_stop
- This function stops the PWM module output
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 Vreg2 Click example
*
* # Description
* This application enables voltage regulation.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the GPIO driver and configures the PWM
* peripheral for controlling VREG2 voltage output.
*
* ## Application Task
* Based on the data received from the uart the voltage output will be increased or decreased.
*
*
* \author MikroE Team
*
*/
// ------------------------------------------------------------------- INCLUDES
#include "board.h"
#include "log.h"
#include "vreg2.h"
// ------------------------------------------------------------------ VARIABLES
static vreg2_t vreg2;
static log_t logger;
static float duty_cycle = 0.5;
static uint8_t ctrl_flag = 0;
static uint8_t ctrl_pre_flag = 0;
// ------------------------------------------------------ APPLICATION FUNCTIONS
void application_init ( void )
{
log_cfg_t log_cfg;
vreg2_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.
vreg2_cfg_setup( &cfg );
vreg2_init( &vreg2, &cfg );
vreg2_set_duty_cycle( &vreg2, duty_cycle );
vreg2_pwm_start( &vreg2 );
}
void application_task ( void )
{
// Task implementation.
switch ( ctrl_flag )
{
case 0:
{
duty_cycle = 0.2;
log_printf( &logger, "Volatage set to : %d %%\r\n", duty_cycle );
ctrl_pre_flag = ctrl_flag;
ctrl_flag = 1;
break;
}
case 1:
{
duty_cycle = 0.5;
log_printf( &logger, "Volatage set to : %d %%\r\n", duty_cycle );
if ( ctrl_pre_flag == 0 )
{
ctrl_pre_flag = ctrl_flag;
ctrl_flag = 2;
}
else if ( ctrl_pre_flag == 2 )
{
ctrl_pre_flag = ctrl_flag;
ctrl_flag = 0;
}
break;
}
case 2:
{
duty_cycle = 0.7;
log_printf( &logger, "Volatage set to : %d %%\r\n", duty_cycle );
if ( ctrl_pre_flag == 1 )
{
ctrl_pre_flag = ctrl_flag;
ctrl_flag = 3;
}
else if ( ctrl_pre_flag == 3 )
{
ctrl_pre_flag = ctrl_flag;
ctrl_flag = 1;
}
break;
}
case 3:
{
duty_cycle = 0.95;
log_printf( &logger, "Volatage set to : %d %%\r\n", duty_cycle );
ctrl_pre_flag = ctrl_flag;
ctrl_flag = 2;
break;
}
default:
{
log_printf( &logger, "Something broke\r\n");
}
}
vreg2_set_duty_cycle( &vreg2, duty_cycle );
Delay_ms( 1500 );
Delay_100ms();
}
void main ( void )
{
application_init( );
for ( ; ; )
{
application_task( );
}
}
// ------------------------------------------------------------------------ END