PCA9955A and PCA9956A class library. The PCA9955A is a 16-channel and the PCA9956A is a 24-channel Fm+ I2C-bus 57mA/20V constant current LED driver. The PCA9955A has a extended feature which called "Gradation control".

Dependencies:   CompLedDvrCC

Dependents:   PCA9956A_Hello pca9956b_two_demoboards PCA9955A_Gradation_control PCA9955A_Gradation_control ... more

What is this?

Code for PCA9956A and PCA9955A.
24-channel and 16-channel constant current type LED driver component class.

Please refer to the component page for details

PCA9955B and PCA9956B are I²C-bus controlled 16-channel constant current LED driver optimized for dimming and blinking.

High-level API is available

A high-level API that can be used as the "PwmOut" of bed-SDK is available.
This API enables to make instances of each LED output pins and control PWM duty cycle by assignment.
Output current also controllable by API function.
For detail information, refer API document of LedPwmOutCC Class class which is included in PCA995xA class library.

#include "mbed.h"
#include "PCA9956A.h"

PCA9956A    led_cntlr( p28, p27, 0xC4 );  //  SDA, SCL, Slave_address(option)
LedPwmOutCC led( led_cntlr, L0 );

int main()
{
    while( 1 ) {
        for( float p = 0.0f; p < 1.0f; p += 0.1f ) {
            led     = p;
            wait( 0.1 );
        }
    }
}

About the chips

PCA9956A

The PCA9956A is an I2C-bus controlled 24-channel constant current LED driver optimized for dimming and blinking 57 mA LEDs. Each LED output has its own 8-bit resolution (256 steps) fixed frequency individual PWM controller that operates at 31.25 kHz with a duty cycle that is adjustable from 0 % to 99.6 % to allow the LED to be set to a specific brightness value.

Datasheet: http://www.nxp.com/documents/data_sheet/PCA9956A.pdf

PCA9955A

The PCA9955A is an I2C-bus controlled 16-channel constant current LED driver optimized for dimming and blinking 57 mA Red/Green/Blue/Amber (RGBA) LEDs in amusement products. Each LED output has its own 8-bit resolution (256 steps) fixed frequency individual PWM controller that operates at 31.25 kHz with a duty cycle that is adjustable from 0 % to 100 % to allow the LED to be set to a specific brightness value.

On addition to this, the PCA9955A has "Gradation control".
The gradation control is a new feature of PCA995xA series. After the register setting and start the control, the PCA9955A performs dimming cycles automatically without MCU intervention.

Datasheet: http://www.nxp.com/documents/data_sheet/PCA9955A.pdf

PCA9952 and PCA9955 (non-A version)

The PCA9955 and PCA9955 (no-A at end of the type number) is not supported by this component class.

PCA9955(non-A)

PCA9955A != PCA9955

PCA9955A is not software compatible to PCA9955(non-A version).
There are several differences between A and non-A versions.
Register mapping is one of the difference. Please make sure you are using PCA9955A.

How the API works?

When the instance is made, all set up for PWM operation are done automatically.
For the operation, user can control the LED brightness in two ways.

  • PWM
  • Current

PCA9955A and PCA9956A have internal 31.25kHz oscillator to generate internal PWM waveform. This signal switchs the output current ON and OFF. The class' function pwm() controls duty-cycle of this output.

Another control is current. Since the PCA9955A and PCA9956A are constant current type LED driver, those have internal current sources. The current source on each channels has independent control of output current. The class' function current() provides interface to current change.

API_and_output

Tips for the chips

PCA995xA family

This PCA995xA components library can be used for both PCA9955A(16-channel) and PCA9956A(24-channel).
If you are using both chips on the I2C bus, those can be operated like..

#include "mbed.h"
 
#include "PCA9955A.h"
#include "PCA9956A.h"

PCA9955A    led0( p28, p27, 0xC0 );    //  SDA, SCL, Slave_address=0xC0 (16-channel chip)
PCA9956A    led1( p28, p27, 0xC2 );    //  SDA, SCL, Slave_address=0xC2 (24-channel chip)
 
int main()
{
    led0.current( ALLPORTS, 1.0 ); //  Set all ports output current 100%
    led1.current( ALLPORTS, 1.0 ); //  Set all ports output current 100%

    led0.pwm( ....    //  PWM control for PCA9955A(16-channel chip)
    led1.pwm( ....    //  PWM control for PCA9956A(24-channel chip)
    ...

Other sample code

For PCA9955A : http://developer.mbed.org/users/nxp_ip/code/PCA9955A_Hello/
For PCA9956A : http://developer.mbed.org/users/nxp_ip/code/PCA9956A_Hello/
For Gradation control of PCA9955A http://developer.mbed.org/users/nxp_ip/code/PCA9955A_Gradation_control/

Committer:
nxp_ip
Date:
Wed Mar 04 10:25:58 2015 +0000
Revision:
2:eeea2e848b81
Parent:
1:3522be54a4f5
Child:
10:0d865f257fd2
LedPwmOut API (Constant-current type device version: LedPwmOutCC) is included

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nxp_ip 0:a624e2eeccac 1 /** PCA995xA constant current LED driver family
nxp_ip 0:a624e2eeccac 2 *
nxp_ip 0:a624e2eeccac 3 * Abstract class for PCA995xA family
nxp_ip 0:a624e2eeccac 4 * No instance can be made from this class
nxp_ip 0:a624e2eeccac 5 *
nxp_ip 0:a624e2eeccac 6 * @class PCA9956A
nxp_ip 0:a624e2eeccac 7 * @author Akifumi (Tedd) OKANO, NXP Semiconductors
nxp_ip 0:a624e2eeccac 8 * @version 0.5
nxp_ip 0:a624e2eeccac 9 * @date 25-Feb-2015
nxp_ip 0:a624e2eeccac 10 *
nxp_ip 1:3522be54a4f5 11 * Released under the Apache 2 license
nxp_ip 0:a624e2eeccac 12 */
nxp_ip 0:a624e2eeccac 13
nxp_ip 0:a624e2eeccac 14 #ifndef MBED_PCA995xA
nxp_ip 0:a624e2eeccac 15 #define MBED_PCA995xA
nxp_ip 0:a624e2eeccac 16
nxp_ip 0:a624e2eeccac 17 #include "mbed.h"
nxp_ip 2:eeea2e848b81 18 #include "CompLedDvrCC.h"
nxp_ip 0:a624e2eeccac 19
nxp_ip 0:a624e2eeccac 20 #define ALLPORTS 0xFF
nxp_ip 0:a624e2eeccac 21 #define DEFAULT_PWM 1.0
nxp_ip 0:a624e2eeccac 22 #define DEFAULT_CURRENT 0.1
nxp_ip 0:a624e2eeccac 23
nxp_ip 1:3522be54a4f5 24 /** Abstract class for PCA995xA family
nxp_ip 1:3522be54a4f5 25 *
nxp_ip 0:a624e2eeccac 26 * No instance can be made from this class
nxp_ip 0:a624e2eeccac 27 */
nxp_ip 2:eeea2e848b81 28 class PCA995xA : public CompLedDvrCC
nxp_ip 0:a624e2eeccac 29 {
nxp_ip 0:a624e2eeccac 30 public:
nxp_ip 0:a624e2eeccac 31 PCA995xA( PinName i2c_sda, PinName i2c_scl, char i2c_address = DEFAULT_I2C_ADDR );
nxp_ip 0:a624e2eeccac 32 PCA995xA( I2C &i2c_obj, char i2c_address = DEFAULT_I2C_ADDR );
nxp_ip 0:a624e2eeccac 33 virtual ~PCA995xA();
nxp_ip 0:a624e2eeccac 34
nxp_ip 0:a624e2eeccac 35 void reset( void );
nxp_ip 0:a624e2eeccac 36
nxp_ip 2:eeea2e848b81 37 virtual void pwm( int port, float v );
nxp_ip 2:eeea2e848b81 38 virtual void current( int port, float vp );
nxp_ip 2:eeea2e848b81 39
nxp_ip 0:a624e2eeccac 40 void pwm( float *vp );
nxp_ip 0:a624e2eeccac 41 void current( float *vP );
nxp_ip 2:eeea2e848b81 42
nxp_ip 0:a624e2eeccac 43 virtual int number_of_ports( void ) = 0;
nxp_ip 0:a624e2eeccac 44
nxp_ip 0:a624e2eeccac 45 void write( char reg_addr, char data );
nxp_ip 0:a624e2eeccac 46 void write( char *data, int length );
nxp_ip 0:a624e2eeccac 47 char read( char reg_addr );
nxp_ip 0:a624e2eeccac 48 void read( char reg_addr, char *data, int length );
nxp_ip 0:a624e2eeccac 49
nxp_ip 0:a624e2eeccac 50 protected:
nxp_ip 0:a624e2eeccac 51 enum {
nxp_ip 0:a624e2eeccac 52 DEFAULT_I2C_ADDR = 0xC0,
nxp_ip 0:a624e2eeccac 53 AUTO_INCREMENT = 0x80
nxp_ip 0:a624e2eeccac 54 };
nxp_ip 0:a624e2eeccac 55
nxp_ip 0:a624e2eeccac 56 private:
nxp_ip 0:a624e2eeccac 57 virtual char pwm_register_access( int port ) = 0;
nxp_ip 0:a624e2eeccac 58 virtual char current_register_access( int port ) = 0;
nxp_ip 0:a624e2eeccac 59
nxp_ip 0:a624e2eeccac 60 I2C *i2c_p;
nxp_ip 0:a624e2eeccac 61 I2C &i2c;
nxp_ip 0:a624e2eeccac 62 char address; // I2C slave address
nxp_ip 0:a624e2eeccac 63 }
nxp_ip 0:a624e2eeccac 64 ;
nxp_ip 0:a624e2eeccac 65
nxp_ip 0:a624e2eeccac 66 #endif // MBED_PCA995xA