We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]
Rating:
Author: MIKROE
Last Updated: 2018-02-06
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: Measurements
Downloaded: 5179 times
Not followed.
License: MIT license
PAC1921 click is a versatile power monitoring and measuring device intended for the high speed, low latency measurements. This device can measure current, voltage or the power of the connected load.
Do you want to subscribe in order to receive notifications regarding "PAC1921 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "PAC1921 click" changes.
Do you want to report abuse regarding "PAC1921 click".
Library description
Initializes click driver functions and I2C bus driver. Offers options for single or block writing to registers and reading from registers. Also offers options for calculating power and different types of voltage in a different number of samples and different full-scale range. For more details check the documentation.
Key functions
float pac1921_getMeasurementData( const uint8_t data_type, const uint8_t nSamples, const uint8_t full_scale ) - The function returns measurement data determined by the data_type parameter, which can be VSENSE (max 100mV), VBUS (max 32V) in mV, or VPOWER (max 320W) witch unit is W. One round of measurement consists of the determined number of samples.
void pac1921_blockReadReg( uint8_t register_address, uint8_t *data_buffer, uint8_t nBytes ) - The function reads bytes from registers to buffer with start location determined by the register_address parameter.
void pac1921_singleWriteReg( uint8_t register_address, uint8_t transfer_data ) - The function writes one byte of data to the register, determined by the parameter of the function.
The application is composed of three sections :
void applicationTask() { data_read = pac1921_getMeasurementData( _PAC1921_VBUS_FREE_RUN, _PAC1921_512_SAMPLES ); FloatToStr( data_read, text ); mikrobus_logWrite( text, _LOG_TEXT ); if ( _PAC1921_UNIT == 0 ) { mikrobus_logWrite( " mV", _LOG_LINE ); } else { mikrobus_logWrite( " W", _LOG_LINE ); } Delay_ms( 500 ); }
MikroElektronika Libraries used in the example:
Additional notes and information
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.