TOP Contributors

  1. MIKROE (2656 codes)
  2. Alcides Ramos (353 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 (136876 times)
  2. FAT32 Library (70000 times)
  3. Network Ethernet Library (55999 times)
  4. USB Device Library (46305 times)
  5. Network WiFi Library (41923 times)
  6. FT800 Library (41206 times)
  7. GSM click (29012 times)
  8. PID Library (26423 times)
  9. mikroSDK (26396 times)
  10. microSD click (25386 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: 2596 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

Network Ethernet Library

72

Ethernet library designed to simplify handling of the underlying hardware (ENC24J600/ENC28J60 and internal ethernet module on PIC18, PIC32, FT90x, TIVA and STM32). Library supports: TCP Stack (Server/Client), UDP, IPv4 protocol, ARP requests, ICMP echo requests, ARP client with cache, DNS client, DHCP client.

[Learn More]

3G click

7

3G click (for Europe and Australia) is a mikroBUS add-on board with Quectel’s UG95 3G UMTS/HSPA module. The board has an SMA connector, earphone/microphone jack, MicroUSB port, as well as a SIM card slot. 3G click communicates with the target MCU through the mikroBUS UART interface (RX, TX). Note: Antenna sold separately.

[Learn More]

RTC 9 click

0

RTC 9 Click is a real-time clock module that has an extremely low power consumption, allowing it to be used with a single button cell battery, for an extended period of time. This board features the M41T82, real-time clock (RTC) with battery switchover, from ST Microelectronics.

[Learn More]