vreg2  2.0.0.0
Main Page

VREG 2 click

VREG 2 click is a voltage regulator click, with outstanding performances.

click Product page


Click library

Software Support

We provide a library for the Vreg2 Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.

Package can be downloaded/installed directly form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

This library contains API for Vreg2 Click driver.

Standard key functions :

Example key functions :

Examples 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.

void application_init ( void )
{
log_cfg_t log_cfg;
// Logger initialization.
log_cfg.level = LOG_LEVEL_DEBUG;
log_cfg.rx_pin = (0x27) ; log_cfg.tx_pin = (0x26) ; log_cfg.baud = 9600; log_cfg.level = LOG_LEVEL_DEBUG; ;
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
vreg2_cfg_setup( &cfg );
cfg.pwm = (0x3C) ; cfg.an = (0x03) ;
vreg2_init( &vreg2, &cfg );
vreg2_set_duty_cycle( &vreg2, duty_cycle );
vreg2_pwm_start( &vreg2 );
}

Application Task

Based on the data received from the uart the voltage output will be increased or decreased.

void application_task ( void )
{
// Task implementation.
switch ( ctrl_flag )
{
case 0:
{
duty_cycle = (uint32_t)vreg2.pwm_period * 20 / 100;
log_printf( &logger, "Volatage set to : %d %%\r\n", duty_cycle );
ctrl_pre_flag = ctrl_flag;
ctrl_flag = 1;
break;
}
case 1:
{
duty_cycle = (uint32_t)vreg2.pwm_period * 50 / 100;
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 = (uint32_t)vreg2.pwm_period * 70 / 100;
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 = (uint32_t)vreg2.pwm_period * 95 / 100;
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();
}

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

Additional notes and informations

Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.