TOP Contributors

  1. MIKROE (2653 codes)
  2. Alcides Ramos (352 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 (136723 times)
  2. FAT32 Library (69936 times)
  3. Network Ethernet Library (55940 times)
  4. USB Device Library (46265 times)
  5. Network WiFi Library (41886 times)
  6. FT800 Library (41169 times)
  7. GSM click (28980 times)
  8. PID Library (26412 times)
  9. mikroSDK (26357 times)
  10. microSD click (25361 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: 2588 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

Pressure 4 click

0

Pressure 4 click is an absolute barometric pressure measurement Click board™, which features a low power consumption, high precision barometric pressure sensor. Capable of using both SPI and I2C communication protocols, Pressure 4 click allows being interfaced with a broad range of various microcontroller units (MCUs). The sensor used on this Click board™ features onboard processing capabilities, such as the IIR filtering, used to filter out abrupt changes of pressure. Low power consumption allows Pressure 4 click to be used in many portable, battery-powered applications.

[Learn More]

RN4870 click

0

RN4870 click carries the RN4870 Bluetooth® 4.2 low energy module from Microchip. The click is designed to run on a 3.3V power supply. It uses ASCII Command Interface over UART for communication with target microcontroller, with additional functionality provided by the following pins on the mikroBUS™ line: PWM, INT, RST, CS.

[Learn More]

Earthquake click

7

Earthquake click carries D7S, the world’s smallest high-precision seismic sensor from Omron. The click is designed to run on either 3.3V or 5V power supply. It communicates with the target MCU over I2C interface, with additional functionality provided by the following pins on the mikroBUS line: PWM, INT, CS.

[Learn More]