Cannot turn LED on! px4 External LED

Hey guys, I'm attempting to communicate to the TCA62724FM driver and then output a signal to turn the LED on.

https://store.3drobotics.com/products/pixhawk-peripheral-kit

The item is a px4 external LED with the TCA62724 driver. The data sheet of the driver can be found here:

http://www.mouser.com/ds/2/408/DST_TCA62724FMG-TDE_EN_21212-369086.pdf

I am using an Ardunio Uno as my microcontroller and I have attached the px4 enternal LED to the sda and clk inputs (A4,A5) including 2x8.2kohm pull up resistor.

Here is my code:

#include <Wire.h>
#define LED_ADDRESS 0x55 //Slave Address

void setup() {

Serial.begin(9600);
Wire.begin();
delay(5000);
TurnOnLed();
}

void TurnOnLed()
{
Wire.beginTransmission(LED_ADDRESS<<1); // Send to device 0x55 and setting the write bit to 0. For I2C devices, slave address is 7 bits and the LSB is the R/W bit. 0 for write and 1 for a read.
Wire.send(0); // Sub-address (I'm guessing between 0-2 for a PWM outputs (PWM0, PWM1, PWM2) and 3 for Data setup
Wire.send(1); // Data byte - 8 bits, only the bottom 4 bits are used for the 15 different PWM steps
Wire.endTransmission();

}

void loop()
{
}

Assuming my electronic connection is correct, I cannot get the LED to turn on. Any help is appreciated. Thanks in advance!

Hi, the data sheet seems to show that there is an "enable/shutdown" register at sub-address 3, as you mention in your comments. I think you may need to write the appropriate bits to that to enable the chip's outputs, 'cause it seems to default to not enabled.

So here is my attempt at modifying your sketch. Also please note you should always use code tags when posting code (look for the </> icon), like this:

#include <Wire.h>
#define LED_ADDRESS 0x55 //Slave Address

void setup() {
 
  Serial.begin(9600);
  Wire.begin();
  delay(5000);
  TurnOnLed();
}

void TurnOnLed()
{
    Wire.beginTransmission(LED_ADDRESS<<1);    // Send to device 0x55 and setting the write bit to 0. For I2C devices, slave address is 7 bits and the LSB is the R/W bit. 0 for write and 1 for a read.
    Wire.write(0);             // Sub-address (I'm guessing between 0-2 for a PWM outputs (PWM0, PWM1, PWM2) and 3 for Data setup
    Wire.write(10);             // Data byte - 8 bits, only the bottom 4 bits are used for the 15 different PWM steps
    Wire.write(3);             // Sub-address (I'm guessing between 0-2 for a PWM outputs (PWM0, PWM1, PWM2) and 3 for Data setup
    Wire.write(0b00000011);             // Data byte - 8 bits, two least significant bits are ENABLE and /SHUTDOWN
    Wire.endTransmission();

}

void loop()
{
}

Paul

Thanks for the reply Paul. Unfortunately there is no luck. The code compiles however it makes no changes to the LED.

You have the address wrong because you are shifting it one place to the left. Do not do this.

Grumpy_Mike:
You have the address wrong because you are shifting it one place to the left. Do not do this.

I saw that but somehow managed to convince myself it was correct! Reading the Wire.beginTransmission() page it does say the parameter is a 7 bit address. But shifting does make the 0x55 into an 8 bit number. I guess the function must do the sfift for you.

Yes the least significant bit is set by if you are doing a read or write and the shift is done inside the function. So if you shift the address as well it is getting done twice which gives the wrong address.

Thanks for the replies guys. I really appreciate it. I managed to get the driver to communicate to the LED. However not as to how ironically. I tried to enable to IC to power up with "LED_ENABLE" address. Here is the code:

#include <Wire.h>

#define LED_ADDRESS 0x55 //Slave Address 0000 0000 0101 0101

#define LED_ENABLE 0x04 // 0000 0000 0000 0100


void setup() {

 Serial.begin(9600);
 Wire.begin();
 delay(50);
 led_ON();
}

void led_ON()
{
  Wire.beginTransmission(LED_ADDRESS);
 Wire.write(LED_ENABLE);
 Wire.write(0x03);
 Wire.write(0x02);
 Wire.endTransmission();

  int ack = Wire.endTransmission();
 
 if(ack == 0) {
   Serial.println(F("LED DETECTED"));
   
 } else {
   Serial.println(F("LED ERROR"));
 }
}

If someone could clarify how the Wire.write worked in this case, I'd appreciate it. Thanks heaps.

First off edit that post. Select all the code and then hit the </> icon and then save it.

If someone could clarify how the Wire.write worked in this case, I'd appreciate it.

Wire.write works exactly how you have it but what you are not doing is writing all the data that the chip expects.

Now look at page 7 of the data sheet. What that code does is to write a 0x03 to register 4, which sets the enable an the !SHDN flags.

Then you write an isolated 0x02, why?

You have not set the PWM data for any of the LEDs.

When you have bit 7 of the sub-address low you get an auto increment so that successive data writes go to successive registers. I am not sure if this includes a wrap round. Therefore address the PWM registers first and write the PWM value to them, that's 0x0F for full on. Do this for all three registers Then enable the LEDs.

So after the Wire.beginTransmission(LED_ADDRESS)
that is a Wire.write for the following numbers

0 ( PWM0 )
0x0f ( PWM value for PWM 0 )
0x0f ( PWM value for PWM 1 )
0x0f ( PWM value for PWM 2 )
0x03 ( enable output blink )

then
Wire.endTransmission