TOP Contributors

  1. MIKROE (2650 codes)
  2. Alcides Ramos (350 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 (136537 times)
  2. FAT32 Library (69730 times)
  3. Network Ethernet Library (55839 times)
  4. USB Device Library (46172 times)
  5. Network WiFi Library (41799 times)
  6. FT800 Library (40985 times)
  7. GSM click (28921 times)
  8. PID Library (26383 times)
  9. mikroSDK (26277 times)
  10. microSD click (25297 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

PWM Click

Rating:

1

Author: MIKROE

Last Updated: 2019-04-20

Package Version: 1.0.0.2

mikroSDK Library: 1.0.0.0

Category: PWM

Downloaded: 5577 times

Followed by: 3 users

License: MIT license  

PWM click is a simple solution for controlling 16 PWM outputs through a single I2C interface. The click board carries the PCA9685PW IC. It is designed to use either a 3.3V or 5V power supply. The board also uses a LOW Output Enable Input pin (OE), which is in place of the default mikroBUS RST pin.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "PWM Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "PWM Click" changes.

Do you want to report abuse regarding "PWM Click".

  • mikroSDK Library 2.0.0.0
  • Comments (9)
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

PWM Click

PWM Click

Front and back view of the PWM Click board designed in mikroBUS form factor.

View full image

Library Description

The library covers all the necessary functions that enables the usage of the PWM click board. It initializes and defines the I2C driver and drivers that offer a choice for controlling 16 PWM outputs through a single I2C interface. This library offer functions that allow the user to make controlled PWM output to each and every of 16 channels. It also allows for different configurations and prescaling. Library also offers generic read and write functions for aditional functionality.

Key functions:

  • pwm_devConfig( uint8_t allcall, uint8_t sub3, uint8_t sub2, uint8_t sub1, uint8_t sleep, uint8_t restart ) - Function is used to configure the device.
  • pwm_setChannel( uint8_t channId, uint8_t offset, uint8_t dutyCyc ) - Function is used to specific set channel output with data.
  • pwm_setAll( uint8_t dutyCyc ) - Function is used to set all channels output with data.

Examples description

The application is composed of the three sections :

  • System Initialization - Initializes GPIO, I2C and LOG structures, set RST pin as output.
  • Application Initialization - Initalizes I2C driver, enables output, configures device, sets prescaling, configures output and makes an initial log.
  • Application Task - (code snippet) - This is an example that shows some of the functions that PWM click has.
void applicationTask()
{
    uint16_t rawDc;
    uint8_t channId;
    uint8_t dutyCycle;
    channId = 0;
    mikrobus_logWrite( "Channel 0 false state  ", _LOG_LINE );
    pwm_channelState( channId, 0 );
    mikrobus_logWrite( "--------------------------", _LOG_LINE );
    Delay_ms( 2000 );
    
    mikrobus_logWrite( "Channel 0 set raw  ", _LOG_LINE );
    for ( rawDc = 0; rawDc < PWM_MAX_RESOLUTION; rawDc += 256 )
    {
        pwm_setChannelRaw( channId, 0, rawDc );
        mikrobus_logWrite( " >", _LOG_TEXT );
        Delay_ms( 500 );
    }
    mikrobus_logWrite( "", _LOG_LINE );
    mikrobus_logWrite( "--------------------------", _LOG_LINE );
    Delay_ms( 1000 );
    
    mikrobus_logWrite( "Channel 0 set  ", _LOG_LINE );
    for ( dutyCycle = 0; dutyCycle < 100; dutyCycle += 10 )
    {
        pwm_setChannel( channId, 0, dutyCycle );
        mikrobus_logWrite( " >", _LOG_TEXT );
        Delay_ms( 500 );
    }
    mikrobus_logWrite( "", _LOG_LINE );
    mikrobus_logWrite( "--------------------------", _LOG_LINE );
    Delay_ms( 1000 );
    
    mikrobus_logWrite( "All Channels raw set  ", _LOG_LINE );
    for ( rawDc = 0; rawDc < PWM_MAX_RESOLUTION; rawDc += 256 )
    {
        pwm_setAllRaw( rawDc );
        mikrobus_logWrite( " >", _LOG_TEXT );
        Delay_ms( 500 );
    }
    mikrobus_logWrite( "", _LOG_LINE );
    mikrobus_logWrite( "--------------------------", _LOG_LINE );
    Delay_ms( 1000 );
    
    mikrobus_logWrite( "All Channels set  ", _LOG_LINE );
    for ( dutyCycle = 0; dutyCycle < 100; dutyCycle += 10 )
    {
        pwm_setAll( dutyCycle );
        mikrobus_logWrite( " >", _LOG_TEXT );
        Delay_ms( 500 );
    }
    mikrobus_logWrite( "", _LOG_LINE );
    mikrobus_logWrite( "--------------------------", _LOG_LINE );
    Delay_ms( 1000 );
    
    mikrobus_logWrite( "All Channels false state  ", _LOG_LINE );
    pwm_allChannState( 0 );
    mikrobus_logWrite( "--------------------------", _LOG_LINE );
    Delay_ms( 2000 );
}

Other mikroE Libraries used in the example:

  • I2C
  • UART

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.

PWM Click Schematics

PWM Click Schematics

Schematics of the PWM click.

View full image

PWM click - example

PWM click is a simple solution for controlling 16 PWM outputs through a single I2C interface. You can use it to control anything from a simple LED strip to a complex robot with a multitude of moving parts. The click boardâ„¢ carries the PCA9685PW IC. The

Watch on YouTube

ALSO FROM THIS AUTHOR

LightHz click

0

LightHz Click is a compact add-on board that effectively measures ambient light intensity. This board features the TL2L30BR, a programmable light-to-frequency converter from ams. The sensor outputs either a pulse train or a square wave (50% duty cycle) with a frequency directly proportional to light intensity (irradiance). It has programmable sensitivity and full-scale output frequency and could be used as a rough color detector with a selectable frequency range.

[Learn More]

IrDA 4 click

0

IrDA 4 Click is a compact add-on board that provides a cost-effective solution for sending and receiving IR serial data. This board features the TFBS4650, an infrared transceiver from Vishay Semiconductors. The transceiver includes a PIN photodiode, an infrared emitter, and a low-power integral circuit and complies with the IrDA physical layer specification.

[Learn More]

Illuminance click

0

Illuminance Click is a compact add-on board that mimics how humans perceive light. This board features ams AG’s TSL2583, a very-high sensitivity light-to-digital converter that transforms light intensity to a digital signal output capable of the direct I2C interface. It combines one broadband photodiode (visible plus infrared) and one infrared-responding photodiode on a single CMOS integrated circuit capable of providing a near-photopic response over an effective 16-bit dynamic range (16-bit resolution).

[Learn More]