ATtiny85 + TLC5940

I just got a Tiny85 working with a TLC5940, here it is controlling a couple of RGB LEDs:

Unfortunately it takes all the Tiny85's pins at the moment. I think I can free up 2 pins but it'll have to wait a couple of days....

Very nice! How did you do it?

I don't know how the OP did it, but this is pretty easy to so if you buy an AVR ISP II which are $35. You can write the program in the Arduino environment, taking care to only use the pins that exist on the ATTiny, and upload it using Atmel Studio. You provide a 6 pin header that goes to +5V, GND, and four pins on the chip (RST, MOSI, SCK, and MISO) There are other bits of software which will do this too and you can use an Arduino as a programmer but I found that AVR ISP II (cheap) and AVR Studio (free) seem to be a good way to achieve it.

http://store.atmel.com/PartDetail.aspx?q=p:10500054

The six wires coming off the board to the bottom left is the OP's programming interface, the AVR ISP uses a 6-conductor ribbon connector. Possibly he is using the arduino route or an Atmel Dragon.

brs0906:
Very nice! How did you do it?

I got a cheap ISP programmer off eBay (search for "usbtinyisp") and connected it to the ATtiny85. That's the wires you see coming in from bottom-left. I literally just poked patch wires into the ISP connector to connect it to the breadboard.

After that you set up the Arduino IDE and start programming as normal! I followed the instructions on this page: http://hlt.media.mit.edu/?p=1695

I did it!

I got the TLS5940 control down to three pins on my Tiny85. It was much easier than I thought, took me ten minutes to adapt the previous version.

I now have two pins free. I'm going to connect two potentiometers as input so I can set a color range for some RGB LEDs. The LEDs will fade around within that color range. I just need to figure out how to read the chip's ADC under interrupts (the TLC driver uses 100% CPU to drive the 5940).

(Edited this thread to change all images to attachments so they'll be visible for eternity, even if my server dies...)

That's good. But I don't think the code is really using 100% of the CPU in the normal sense of the idea. The CPU is always running at 100% - it's just running the main loop code over and over - it's not a infinite length blocking call or anything like that. If you put something in your main loop to read the pot you will be fine, it will probably be reading that pot a few thousand times a second.

What is that blue box anyway, is that a fancy despiking cap? I don't have any that look like a blue box, that is new to me.

JoeN:
That's good. But I don't think the code is really using 100% of the CPU in the normal sense of the idea. The CPU is always running at 100% - it's just running the main loop code over and over - it's not a infinite length blocking call or anything like that. If you put something in your main loop to read the pot you will be fine, it will probably be reading that pot a few thousand times a second.

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

I got the pot working. I couldn't use analogRead() because it blocks until the conversion finishes. I need conversion in parallel so I can keep the PWM clock going. It wasn't too hard to program the ADC directly though.

Register level AVR programming is turning out to be very easy, I almost prefer it to using the Arduino library (which is VERY inefficient BTW). You can do some cool stuff, too, eg. flip the state of digital output pins directly (no read-modify-write needed) using the "PIN" register. I can't think why they didn't include a function in the library to use that (maybe some early AVR chips can't do it)

JoeN:
What is that blue box anyway, is that a fancy despiking cap? I don't have any that look like a blue box, that is new to me.

It's a 10uF polyester capacitor, they come in little boxes.

Its there for decoupling. The LEDs are common anode and draw power from that rail (the yellow wires). I'm going to connect 15 LEDs (5xRGB) and they might all switch on at once...

would you be able to give us link to the ebay page you bought the programmer at?

I've been thinking about trying some of these, They are the same thing you are doing, but in a nice little package.
After you've programmed it, you cold cut off the tab and and make it even smaller.

First an update:

Here's the project built into a final PCB.

I put in a six-pin ISP header so I can update the software if I want to. All it needs now is a pretty box.

TinyTLC.jpg

funkyguy4000:
would you be able to give us link to the ebay page you bought the programmer at?

I don't know the sellers personally so I'm not going to recommend anybody (maybe I was the only lucky buyer they ever had and it would go horribly wrong for you).

Just search for "usbtinyisp" on ebay and look for "version 3.0" on the thumbnail images. My seller is in the top three results - you've got pretty good odds of getting the same one!

The ISP itself isn't perfect, it doesn't work after the computer goes to sleep then wakes up. It's probably a Windows 7 thing, I dunno.

Anyway... I added a reset button to mine. Whenever it doesn't work I just press that and it fixes itself. It connects the chip's reset line to GND under the board - see attached image.

Hippynerd:
Teensy Tiny Arduino Board With An ATtiny85 | Hackaday
I've been thinking about trying some of these, They are the same thing you are doing, but in a nice little package.
After you've programmed it, you cold cut off the tab and and make it even smaller.

Hmmm...looks cute but it's quite expensive for just a chip on a PCB. Plus it uses a bootloader, ick!

I just bought some of these on eBay: http://www.ebay.com/itm/190747889648

I haven't used one yet but six holes wide is just enough for a Tiny85 and a connecting wire along each side (see attached image). 4 holes long is enough for the Tiny85 and I can snip the boards to any length I want for individual projects.

The Digispark looks about 8x6 holes big - a PCB that huge would have half of it free for extra components. :slight_smile:

(wish my cellphone camera had a better macro...)

It looks like you may be able to use that board in a usb slot (similar to the one I posted), you may need trim down the sides a little, but it looks like it may plug right into USB.

I thought they were a bit spendy too. I was able to find knock off arduinos for that price.

someone made a neat LED matrix stamp for the digispark, I thought it was pretty neat also

Hippynerd:
It looks like you may be able to use that board in a usb slot (similar to the one I posted), you may need trim down the sides a little, but it looks like it may plug right into USB.

You mean those little connector strips on the end? Maybe. The spacing is right...

Hippynerd:
someone made a neat LED matrix stamp for the digispark, I thought it was pretty neat also

Have you seen these?

those are freaking awesome! They would make nice cufflinks or maybe rings too.

Sigh, too many LED projects, not enough time.

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

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

?R:
did you use a library?

I wrote my own library.

great :slight_smile: 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 :wink:

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

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

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