Go Down

Topic: ATtiny85 + TLC5940 (Read 6424 times) previous topic - next topic

ƎR

i didn't understand how you could manage a TLC5940 with an ATtiny, did you use a library?
Riccardo Ertolupi of the Vicenza Thunders Team: http://www.VicenzaThunders.com

fungus


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.

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

ƎR

great :) 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 ;)
Riccardo Ertolupi of the Vicenza Thunders Team: http://www.VicenzaThunders.com

fungus


great :) 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...

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

ƎR

you haven't published it in some website yet, do you?
Riccardo Ertolupi of the Vicenza Thunders Team: http://www.VicenzaThunders.com

funkyguy4000

It would be great if you could share the library.
Accelerate to 88 miles per hour.

fungus


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...
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

fungus

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


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

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

dc42


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

fungus

#24
Dec 27, 2012, 02:44 pm Last Edit: Dec 27, 2012, 05:28 pm by fungus Reason: 1


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? :) 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).

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

ƎR


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! ;)
Riccardo Ertolupi of the Vicenza Thunders Team: http://www.VicenzaThunders.com

ƎR

well, i tried it and it worked very well: http://www.youtube.com/watch?v=3Br7PhvEIF0
thank you for sharing it! ;)
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: [Select]
#if defined (__AVR_ATtiny85__) || (__AVR_ATtiny84__)
or is there some register settings to do?
thanks again ;)
Riccardo Ertolupi of the Vicenza Thunders Team: http://www.VicenzaThunders.com

fungus


well, i tried it and it worked very well: http://www.youtube.com/watch?v=3Br7PhvEIF0
thank you for sharing it! ;)


No problem.

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


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: [Select]
#if defined (__AVR_ATtiny85__) || (__AVR_ATtiny84__)
or is there some register settings to do?
thanks again ;)


I just tried it and there's a line in setup() that doesn't compile. The line is:
Code: [Select]

  TCCR1 = 0;


It should work if you replace that line with:

Code: [Select]

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

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

ƎR


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: [Select]

#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: [Select]

  TCCR1 = 0;


It should work if you replace that line with:

Code: [Select]

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

ok thank you, after i'll try that if i've time ;)
Riccardo Ertolupi of the Vicenza Thunders Team: http://www.VicenzaThunders.com

funkyguy4000

Whoa ?R, are those 2pin rgb fade leds or are those 4 pin rgb terminated leds?  They look to only have 2 pins.
Accelerate to 88 miles per hour.

Go Up