Pages: 1 2 [3] 4 5 ... 18   Go Down
Author Topic: Library for TLC5940 16-channel PWM chip  (Read 31082 times)
0 Members and 1 Guest are viewing this topic.
Seattle, WA
Offline Offline
Jr. Member
**
Karma: 1
Posts: 81
Arduino rocks my socks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
Slowly Developing
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Bingo. Thanks.
Logged


0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
Slowly Developing
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#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()
« Last Edit: September 13, 2008, 10:01:25 am by nphillips » Logged


0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
Slowly Developing
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Code:
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.
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
I love YaBB 1G - SP1!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
Slowly Developing
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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. smiley-wink

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 :/
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
I love YaBB 1G - SP1!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
I love YaBB 1G - SP1!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

"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
Logged

Austin, TX USA
Offline Offline
God Member
*****
Karma: 4
Posts: 997
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
Slowly Developing
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 smiley-wink
Logged


Malmo, Sweden
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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...
« Last Edit: October 06, 2008, 09:27:05 am by zervez » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
Slowly Developing
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged


Seattle, WA
Offline Offline
Jr. Member
**
Karma: 1
Posts: 81
Arduino rocks my socks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 70
Slowly Developing
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
I love YaBB 1G - SP1!
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Pages: 1 2 [3] 4 5 ... 18   Go Up
Jump to: