vcpmonitor6  2.1.0.0
Main Page

VCP Monitor 6 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Nenad Filipovic
  • Date : Feb 2024.
  • Type : I2C type

Software Support

We provide a library for the VCP Monitor 6 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 VCP Monitor 6 Click driver.

Standard key functions :

Example key functions :

  • vcpmonitor6_get_bus_voltage This function reads the BUS voltage output measurement in volts [V] by using the I2C serial interface.
    err_t vcpmonitor6_get_bus_voltage ( vcpmonitor6_t *ctx, float *voltage );
  • vcpmonitor6_get_current This function reads the current measurement result in milliamperes [mA] by using the I2C serial interface.
    err_t vcpmonitor6_get_current ( vcpmonitor6_t *ctx, float *current );
  • vcpmonitor6_get_power This function reads the power measurement result in watts [W] by using the I2C serial interface.
    err_t vcpmonitor6_get_power ( vcpmonitor6_t *ctx, float *power );

Example Description

This library contains API for the VCP Monitor 6 Click driver for measurements of the voltage, current, power, energy, charge, and die temperature.

The demo application is composed of two sections :

Application Init

The initialization of the I2C module and log UART. After driver initialization, the app sets the default configuration.

void application_init ( void )
{
log_cfg_t log_cfg;
vcpmonitor6_cfg_t vcpmonitor6_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
vcpmonitor6_cfg_setup( &vcpmonitor6_cfg );
VCPMONITOR6_MAP_MIKROBUS( vcpmonitor6_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == vcpmonitor6_init( &vcpmonitor6, &vcpmonitor6_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( VCPMONITOR6_ERROR == vcpmonitor6_default_cfg ( &vcpmonitor6 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
}

Application Task

The demo application reads and displays the results of the input bus voltage, current, power, energy, charge accumulation measurements, and die temperature. Results are being sent to the UART Terminal, where you can track their changes.

void application_task ( void )
{
float app_buf = 0;
if ( VCPMONITOR6_OK == vcpmonitor6_get_bus_voltage( &vcpmonitor6, &app_buf ) )
{
log_printf( &logger, " Voltage: %.2f [V]\r\n", app_buf );
Delay_ms( 50 );
}
if ( VCPMONITOR6_OK == vcpmonitor6_get_current( &vcpmonitor6, &app_buf ) )
{
log_printf( &logger, " Current: %.2f [mA]\r\n", app_buf );
Delay_ms( 50 );
}
if ( VCPMONITOR6_OK == vcpmonitor6_get_power( &vcpmonitor6, &app_buf ) )
{
log_printf( &logger, " Power: %.2f [W]\r\n", app_buf );
Delay_ms( 50 );
}
if ( VCPMONITOR6_OK == vcpmonitor6_get_energy( &vcpmonitor6, &app_buf ) )
{
log_printf( &logger, " Energy: %.2f [kJ]\r\n", app_buf );
Delay_ms( 50 );
}
if ( VCPMONITOR6_OK == vcpmonitor6_get_charge( &vcpmonitor6, &app_buf ) )
{
log_printf( &logger, " Charge: %.2f [C]\r\n", app_buf );
Delay_ms( 50 );
}
if ( VCPMONITOR6_OK == vcpmonitor6_get_temperature( &vcpmonitor6, &app_buf ) )
{
log_printf( &logger, " Temperature: %.2f [degC]\r\n", app_buf );
Delay_ms( 50 );
}
log_printf( &logger, " ----------------------------\r\n" );
Delay_ms( 2000 );
}

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

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.


vcpmonitor6_cfg_setup
void vcpmonitor6_cfg_setup(vcpmonitor6_cfg_t *cfg)
VCP Monitor 6 configuration object setup function.
VCPMONITOR6_MAP_MIKROBUS
#define VCPMONITOR6_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: vcpmonitor6.h:201
vcpmonitor6_get_energy
err_t vcpmonitor6_get_energy(vcpmonitor6_t *ctx, float *energy)
VCP Monitor 6 get the energy function.
application_task
void application_task(void)
Definition: main.c:67
vcpmonitor6_get_bus_voltage
err_t vcpmonitor6_get_bus_voltage(vcpmonitor6_t *ctx, float *voltage)
VCP Monitor 6 get the voltage function.
vcpmonitor6_get_power
err_t vcpmonitor6_get_power(vcpmonitor6_t *ctx, float *power)
VCP Monitor 6 get the power function.
vcpmonitor6_default_cfg
err_t vcpmonitor6_default_cfg(vcpmonitor6_t *ctx)
VCP Monitor 6 default configuration function.
VCPMONITOR6_ERROR
@ VCPMONITOR6_ERROR
Definition: vcpmonitor6.h:249
VCPMONITOR6_OK
@ VCPMONITOR6_OK
Definition: vcpmonitor6.h:248
vcpmonitor6_get_temperature
err_t vcpmonitor6_get_temperature(vcpmonitor6_t *ctx, float *temperature)
VCP Monitor 6 get the temperature function.
vcpmonitor6_init
err_t vcpmonitor6_init(vcpmonitor6_t *ctx, vcpmonitor6_cfg_t *cfg)
VCP Monitor 6 initialization function.
application_init
void application_init(void)
Definition: main.c:31
vcpmonitor6_cfg_t
VCP Monitor 6 Click configuration object.
Definition: vcpmonitor6.h:231
vcpmonitor6_get_current
err_t vcpmonitor6_get_current(vcpmonitor6_t *ctx, float *current)
VCP Monitor 6 get the current function.
vcpmonitor6_get_charge
err_t vcpmonitor6_get_charge(vcpmonitor6_t *ctx, float *charge)
VCP Monitor 6 get the charge function.
vcpmonitor6_t
VCP Monitor 6 Click context object.
Definition: vcpmonitor6.h:214