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: 2020-08-31
Package Version: 1.0.0.0
mikroSDK Library: 1.0.0.0
Category: ADC
Downloaded: 2081 times
Not followed.
License: MIT license
AN to PWM 2 Click is a compact add-on board that contains an easy-to-use component that converts the value of the input analog signal to a fixed frequency PWM voltage output, with a duty cycle proportional to the input voltage.
Do you want to subscribe in order to receive notifications regarding "AN to PWM 2 click" changes.
Do you want to unsubscribe in order to stop receiving notifications regarding "AN to PWM 2 click" changes.
Do you want to report abuse regarding "AN to PWM 2 click".
Library Description
The library contains basic function for sets frequency and gets interrupt pin state.
Key functions:
uint8_t antopwm2_get_int_state ( void )
- Gets interrupt pin statevoid antopwm2_set_freq ( uint8_t freq )
- Set FrequencyExamples description
The application is composed of three sections :
void application_task ( )
{
uint8_t drdy;
char rsp_data;
drdy = UART_Rdy_Ptr( );
if ( drdy != 0 )
{
rsp_data = UART_Rd_Ptr( );
switch ( rsp_data )
{
case '+' :
{
// Reset flags
period_flag = 0;
idle_high_cnt = 0;
idle_low_cnt = 0;
period_cnt = 0;
while ( period_flag != 1 );
idle_high_cnt /= 10;
idle_low_cnt /= 10;
if ( ( idle_high_cnt != 0 ) && ( idle_high_cnt != 0 ) )
{
tmp_value = calc_percentage( idle_high_cnt );
FloatToStr( tmp_value, demo_text );
mikrobus_logWrite( "> Idle [HIGH]: ~ ", _LOG_TEXT );
mikrobus_logWrite( demo_text, _LOG_TEXT );
mikrobus_logWrite( " %", _LOG_LINE );
tmp_value = calc_percentage( idle_low_cnt );
FloatToStr( tmp_value, demo_text );
mikrobus_logWrite( "> Idle [LOW]: ~ ", _LOG_TEXT );
mikrobus_logWrite( demo_text, _LOG_TEXT );
mikrobus_logWrite( " %", _LOG_LINE );
tmp_value = calc_voltage( idle_high_cnt );
FloatToStr( tmp_value , demo_text );
mikrobus_logWrite( "> Voltage: ~ ", _LOG_TEXT );
mikrobus_logWrite( demo_text, _LOG_TEXT );
mikrobus_logWrite( " mV", _LOG_LINE );
mikrobus_logWrite( "--------------------------------", _LOG_LINE );
}
mikrobus_logWrite( "--- Please, enter the command [ + ].", _LOG_LINE );
break;
}
}
}
}
Additional Functions :
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.