TOP Contributors

  1. MIKROE (2653 codes)
  2. Alcides Ramos (351 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (136668 times)
  2. FAT32 Library (69909 times)
  3. Network Ethernet Library (55923 times)
  4. USB Device Library (46251 times)
  5. Network WiFi Library (41882 times)
  6. FT800 Library (41129 times)
  7. GSM click (28973 times)
  8. PID Library (26406 times)
  9. mikroSDK (26345 times)
  10. microSD click (25350 times)
Libstock prefers package manager

Package Manager

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]

< Back
mikroSDK Library

Analog To PWM click

Rating:

5

Author: MIKROE

Last Updated: 2020-04-06

Package Version: 1.0.0.0

mikroSDK Library: 1.0.0.0

Category: Measurements

Downloaded: 2587 times

Not followed.

License: MIT license  

AN to PWM Click is a device that converts the value of the input analog signal with virtually any wave shape to a fixed frequency PWM voltage output, with a duty cycle proportional to the input voltage

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Analog To PWM click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Analog To PWM click" changes.

Do you want to report abuse regarding "Analog To PWM click".

  • Information
  • Comments (0)
DOWNLOAD LINK RELATED COMPILER CONTAINS
mikroBasic PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroBasic PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroC PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for ARM
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for AVR
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for dsPIC30/33 & PIC24
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for FT90x
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc
mikroPascal PRO for PIC32
  • lib
  • src
  • exa
  • hlp
  • hex
  • sch
  • pcb
  • doc

mikroSDK Library Blog

AN to PWM Click

AN to PWM Click

Native view of the AN to PWM Click board.

View full image
AN to PWM Click

AN to PWM Click

Front and back view of the AN to PWM Click board.

View full image

Library Description

The library contains a interrupt pin state function.

Key functions:

  • uint8_t antopwm_get_int_state( ) - Gets interrupt pin state

Examples description

The application is composed of three sections :

  • System Initialization - Initializes the INT pin required to measure.
  • Application Initialization - Initializes the driver and timer on 1us
  • Application Task - Waits for the + command entered. When a command is entered, it calculates the PWM signal and the voltage on the INT pin.
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 :

  • calc_percentage( ) - Represented data as a percentage
  • calc_voltage( ) - Voltage calculation
  • timer_init_1us( ) - Sets timer on 1us

Other mikroE Libraries used in the example:

  • Conversions
  • UART library

Additional notes and informations

Depending on the development board you are using, you may need USB UART clickUSB 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.

ALSO FROM THIS AUTHOR

HOD CAP click

0

HOD CAP Click is a compact add-on board that adds a smart sensing solution to your application. This board features the AS8579, a capacitive sensor from ams OSRAM. The sensor features I/Q signal demodulation, parasitic influences from cable, and PCB protection. It has ten sense outputs, five of which come with sensing line filter circuits. This Click board™ makes the perfect solution for the development of autonomous driving applications such as hands-on steering wheel detection and detection of any human presence inside a vehicle or outside of the vehicle, e.g., for automatic trunk opener and more.

[Learn More]

Buck-Boost click

0

Buck-Boost click™ features LTC3129-1, a buck-boost DC/DC conversion integrated circuit. The click supports a wide input voltage range and can output eight discrete regulated output voltage levels, selectable by the digital output voltage selection pins, ranging from 2.5V to 15V.

[Learn More]

Let’s make - mikroWeb server

0

The mikromedia-based mikroWebserver is the easiest way to remotely monitor and control your smart home system, weather station, or any other type of data logger.

[Learn More]