TLC5947 and Mosfets

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
hobbes191
 
Posts: 7
Joined: Mon Feb 08, 2016 7:44 pm

TLC5947 and Mosfets

Post by hobbes191 »

So I made the mistake of buying TLC5947's thinking they would give me 24 extra PWM pins similar to the ones on the arduino. The plan was to control multiple RGBL analog strips via external power (since the strips are long enough to need the additional current) by using the PWM pins on the 5947 to interact with mosfets. Unfortunately, I was mistaken since the 5947 cannot switch a mosfet on and off without some weird inverter/pull-up configuration.

While researching how to use the 5947 PWM pins like normal arduino PWM pins, I learned that whatever is connected to the 5947 will flicker whenever you write to it (or after x milliseconds or something, it doesn't really matter, the point is that LED's will visibly flicker under normal use). I reread the product page on the adafruit site and still didn't see anything warning about the flickering problem, although that would probably bite into sales so I'm not surprised..

So now I'm here and need to reevaluate the project. This lead to a few questions..

1. How do I make it so that LED's won't flicker when using the 5947? If the answer is "that's impossible" then please skip question 2 since these boards are useless for my application, lesson learned $$

2. What would I need to buy to make the 5947 switch mosfets like the PWM pins on the arduino?

2. What are my options as far as adding PWM pins to an uno (that can interact with/switch mosfets)? Preferably something straightforward like a shield that you just plug in, load a library and you've got more PWM pins to work with.

User avatar
adafruit_support_mike
 
Posts: 65256
Joined: Thu Feb 11, 2010 2:51 pm

Re: TLC5947 and Mosfets

Post by adafruit_support_mike »

2) Add some PNP transistors:
tlc5947.jpg
tlc5947.jpg (13.27 KiB) Viewed 2306 times
When the TLC5947 pin opens, it will turn the PNP on. That will pull the 10k resistor connected to the mosfet's gate high, turning the mosfet on. When the TLC5947's pin closes, the PNP and mosfet will shut off.

Technically that doesn't do anything about the flickering, but it's a lot easier for the human eye to see a millisecond of light in a second of darkness than a millisecond of darkness in a second of light.

User avatar
hobbes191
 
Posts: 7
Joined: Mon Feb 08, 2016 7:44 pm

Re: TLC5947 and Mosfets

Post by hobbes191 »

Okay that's not too bad.

Image

I think I'm pretty close to the circuit above. Technically the resistors aren't 10k and that's an NPN transistor but I'll pretend it's the right hardware for the sake of demonstrating. The breadboard power rails would be connected to a 12V dc source and I'm also pretending that the TLC5947 is hooked up to an arduino properly with a ground established between arduino and (-) breadboard rail

Into the emitter -right pin- of the transistor I've got the yellow lead from the V+ pin on the TLC5947. The base -middle pin- of the transistor has a 10k resistor going to a white lead that goes back to a PWM pin on the board. The collector -left pin- of the transistor has a 10k resistor going to ground and a red lead connecting to the gate of the mosfet.

The mosfet has a blue lead going from the drain -middle pin- to the blue lead of the led strip. The source -left pin- of the mosfet has a black lead going to ground.

I think that's right(?) The V+ and the PWM pin on the board are both connected to the transistor to switch that. Then the collector of the transistor is connected to both the gate of the mosfet and the common ground so it should switch the mosfet. Maybe I'm supposed to use a different V source going to the transistor's emitter?

User avatar
adafruit_support_mike
 
Posts: 65256
Joined: Thu Feb 11, 2010 2:51 pm

Re: TLC5947 and Mosfets

Post by adafruit_support_mike »

Go ahead and use the same power for the transistor as for the LED strip. Any common PNP will be able to handle voltages up to about 40v.

User avatar
hobbes191
 
Posts: 7
Joined: Mon Feb 08, 2016 7:44 pm

Re: TLC5947 and Mosfets

Post by hobbes191 »

the 10K resistors and PNP transistors arrived and I'm back to getting this figured out.

Let me see if I'm understanding this diagram right.. The emitter pin on the transistor, the one with the arrow on the diagram, connects directly to 12V. The base on the transistor connects to a PWM pin on the TLC5947 with a 10k resistor. And finally the collector has two connections, one going directly to the mosfet gate and the other going to ground with a 10k resistor.

Image

I figure the example code will occasionally turn pin 0 on the 5947 board on and off, but it's not happening. I'm thinking I misinterpreted what's going on at the collector pin on the transistor. I noticed that when I take the wire out of the 5947 PWM pin, the LED goes off. Plugging it back in usually turns the LED back on. Plugging it into the V+ pin rather than the PWM pin also usually turns the LED back on. Not sure if that's important or indicative of anything.

fwiw, I've got the source of the mosfet being common ground and the mosfet drain connected to a cathode lead from the led strip. Then the +12V common anode pin from the led strip is connected to my 12V power supply.

like this:

Image

User avatar
adafruit_support_mike
 
Posts: 65256
Joined: Thu Feb 11, 2010 2:51 pm

Re: TLC5947 and Mosfets

Post by adafruit_support_mike »

hobbes191 wrote:Let me see if I'm understanding this diagram right.. The emitter pin on the transistor, the one with the arrow on the diagram, connects directly to 12V. The base on the transistor connects to a PWM pin on the TLC5947 with a 10k resistor. And finally the collector has two connections, one going directly to the mosfet gate and the other going to ground with a 10k resistor.
Yep, that's all correct.
hobbes191 wrote:I figure the example code will occasionally turn pin 0 on the 5947 board on and off, but it's not happening.
Post the exact code you're using and we'll see.

It sounds like you've confirmed the mosfet is working the way it should by connecting it to different known signals. That means the trouble is most likely to be in the BJT or the signals from the TLC5947.

To check the BJT, connect the 10k resistor between the base and your 12v supply rail, then connect it between the base and the GND rail. The LEDs should turn off when the input voltage is high, and should turn off when the input voltage is low.

User avatar
hobbes191
 
Posts: 7
Joined: Mon Feb 08, 2016 7:44 pm

Re: TLC5947 and Mosfets

Post by hobbes191 »

Okay so I've got the hardware side functioning.

Image

And it's got some flickering issues when fading. It's a little tricky to see but here's a video. On camera, the flickering shows up in more of a weird distortion and waves around the LED strips. To the eye it's definitely visible.

https://youtu.be/d2s_229-_TQ

The code used is simply the TLC5947 example program from adafruit:

Code: Select all

#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);
  }
}
Any idea what could be causing the flickering? Maybe the tlc5947 needs a capacitor on it? Or maybe I should look into that trick of shorting the OE and CLK pins together that seems to have worked for others for reasons that aren't clear? It is driving a PNP transistor which is driving a mosfet and both take time to switch. Since that time "stacks," maybe that's the issue?

User avatar
adafruit_support_mike
 
Posts: 65256
Joined: Thu Feb 11, 2010 2:51 pm

Re: TLC5947 and Mosfets

Post by adafruit_support_mike »

Does the flicker happen while the strips are holding a single color, or just during a fade?

User avatar
hobbes191
 
Posts: 7
Joined: Mon Feb 08, 2016 7:44 pm

Re: TLC5947 and Mosfets

Post by hobbes191 »

sorry, yes it's only when fading. solid colors are fine

User avatar
adafruit_support_mike
 
Posts: 65256
Joined: Thu Feb 11, 2010 2:51 pm

Re: TLC5947 and Mosfets

Post by adafruit_support_mike »

That sounds like interaction between the TLC5947's internal PWM clock and the timing of the updates as you fade the values.

The TCS5947's PWM counter doesn't reset when you send the XLAT signal high to enter the new values. The outputs just shut off until the beginning of the next counting period.

The BLANK signal does reset the PWM counter though. Try pulling that high just before you toggle XLAT, then sending it low right after toggling XLAT. You probably have a millisecond of leeway on the timing. Human eyes are a lot better at seeing brief flashes of light than brief periods of dark.

User avatar
13rac1
 
Posts: 1
Joined: Tue Dec 13, 2016 1:36 am

Re: TLC5947 and Mosfets

Post by 13rac1 »

Super late reply, but hopefully useful to someone else in the future.

Connecting the XLAT(LAT) and BLANK(/OE) pins together solved the flicker on the Adafruit TLC5947. Recommended by banned here: https://e2e.ti.com/support/power_manage ... 824#682824

User avatar
adafruit_support_mike
 
Posts: 65256
Joined: Thu Feb 11, 2010 2:51 pm

Re: TLC5947 and Mosfets

Post by adafruit_support_mike »

Thanks for posting the follow-up!

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”