buck20  2.1.0.0
Main Page

Buck 20 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Stefan Filipovic
  • Date : Dec 2022.
  • Type : SPI type

Software Support

We provide a library for the Buck 20 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 from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Library Description

This library contains API for Buck 20 Click driver.

Standard key functions :

Example key functions :

  • buck20_set_wiper_1 This function sets wiper 1 to desired value.
    err_t buck20_set_wiper_1 ( buck20_t *ctx, uint16_t data_in );
  • buck20_enable_device This function enables the buck device by setting the RST pin to high logic state.
  • buck20_disable_device This function disables the buck device by setting the RST pin to low logic state.

Example Description

This example demonstrates the use of Buck 20 click by changing the output voltage.

The demo application is composed of two sections :

Application Init

Initializes the driver and enables the device.

void application_init ( void )
{
log_cfg_t log_cfg;
buck20_cfg_t buck20_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
buck20_cfg_setup( &buck20_cfg );
BUCK20_MAP_MIKROBUS( buck20_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == buck20_init( &buck20, &buck20_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
buck20_enable_device ( &buck20 );
log_info( &logger, " Application Task " );
}

Application Task

Changes the output voltage every 3 seconds and displays on the USB UART the digipot wiper position, as well as an approximate buck R1 and voltage output.

void application_task ( void )
{
static uint16_t digipot_wiper = BUCK20_WIPER_ZERO_SCALE;
float buck_r1_kohm, buck_vout;
if ( BUCK20_OK == buck20_set_wiper_1 ( &buck20, digipot_wiper ) )
{
buck_r1_kohm = BUCK20_RESISTOR_R6_KOHM +
( float ) ( BUCK20_DIGIPOT_MAX_KOHM * digipot_wiper ) / BUCK20_WIPER_FULL_SCALE;
buck_vout = BUCK20_BUCK_VREF + ( buck_r1_kohm * BUCK20_BUCK_VREF ) / BUCK20_BUCK_R2_KOHM;
log_printf( &logger, " Digipot wiper position: %u\r\n", digipot_wiper );
log_printf( &logger, " Approximate R1 (Digipot+R6): %.2f kOhm\r\n", buck_r1_kohm );
log_printf( &logger, " Approximate buck voltage output: %.2f V\r\n\n", buck_vout );
digipot_wiper += 50;
if ( digipot_wiper > BUCK20_WIPER_FULL_SCALE )
{
digipot_wiper = BUCK20_WIPER_ZERO_SCALE;
}
}
Delay_ms ( 3000 );
}

Note

An approximate buck R1 and VOUT values do not have to be 100% accurate for all wiper settings

but they are a good reference point. VOUT ranges from ~1.3V to ~5V, and it is the most accurate around 3.3V since all passive components are set for that output.

The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.

Other Mikroe Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Buck20

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. UART terminal is available in all MikroElektronika compilers.


BUCK20_WIPER_ZERO_SCALE
#define BUCK20_WIPER_ZERO_SCALE
Definition: buck20.h:116
buck20_set_wiper_1
err_t buck20_set_wiper_1(buck20_t *ctx, uint16_t data_in)
Buck 20 Set wiper 1 function.
buck20_init
err_t buck20_init(buck20_t *ctx, buck20_cfg_t *cfg)
Buck 20 initialization function.
buck20_disable_device
void buck20_disable_device(buck20_t *ctx)
Buck 20 disable device function.
buck20_cfg_t
Buck 20 Click configuration object.
Definition: buck20.h:189
application_task
void application_task(void)
Definition: main.c:64
BUCK20_WIPER_FULL_SCALE
#define BUCK20_WIPER_FULL_SCALE
Buck 20 digipot wiper setting.
Definition: buck20.h:114
buck20_cfg_setup
void buck20_cfg_setup(buck20_cfg_t *cfg)
Buck 20 configuration object setup function.
BUCK20_OK
@ BUCK20_OK
Definition: buck20.h:213
buck20_t
Buck 20 Click context object.
Definition: buck20.h:170
application_init
void application_init(void)
Definition: main.c:33
BUCK20_MAP_MIKROBUS
#define BUCK20_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: buck20.h:154
buck20_enable_device
void buck20_enable_device(buck20_t *ctx)
Buck 20 enable device function.
BUCK20_BUCK_R2_KOHM
#define BUCK20_BUCK_R2_KOHM
Definition: buck20.h:124
BUCK20_BUCK_VREF
#define BUCK20_BUCK_VREF
Definition: buck20.h:125
BUCK20_RESISTOR_R6_KOHM
#define BUCK20_RESISTOR_R6_KOHM
Buck 20 voltage calculation values.
Definition: buck20.h:122
BUCK20_DIGIPOT_MAX_KOHM
#define BUCK20_DIGIPOT_MAX_KOHM
Definition: buck20.h:123