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]
Rating:
Author: MIKROE
Last Updated: 2019-04-20
Package Version: 1.0.0.2
mikroSDK Library: 1.0.0.0
Category: PWM
Downloaded: 6057 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.
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".
Front and back view of the PWM Click board designed in mikroBUS form factor.
View full imageLibrary 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.Examples description
The application is composed of the three sections :
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 click, USB 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 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