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 (136706 times)
  2. FAT32 Library (69916 times)
  3. Network Ethernet Library (55929 times)
  4. USB Device Library (46254 times)
  5. Network WiFi Library (41882 times)
  6. FT800 Library (41141 times)
  7. GSM click (28975 times)
  8. PID Library (26407 times)
  9. mikroSDK (26354 times)
  10. microSD click (25351 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: 5595 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

Accel 27 click

0

Accel 27 Click is a compact add-on board that contains an acceleration sensor. This board features the ADXL373, a three-axis MEMS ±400g accelerometer from Analog Devices. In addition to its ultra-low power consumption, the ADXL373 enables impact detection while providing system-level power reduction. It offers 12-bit output data at 200mg/LSB scale factor with a configurable host interface that supports SPI and I2C serial communication.

[Learn More]

Compass 7 click

0

Compass 7 Click is a compact add-on board perfect for applications like an electronic compass. This board features the MMC5633NJL, a monolithic complete 3-axis AMR magnetic sensor with on-chip signal processing and an integrated digital bus from MEMSIC. It can measure magnetic fields within the full-scale range of ±30 Gauss (G) with up to 0.0625mG per LSB resolution at 20bits operation mode and 2mG total RMS noise level, enabling heading accuracy of ±1º in electronic compass applications. Also, an integrated SET/RESET function eliminates thermal variation-induced offset error (Null field output) and clears the residual magnetization resulting from powerful external fields.

[Learn More]

Cap Touch 2 click

5

Cap Touch 2 click is a capacitive touch sensing click board, with the advanced touch/proximity sensor IC, based on the proprietary RightSense technology from Microchip. Cap Touch 2 click has six touch sensitive channels and six independent LED drivers with several operating modes, including touch sensor linking.

[Learn More]