currentlimit  2.0.0.0
Main Page

Current Limit click

Current Limit Click is a compact add-on board that contains a low-voltage, P-channel MOSFET power switch intended for high-side load switching applications. This board features the MAX890L, a low-resistance power switch with the adjustable, accurate current limit system, and thermal shutdown from Maxim Integrated.

click Product page


Click library

  • Author : Stefan Ilic
  • Date : Jul 2021.
  • Type : SPI type

Software Support

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

Standard key functions :

Example key functions :

Example Description

This example shows capabilities of Current Limit Click board.

The demo application is composed of two sections :

Application Init

Initalizes SPI driver and enables the device.

void application_init ( void ) {
log_cfg_t log_cfg;
currentlimit_cfg_t currentlimit_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
currentlimit_cfg_setup( &currentlimit_cfg );
CURRENTLIMIT_MAP_MIKROBUS( currentlimit_cfg, MIKROBUS_1 );
err_t init_flag = currentlimit_init( &currentlimit, &currentlimit_cfg );
if ( SPI_MASTER_ERROR == init_flag ) {
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
log_printf( &logger, " Click Enabled! \r\n" );
log_printf( &logger, "-----------------------\r\n" );
Delay_ms ( 100 );
log_info( &logger, " Application Task " );
}

Application Task

Reading users input from USART terminal and using it as an index for an array of pre-calculated values that define current limit level.

void application_task ( void ) {
char inx;
if ( log_read( &logger, &inx, 1 ) != CURRENTLIMIT_ERROR ) {
if ( inx >= '1' && inx <= '8' ) {
currentlimit_set_limit( &currentlimit, lim_val[ inx - 49 ] );
log_printf( &logger, " Selected mode %d, \r\n Current limit is %d mA \r\n", ( uint16_t ) inx - 48, lim_data[ inx - 49 ] );
log_printf( &logger, "- - - - - - - - - - - - - - - \r\n" );
} else {
log_printf( &logger, "- - - - - - - - - - - - - - - \r\n" );
log_printf( &logger, " Data not in range! \r\n" );
log_printf( &logger, "- - - - - - - - - - - - - - - \r\n" );
}
}
}

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

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.


currentlimit_dev_enable
void currentlimit_dev_enable(currentlimit_t *ctx, uint8_t state)
Device enable function.
CURRENTLIMIT_MAP_MIKROBUS
#define CURRENTLIMIT_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: currentlimit.h:118
currentlimit_cfg_setup
void currentlimit_cfg_setup(currentlimit_cfg_t *cfg)
Current Limit configuration object setup function.
currentlimit_init
err_t currentlimit_init(currentlimit_t *ctx, currentlimit_cfg_t *cfg)
Current Limit initialization function.
application_task
void application_task(void)
Definition: main.c:85
lim_val
const uint8_t lim_val[8]
Definition: main.c:29
currentlimit_set_limit
void currentlimit_set_limit(currentlimit_t *ctx, uint8_t lim_val)
Set Current With Predefined Values Limit function.
CURRENTLIMIT_ENABLE
#define CURRENTLIMIT_ENABLE
Current Limit description setting.
Definition: currentlimit.h:74
currentlimit_cfg_t
Current Limit Click configuration object.
Definition: currentlimit.h:149
application_init
void application_init(void)
Definition: main.c:48
currentlimit_t
Current Limit Click context object.
Definition: currentlimit.h:133
currentlimit_set_limit_calc
void currentlimit_set_limit_calc(currentlimit_t *ctx, float lim_val)
Set Calculated Current Limit function.
display_settings
void display_settings(void)
Definition: main.c:32
lim_data
uint16_t lim_data[8]
Definition: main.c:30
CURRENTLIMIT_ERROR
@ CURRENTLIMIT_ERROR
Definition: currentlimit.h:173