Go Down

Topic: Library for TLC5940 16-channel PWM chip (Read 36510 times) previous topic - next topic

acleone

Try deleting the .o file in library folder (<arduino folder>/hardware/libraries/TLC5940LED), then open the Arduino IDE again.


nphillips

#32
Sep 13, 2008, 04:52 pm Last Edit: Sep 13, 2008, 05:01 pm by nphillips Reason: 1
Have you run any fades over many hours?

I've been testing a few different wave-like motions, and when I come back to them in the morning, things are either off-sync or "stuck" flickering between two pins. The fade action of each pin seems fine, it's just the timing that breaks.

I thought it might be related to the millis() function, but last night I used a generic "Cylon" sweeper and it ended up stuck flickering between pins 5 and 7.

Here's my crappy code:
Code: [Select]
#include <TLC5940LED.h>
int i;
void setup()
{        
     Tlc.init();
     Tlc.resetTimers();
}

void loop()
{
 
 for(i=5;i<14;i+=2)
 {
   Tlc.newFade(i, 1500, 0, 4095);
   Tlc.newFade(i-2,1500,4095,0);
   while(Tlc.updateFades());
 }
for(i=13;i>2;i-=2)
 {
   Tlc.newFade(i, 1500, 0, 4095);
   Tlc.newFade(i+2, 1500, 4095, 0);
   while(Tlc.updateFades());
 }
}

EDIT: I forgot to add that hitting the reset button gets things back to normal.

And the "stuck" part of the cylon script is, as i said, between i=7 and i=5 on the second half.

This didn't happen with the regular arduino PWM controls. I'm wondering if it's something inside updateFades()

nphillips

Once again, I started poking around in the Library...

Code: [Select]
if (fp->stopMillis <= currentMillis)

As soon as the arduino's millis counter rolls over, this will get stuck in a 9-hour loop.

I don't have anything off the top of my head right now, but I think a simple for or switch statement to check if the stopMillis is higher than the millis() rollover point.

nima

Has anyone tested or used this library with Arduino IDE 12?

I can no longer use the library once I switched from 11 to 12

-nima

nphillips

I haven't upgraded yet, myself.

No time to do so, and play around with this lib. acleone, the creator, seems to have "disappeared" for the time being. Apparently, we all get busy around the same time. ;)

I still need to figure out a fix for the millis() issue I noted above.

If I knew anything about what changes were made in IDE 12, and how to update libraries accordingly, I'd lend a hand. Unfortunately, I have no idea how to do it, nor do I currently have the time to try :/

nima

usually there is a limit for millis(), that's why it wraps around and it's not an issue specific to the TLC5940 library (it's arduino limit).  But look around the forums for other solutions to the problem ( i *think* some ppl, once the millis reaches its limit, count down backwards or something)

nima

"As far as those 3V/80mA Sparkfun vibration motors are concerned, they seem to run fine at 500Hz, ramping up and down smoothly, based on prior experience. Alas, I won't be able to confirm with the TLC5940 for at least two weeks (vacation)."

I've used the TLC5940 to drive motors... a tip that usually emerges is to use diodes to protect the chip from any reverse current from the motors. I've used the tlc5940 with motors with diodes and without, and it never harmed the arduino or tlc5940 but it's good to use as a precaution

mikalhart

Just to clarify, in Arduino 0011, the return value for millis() increments upwards by 1 per millisecond until it reaches 0x20C49B9 (about 9 1/2 hours) and then returns to 0 ("rolls over") and continues upward.  In Arduino 0012, the rollover occurs at 0xFFFFFFFF, or about 49 days.

I haven't investigated the library code in particular, but I would suggest replacing

if (fp->stopMillis <= currentMillis)

with

// Version 0011 fix
#define ROLLOVER 0x20C49BA
if (currentMillis - fp->stopMillis % ROLLOVER < ROLLOVER/2)


or

// Version 0012 fix
if (currentMillis - fp->stopMillis < 0x80000000)


Mikal

nphillips

Thanks, mikel. I'll give that a go, soon.

it's essentially what I was thinking, but I didn't have the knowledge to build it ;)

sjunnesson

#40
Oct 06, 2008, 02:17 pm Last Edit: Oct 06, 2008, 04:27 pm by zervez Reason: 1
I have created a breakout board for this circuit for a more simple and quick build of projects and experiments. Take a look at http://www.instructables.com/id/The_Dawm/ where I have put a short instruction how to solder it together with some pictures. I also refer to your library acleone hope that is alright...

The nice thing of the breakout board is that it is easily connectable after each other creating a lot  of outputs fast together with the TLC5940 library

If anyone is interested in a breakout board please mail me or soon look at http://blushingboy.org/ where it will be sold as soon as the page is ready...

nphillips

Good instructable, zervez!

I added a comment regarding the header pin soldering (as coffeebot). I'll keep an eye out for the boards on your site, for sure!

acleone

Nice breakout boards, zervez.

nphillips: I didn't see the new reply email until today, sorry!  You're right about the 9-hour rollover bug.  I'll fix that straight away (lazy coding in the first place always bites you in the back).

As for the problems with 0012, it's because the new millis() function disables interrupts while running.  The library uses a few interrupts every time update() is called, so calling millis() right after an update might be the problem.  I'll try running a few updates without millis to see if that fixes anything.

nphillips

Quote
nphillips: I didn't see the new reply email until today, sorry!
Not a problem. Life and monetary restrictions have put my project on hold, anyway. It's good to see that you're still interested though!

Quote
(lazy coding in the first place always bites you in the back).
I'm all too familiar with that one.

nima

ok, thanks for taking a look at the 012 IDE issue.

Go Up