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
![default](https://cdn.mikroe.com/rent-a-product/request-setup/mcu-cards/easypic-pro-v7-pic18f8520.png)
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
Click board™ Schematic
![VREG 2 Click Schematic schematic](https://dbp-cdn.mikroe.com/catalog/click-boards/resources/1ee790cd-a778-60ee-a41c-0242ac120009/schematic.webp)
Step by step
Project assembly
Track your results in real time
Application Output
This Click board can be interfaced and monitored in two ways:
Application Output
- Use the "Application Output" window in Debug mode for real-time data monitoring. Set it up properly by following this tutorial.
UART Terminal
- Monitor data via the UART Terminal using a USB to UART converter. For detailed instructions, check out this tutorial.
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
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 VREG 2 Click example
*
* # Description
* This example demonstrates the use of the VREG 2 Click board by changing
* the voltage output every 5 seconds.
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initializes the driver and performs the click default configuration.
*
* ## Application Task
* Controls the voltage output by changing the PWM duty cycle every 5 seconds.
* The duty cycle ranges from 10% to 50%. Each step will be logged on
* the USB UART where you can track the program flow.
*
* @author Stefan Filipovic
*
*/
#include "board.h"
#include "log.h"
#include "vreg2.h"
static vreg2_t vreg2;
static log_t logger;
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
vreg2_cfg_t vreg2_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.
vreg2_cfg_setup( &vreg2_cfg );
VREG2_MAP_MIKROBUS( vreg2_cfg, MIKROBUS_1 );
if ( PWM_ERROR == vreg2_init( &vreg2, &vreg2_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( VREG2_ERROR == vreg2_default_cfg ( &vreg2 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}
void application_task ( void )
{
static int8_t duty_pct = 10;
static int8_t duty_step = 10;
if ( VREG2_OK == vreg2_set_duty_cycle ( &vreg2, ( float ) duty_pct / 100 ) )
{
log_printf( &logger, "\r\n Duty: %u%%\r\n", ( uint16_t ) duty_pct );
}
duty_pct += duty_step;
if ( ( duty_pct > 50 ) || ( duty_pct < 10 ) )
{
duty_step = -duty_step;
duty_pct += ( duty_step * 2 );
}
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
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