Pages: [1] 2 3   Go Down
Author Topic: ATtiny85 + TLC5940  (Read 4732 times)
0 Members and 1 Guest are viewing this topic.
Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 119
Posts: 4591
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


* tiny85tlc.jpg (233.43 KB, 987x695 - viewed 69 times.)
« Last Edit: November 02, 2012, 06:47:11 am by fungus » Logged

No, I don't answer questions sent in private messages...

0
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Very nice! How did you do it?
Logged

More Cowbell
Offline Offline
Edison Member
*
Karma: 11
Posts: 1029
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Vexatious Sampler

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 119
Posts: 4591
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


* tinyisp.jpg (112.15 KB, 818x439 - viewed 31 times.)
« Last Edit: November 02, 2012, 06:47:46 am by fungus » Logged

No, I don't answer questions sent in private messages...

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 119
Posts: 4591
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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



* teeny5940.jpg (89.1 KB, 761x367 - viewed 53 times.)
« Last Edit: November 02, 2012, 06:49:59 am by fungus » Logged

No, I don't answer questions sent in private messages...

More Cowbell
Offline Offline
Edison Member
*
Karma: 11
Posts: 1029
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
« Last Edit: October 03, 2012, 11:39:36 pm by JoeN » Logged

Vexatious Sampler

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 119
Posts: 4591
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)

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

No, I don't answer questions sent in private messages...

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

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

Accelerate to 88 miles per hour.

Eugene, Oregon
Offline Offline
Sr. Member
****
Karma: 9
Posts: 388
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

http://hackaday.com/2012/08/13/teensy-tiny-arduino-board-with-an-attiny85/
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.
Logged


Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 119
Posts: 4591
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 (101.26 KB, 590x445 - viewed 54 times.)
« Last Edit: November 02, 2012, 06:45:28 am by fungus » Logged

No, I don't answer questions sent in private messages...

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 119
Posts: 4591
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.



* isp_reset.jpg (127.46 KB, 1087x573 - viewed 45 times.)
« Last Edit: November 02, 2012, 06:45:00 am by fungus » Logged

No, I don't answer questions sent in private messages...

Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 119
Posts: 4591
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://hackaday.com/2012/08/13/teensy-tiny-arduino-board-with-an-attiny85/
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. smiley


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


* tinypcb.jpg (77.45 KB, 695x446 - viewed 38 times.)
« Last Edit: November 02, 2012, 07:19:28 am by fungus » Logged

No, I don't answer questions sent in private messages...

Eugene, Oregon
Offline Offline
Sr. Member
****
Karma: 9
Posts: 388
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged


Valencia, Spain
Offline Offline
Faraday Member
**
Karma: 119
Posts: 4591
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


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

Have you seen these?

http://hackaday.com/2012/10/12/led-matrix-pendants/

Logged

No, I don't answer questions sent in private messages...

Eugene, Oregon
Offline Offline
Sr. Member
****
Karma: 9
Posts: 388
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Sigh, too many LED projects, not enough time.
Logged


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