Pages: 1 [2] 3   Go Down
Author Topic: ATtiny85 + TLC5940  (Read 5987 times)
0 Members and 1 Guest are viewing this topic.
Camisano Vicentino (VI), Italy
Offline Offline
God Member
*****
Karma: 5
Posts: 956
ƎR like no other.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

i didn't understand how you could manage a TLC5940 with an ATtiny, did you use a library?
Logged

Riccardo Ertolupi of the Vicenza Thunders Team: http://www.VicenzaThunders.com

Valencia, Spain
Online Online
Faraday Member
**
Karma: 152
Posts: 5752
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

i didn't understand how you could manage a TLC5940 with an ATtiny

ATtinys have most of the capabilities of the bigger chips, just less pins.

did you use a library?

I wrote my own library.

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Camisano Vicentino (VI), Italy
Offline Offline
God Member
*****
Karma: 5
Posts: 956
ƎR like no other.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

great smiley i was reading that there are some problems with SPI on attinys... Did you solved them? did you modify the TLC library for arduino or did you make a new one? Is that library public?
And Which core did you use to program attiny?
Thanks for the info smiley-wink
Logged

Riccardo Ertolupi of the Vicenza Thunders Team: http://www.VicenzaThunders.com

Valencia, Spain
Online Online
Faraday Member
**
Karma: 152
Posts: 5752
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

great smiley i was reading that there are some problems with SPI on attinys... Did you solved them?

The standard Arduino SPI library probably doesn't work, no. The tinys don't have SPI, they have USI (which is hardware support for SPI, I2C, etc.)

did you modify the TLC library for arduino or did you make a new one? Is that library public?

It's a new library. I can send you a copy, no problem...

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Camisano Vicentino (VI), Italy
Offline Offline
God Member
*****
Karma: 5
Posts: 956
ƎR like no other.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

you haven't published it in some website yet, do you?
Logged

Riccardo Ertolupi of the Vicenza Thunders Team: http://www.VicenzaThunders.com

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1001
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It would be great if you could share the library.
Logged

Accelerate to 88 miles per hour.

Valencia, Spain
Online Online
Faraday Member
**
Karma: 152
Posts: 5752
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you haven't published it in some website yet, do you?

Nope.

It would be great if you could share the library.

Watch this space...
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Valencia, Spain
Online Online
Faraday Member
**
Karma: 152
Posts: 5752
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, here's a copy of my library...hope somebody finds it useful!


http://www.artlum.com/arduino/tinytlc.html

Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

United Kingdom
Offline Offline
Tesla Member
***
Karma: 227
Posts: 6639
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The CPU spends most of its time generating a clock output on a pin at about 4MHz (the tlc5940 needs a clock signal for the PWM). That's 100% in my book...

Why not use one of the 2 counter/timers in the ATtiny85 to generate the 4MHz clock?
Logged

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

Valencia, Spain
Online Online
Faraday Member
**
Karma: 152
Posts: 5752
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The CPU spends most of its time generating a clock output on a pin at about 4MHz (the tlc5940 needs a clock signal for the PWM). That's 100% in my book...

Why not use one of the 2 counter/timers in the ATtiny85 to generate the 4MHz clock?

V1.0 of the library did that... but using timers to generate the signals needs both timers and all five I/O pins to make it work. I wanted to get it down to three pins so I could attach a couple of potentiometers/switches/whatever. You could even use a timer to play music on one of the other pins if you wanted to.

Besides, what would you do with all those extra CPU cycles? smiley In real life you'd probably only use 1% of them anyway (especially if you can't attach any external devices because you ran out of I/O pins - that kinda limits your processing to basic color sequencing).


Edit: I guess if you want to chain a lot of TLC5940s together the CPU power needed to update them all might become significant - even for basic color fades. In that case I'd dig out the v1.0 version of the library (and use a Tiny84 if I needed some free pins).

« Last Edit: December 27, 2012, 11:28:59 am by fungus » Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Camisano Vicentino (VI), Italy
Offline Offline
God Member
*****
Karma: 5
Posts: 956
ƎR like no other.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

OK, here's a copy of my library...hope somebody finds it useful!
http://www.artlum.com/arduino/tinytlc.html
thank you very much! i will try it asap! smiley-wink
Logged

Riccardo Ertolupi of the Vicenza Thunders Team: http://www.VicenzaThunders.com

Camisano Vicentino (VI), Italy
Offline Offline
God Member
*****
Karma: 5
Posts: 956
ƎR like no other.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

well, i tried it and it worked very well:
thank you for sharing it! smiley-wink
i had some problems because you suggested not to use millis and delays, but i see that the problems are caused only by delays, so we can use millis and micros... we just need to do the update method very often, right?
i've a question, i'm not an expert of making libraries, but to make this library work in an attiny84 do i just need to add this line?
Code:
#if defined (__AVR_ATtiny85__) || (__AVR_ATtiny84__)
or is there some register settings to do?
thanks again smiley-wink
Logged

Riccardo Ertolupi of the Vicenza Thunders Team: http://www.VicenzaThunders.com

Valencia, Spain
Online Online
Faraday Member
**
Karma: 152
Posts: 5752
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

well, i tried it and it worked very well:
thank you for sharing it! smiley-wink

No problem.

It's fun to think that the teeny chip in the corner is driving something that many LEDs... smiley

i had some problems because you suggested not to use millis and delays, but i see that the problems are caused only by delays, so we can use millis and micros... we just need to do the update method very often, right?

I don't think millis() will do anything useful. I turned off the hardware timer in setup() (if it's ticking then there's a bug!)

Time spent in between calls to update() is time the LEDs aren't lit up. I think you'd have to do a lot before you notice them get visibly dimmer, but bear it in mind.

i've a question, i'm not an expert of making libraries, but to make this library work in an attiny84 do i just need to add this line?
Code:
#if defined (__AVR_ATtiny85__) || (__AVR_ATtiny84__)
or is there some register settings to do?
thanks again smiley-wink

I just tried it and there's a line in setup() that doesn't compile. The line is:
Code:
  TCCR1 = 0;

It should work if you replace that line with:

Code:
#if defined (__AVR_ATtiny85__)
  TCCR1 = 0;
#else
  TCCR1A = TCCR1B = 0;
#endif
Logged

No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

Camisano Vicentino (VI), Italy
Offline Offline
God Member
*****
Karma: 5
Posts: 956
ƎR like no other.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't think millis() will do anything useful. I turned off the hardware timer in setup() (if it's ticking then there's a bug!)

Time spent in between calls to update() is time the LEDs aren't lit up. I think you'd have to do a lot before you notice them get visibly dimmer, but bear it in mind.
yes i noticed that, and i used millis and micros to synchronize the duration of functions and other things, i think it easier to use than the method that you used in your example code... i do something like this, and it acts like a delay, but it's useful for other things too:
Code:
#define TIME 100
...
_time=millis();
while(millis()- _time < TIME) tlc5940.update();

I just tried it and there's a line in setup() that doesn't compile. The line is:
Code:
  TCCR1 = 0;

It should work if you replace that line with:

Code:
#if defined (__AVR_ATtiny85__)
  TCCR1 = 0;
#else
  TCCR1A = TCCR1B = 0;
#endif
ok thank you, after i'll try that if i've time smiley-wink
Logged

Riccardo Ertolupi of the Vicenza Thunders Team: http://www.VicenzaThunders.com

Wisconsin
Offline Offline
Edison Member
*
Karma: 4
Posts: 1001
I LOVE THIS STUFF!!!!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Whoa ƎR, are those 2pin rgb fade leds or are those 4 pin rgb terminated leds?  They look to only have 2 pins.
Logged

Accelerate to 88 miles per hour.

Pages: 1 [2] 3   Go Up
Jump to: