0

Need help with TLC5947
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Need help with TLC5947

by mbiasotti on Sun Jul 17, 2016 7:12 pm

I am new to Arduino sketches. Have read Simon Monk's book "programming Arduino - getting started with sketches" but now I need to go beyond and get my project working.

I have two TLC5947's chained driving 15 RGB hi-powered LED's (for a total of 45 individual LED's) I've built custom boards using ULN2803A's (darlington arrays) to drive the LED's with a separate hi-power supply (each led of the RGB draws 150ma).
I've installed the TLC5947 library and run the TLC3947 test program (tlc5947test.ino) successfully (led's sequencing and turning different colors.

Now I want to write a custom sketch to test each individual channel individually, and one at a time, using my serial monitor to input the channel and led value (or using setLED to give it an RGB value. - i.e. 3 at a time.)

I can seem to get a sketch written that works because I don't quite understand the TLC5947 library and how it works. Could someone post a sketch to help me? I've included a diagram of my 2 TLC5947's.

Also, the way I've designed my LED driver boards I'm using the ULN2803A with Pull Up resistor network which means that when, for instance - colorWipe (4095,4095,4095) means all LEDs are off - not a big deal as I can transpose values.

thanks

Mark

mbiasotti
 
Posts: 14
Joined: Sun Jul 17, 2016 6:27 pm

Re: Need help with TLC5947

by franklin97355 on Sun Jul 17, 2016 7:52 pm


franklin97355
 
Posts: 20131
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Need help with TLC5947

by mbiasotti on Sun Jul 17, 2016 11:10 pm

Yes - I have reviewed that document.

mbiasotti
 
Posts: 14
Joined: Sun Jul 17, 2016 6:27 pm

Re: Need help with TLC5947

by mbiasotti on Mon Jul 18, 2016 12:04 pm

I think a big part of my problem is coming from Basic to C and learning how to use curly brackets. I'm getting compiling errors because I'm probably not using these correctly.

Mark

mbiasotti
 
Posts: 14
Joined: Sun Jul 17, 2016 6:27 pm

Re: Need help with TLC5947

by franklin97355 on Mon Jul 18, 2016 12:43 pm

If you think your code is the problem post it (using the [code] tags provided when you press the </> button and paste your code between the tags.) and we will take a look.

franklin97355
 
Posts: 20131
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: Need help with TLC5947

by mbiasotti on Tue Jul 19, 2016 12:58 pm

thank you for help Franklin97355,

Basically I want to use the functions "Serial available()" to type in a string of 4 values: [the led channel - I'm using 45 channels between my two TLC5947's], [PWM value of Red], [PWM value of Green], [PWM value of Blue] - and example of the string I type into my serial monitor terminal would be "1, 4095, 0, 0" = First led in string, Red full bright, Green off, Blue off. This way I will be able to interactively test each of my legs 1-15 RGB values and start to experiment with color.

The only code I have to work with is the example code tlc5947test.ino here:

https://github.com/adafruit/Adafruit_TLC5947/archive/master.zip Using this example code, all my hardware is verified working but now I need to create a program to test brightness of each individual LED's RGB.

I am not familiar with the TLC5947 library functions "setPWM," "setLED" but I think what I want to use is "setLED".

Of course setting things up is pretty standard:
<
Code: Select all | TOGGLE FULL SIZE
#include "Adafruit_TLC5947.h"

// How many boards do you have chained?
#define NUM_TLC5974 2

#define data   4
#define clock   5
#define latch   6
#define oe  -1  // set to -1 to not use the enable pin (its optional)

Adafruit_TLC5947 tlc = Adafruit_TLC5947(NUM_TLC5974, clock, data, latch);

void setup() {
  Serial.begin(9600);
 
  Serial.println("enter Channel, R,G,B value");
  tlc.begin();
  if (oe >= 0) {
    pinMode(oe, OUTPUT);
    digitalWrite(oe, LOW);
  }
}

>
Now what to do in the Void loop() is what I'm not sure what to do. I know that I need to use serial available() to read my string from my serial monitor and then convert that into some that "setLed" can read and then write to the appropriate pin. something like this:

<
Code: Select all | TOGGLE FULL SIZE
     void loop()
     {
        if (serial.available() > 0)
        char chan+rgbvalue = Serial.read();
// this is where I'm unsure how to convert the variable "chan+rgbvalue" into something that "talc.setLED" can use?
        tlc.setLED(i, r, g, b);
         tlc.write();
        delay(wait);
    }



Simple right? - well haven't done any coding for about a decade and that was visual basic.

Any help would be appreciated

thanks

Mark
Last edited by franklin97355 on Tue Jul 19, 2016 1:21 pm, edited 1 time in total.
Reason: added [code]...[/code] tags to post.

mbiasotti
 
Posts: 14
Joined: Sun Jul 17, 2016 6:27 pm

Re: Need help with TLC5947

by adafruit_support_bill on Tue Jul 19, 2016 1:24 pm

If you will be sending it numbers, you can use Serial.ParseInt() to read them:

https://www.arduino.cc/en/Serial/ParseInt

adafruit_support_bill
 
Posts: 71787
Joined: Sat Feb 07, 2009 10:11 am

Re: Need help with TLC5947

by mbiasotti on Sun Jul 24, 2016 2:08 am

thank you for that. I'm now using Serial.parseInt() and it works great. Better yet, the example over on the Arduino site's reference for Serial.parseInt() is the exact LED program that I'm looking for.

Thanks

Mark

mbiasotti
 
Posts: 14
Joined: Sun Jul 17, 2016 6:27 pm

Re: Need help with TLC5947

by adafruit_support_bill on Sun Jul 24, 2016 6:12 am

Awesome! Good to hear. Thanks for the follow-up :)

adafruit_support_bill
 
Posts: 71787
Joined: Sat Feb 07, 2009 10:11 am

Re: Need help with TLC5947

by Tchouala on Mon Jan 21, 2019 7:36 am

Hi Iam very new in TLC AND Arduino .
i need help to send information from arduino to Tlc5947.
i have been using the test code.
the Tlc 5947 can not receive the code the LEDS are not going on .

Kan you please help me ?

Code: Select all | TOGGLE FULL SIZE
/***************************************************
  This is an example for our Adafruit 24-channel PWM/LED driver

  Pick one up today in the adafruit shop!
  ------> http://www.adafruit.com/products/1429

  These drivers uses SPI to communicate, 3 pins are required to 
  interface: Data, Clock and Latch. The boards are chainable

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries. 
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include "Adafruit_TLC5947.h"

// How many boards do you have chained?
#define NUM_TLC5974 1

#define data   4
#define clock   5
#define latch   6
#define oe  -1  // set to -1 to not use the enable pin (its optional)

Adafruit_TLC5947 tlc = Adafruit_TLC5947(NUM_TLC5974, clock, data, latch);

void setup() {
  Serial.begin(9600);
 
  Serial.println("TLC5974 test");
  tlc.begin();
  if (oe >= 0) {
    pinMode(oe, OUTPUT);
    digitalWrite(oe, LOW);
  }
}

void loop() {
  colorWipe(4095, 0, 0, 100); // "Red" (depending on your LED wiring)
  delay(200);
  colorWipe(0, 4095, 0, 100); // "Green" (depending on your LED wiring)
  delay(200);
  colorWipe(0, 0, 4095, 100); // "Blue" (depending on your LED wiring)
  delay(200);
  rainbowCycle(10);
}


// Fill the dots one after the other with a color
void colorWipe(uint16_t r, uint16_t g, uint16_t b, uint8_t wait) {
  for(uint16_t i=0; i<8*NUM_TLC5974; i++) {
      tlc.setLED(i, r, g, b);
      tlc.write();
      delay(wait);
  }
}

// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
  uint32_t i, j;

  for(j=0; j<4096; j++) { // 1 cycle of all colors on wheel
    for(i=0; i< 8*NUM_TLC5974; i++) {
      Wheel(i, ((i * 4096 / (8*NUM_TLC5974)) + j) & 4095);
    }
    tlc.write();
    delay(wait);
  }
}

// Input a value 0 to 4095 to get a color value.
// The colours are a transition r - g - b - back to r.
void Wheel(uint8_t ledn, uint16_t WheelPos) {
  if(WheelPos < 1365) {
    tlc.setLED(ledn, 3*WheelPos, 4095 - 3*WheelPos, 0);
  } else if(WheelPos < 2731) {
    WheelPos -= 1365;
    tlc.setLED(ledn, 4095 - 3*WheelPos, 0, 3*WheelPos);
  } else {
    WheelPos -= 2731;
    tlc.setLED(ledn, 0, 3*WheelPos, 4095 - 3*WheelPos);
  }
}
Last edited by adafruit_support_bill on Mon Jan 21, 2019 7:47 am, edited 1 time in total.
Reason: Please use [code] tags when submitting code to the forums

Tchouala
 
Posts: 20
Joined: Mon Jan 21, 2019 6:15 am

Re: Need help with TLC5947

by adafruit_support_bill on Mon Jan 21, 2019 7:48 am

@Tchouala - Please post photos showing your soldering and connections.

adafruit_support_bill
 
Posts: 71787
Joined: Sat Feb 07, 2009 10:11 am

Re: Need help with TLC5947

by Tchouala on Mon Jan 21, 2019 7:21 pm

Here ist my connection
Attachments
montage.PNG
montage.PNG (697.68 KiB) Viewed 87 times

Tchouala
 
Posts: 20
Joined: Mon Jan 21, 2019 6:15 am

Re: Need help with TLC5947

by adafruit_support_bill on Mon Jan 21, 2019 7:47 pm

We can't see the soldering on the end where your connections are. But the headers on the other end are going to short everything out if plugged into the breadboard that way.

adafruit_support_bill
 
Posts: 71787
Joined: Sat Feb 07, 2009 10:11 am

Re: Need help with TLC5947

by Tchouala on Tue Jan 22, 2019 5:41 am

here is once more the soldering.

Gnd Gnd
V+ VIN
LAT Dig6
CLK Dig5
DIN Dig4
Attachments
bild.PNG
bild.PNG (545.54 KiB) Viewed 75 times

Tchouala
 
Posts: 20
Joined: Mon Jan 21, 2019 6:15 am

Re: Need help with TLC5947

by adafruit_support_bill on Tue Jan 22, 2019 6:18 am

We still can't see the solder joints for your connections to the board. And as I said in my previous post, the way you have the headers plugged in on the breadboard will short out the connections. You have the LAT and OE plugged into the same row on the breadboard. And you also have V+ and GND plugged into the same row.

adafruit_support_bill
 
Posts: 71787
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.