What can the ATTiny85 do?

I recently ordered some ATMegas to play around with but while I was looking around I found some ATTiny85 chips in the shop. For a dollar apiece I thought what the heck, they're cool and small, so a bought a few of them. After doing some research on them after the fact I've found a few things about them that make them cool buys, one being they have an Arduino compatible bootloader (not included) and can be programmed by the Arduino via ArduinoISP. This makes the great for these small projects where a full Mega isn't required.

That being said it seems like there are a few things that I would like to be able to do with them that either can't or just have very little documentation about. My main issue is controlling shift registers and LED drivers. The ATTiny support does have shiftOut() capabilities but because of the number and types of pins (and possibly memory and storage) doesn't seem to support the ShiftPWM(http://www.elcojacobs.com/shiftpwm/) library I enjoy using for PWM over shift registers.

This led me to look at LED drivers such as the TL5940 to drive multiple LEDs, with PWM being a huge plus, but again there seem to be issues with the chip's support for SPI. There seemed to be solutions but not with nearly enough explaination to wrap my head around it.

So really what I want to know is what do people know about solutions to my problems and maybe just some other ATTiny project you've done or seen. It would be nice to use this tiny chip for some cool stuff.

Doesn't the ATtiny85 have SPI hardware and a free timer? Is that not enough to run ShiftPWM?

ATtinys can do a lot of what ATmegas can. Pins are limited of course. They have fewer peripheral features than the ATmegas, and those features are not all as sophisticated. Still they work well within their limits and are a lot of fun to work with.

I am not aware that ATtinys support bootloaders. They can be programmed via the Arduino IDE using an ICSP programmer or using an Arduino running the ArduinoISP sketch.

There are several "cores" available to enable the IDE to program the ATtinys. I've mostly used this one and can recommend it. I've used this one to a lesser extent, but it was also easy to install and seemed to work fine (I only ran a couple example sketches IIRC).

I'd be interested to know where ATtiny85s can be had for a dollar. Last ones I bought (from Mouser) were around $1.40 in quantities of 10 IIRC.

Ah okay, I guess I was mistaken that those IDE hacks were bootloaders. I hadn't seen that first one you posted so I'll take a look into that.

From what I read the ATTiny85 doesn't have SPI but can emulate it somehow. Until I find out a definitive answer to thatI have to assume that it can't run ShiftPWM.

Also I checked Mouser just to make sure I had my numbers right and the ATTiny85-20PU DIP is actually 1$(CAD) in quantities of 1. http://ca.mouser.com/ProductDetail/Atmel/ATtiny85-20PU/?qs=8jWQYweyg6OOxtot0UtUEqrf9r0RO67EQK4XVLDlbMc%3D

Jack, do you have any links to projects you did with the ATTinys?

paultyoung:
one being they have an Arduino compatible bootloader (not included)

No bootloader.

and can be programmed by the Arduino via ArduinoISP

Yup. Uploaded a frequency test just seconds ago.

This led me to look at LED drivers such as the TL5940 to drive multiple LEDs, with PWM being a huge plus, but again there seem to be issues with the chip's support for SPI. There seemed to be solutions but not with nearly enough explaination to wrap my head around it.

This may help...

paultyoung:
Until I find out a definitive answer to thatI have to assume that it can't run ShiftPWM.

Looks like the Attiny85 has two counters so you should be able to do PWM quite easily. That's nothing to do with SPI.

I would be surprised if you can't do SPI, because you program it using SPI.

I understand PWM is possible with the basic chip as is, the datasheet indicates two PWM pins if I recall. The issue with ShiftPWM is that it requires specifics pins to work correctly. Because the ATTiny85 lacks a lot of these pins I'm not sure it can be ported to the smaller chip. Maybe it's just a matter of digging around in the code or the datasheet to see what needs to be done to get it to work.

@CD Are you saying that the I2C protocol can be used in place of SPI for controlling these types of chips? Or that they are basically the same?

paultyoung:
the datasheet indicates two PWM pins if I recall

There are four. One of the four is inverted.

@CD Are you saying that the I2C protocol can be used in place of SPI for controlling these types of chips?

ATtiny processors have "hardware assisted" I2C -or- SPI communications. The assistance is provided by a single subsystem; the Universal Serial Interface (USI).

Maybe this will bring some clarity...

Or that they are basically the same?

No, they are not basically the same.

Alright thanks for pointing this stuff out. When it comes to very low level hardware stuff I have no idea what's going on.

It seems that if I want to play with these chips using Arduino IDE to code them I best stick with the supported ATMega family. I probably am looking too far ahead for projects on the ATTiny considering what I know about working with them. Small steps for the next while.

Oh I do have another question about the ATTiny. Because of it's small size and application to small projects, does it run well on ~3.3V? Being able to reduce the size of the battery would be nice to shrink a project.

paultyoung:
Alright thanks for pointing this stuff out. When it comes to very low level hardware stuff I have no idea what's going on.

It seems that if I want to play with these chips using Arduino IDE to code them I best stick with the supported ATMega family. I probably am looking too far ahead for projects on the ATTiny considering what I know about working with them. Small steps for the next while.

Oh I do have another question about the ATTiny. Because of it's small size and application to small projects, does it run well on ~3.3V? Being able to reduce the size of the battery would be nice to shrink a project.

Don't be scared off, it literally took me just minutes to download either the Arduino-Tiny or the HLT core, install it, and have something simple (blink sketch) programmed into an ATtiny85 with an ICSP programmer. I was impressed by how quick and easy it was!

There are two flavors of the ATtiny, for example the ATtiny85-20PU can run up to 20MHz but requires 2.7V to 5.5V. The ATtiny85V-10PU can only run up to 10MHz but only needs 1.8V to 5.5V. So the latter is probably the better choice to run on a 3V battery.

Sorry, I don't have any links to 'tiny projects, I've only played with them, really. Nothing too serious. Search around the forum and you might find some though. Also, as ever, GIYF XD

Oh don't you worry, I think I just have to take a step back and start small. I realize it works differently than the Megas so I'll just have to start with the basic blinking and work up to bigger and better projects as I get an understanding for it. As I said I bought some ATMegas to build into things, so what the ATTinys can't do, they surely can.

What can the ATTiny85 do?

Just to inspire you:

http://www.ladyada.net/make/tvbgone/

This gadget turns off around 230 different TVs (eg. in shopping malls) and is based around the Attiny85. That requires PWM output for the IR codes, and enough memory to store all those codes, make decisions etc. Pretty impressive.

I'm looking at trying an ATtiny85 project and it would be handy to be able to use the Arduino IDE.

I gather that the ATtiny cores don't necessarily support all the features of a full '328 version. However, does anyone have an idea of what is and is not supported for Arduino on an ATtiny? Direct port access (port B obviously), for example, or sleep modes, or turning off subsystems such as the ADC? I'm not entirely sure whether those are controlled by the Arduino IDE or by some deeper level within the compiling process even for an Arduno but they would be particularly useful for small battery-powered ATtiny projects.

Any advice appreciated.

Sleep modes and turning off subsystems/peripherals are supported, since these are just controlled via setting registers. See the datasheet. Also AVR-Libc has support for power management and sleep modes (#include <avr/sleep.h>), see the AVR-Libc user manual for more info.

Thanks Jack

I had seen from the datasheet that the sleep modes etc were just register settings but it's a case of how to set them! I'll look into LibC. There aren't all the same sleep modes on the ATtiny as on the ATMega328 but maybe it can handle both types of chip.

Yes it can, I've programmed sleep modes on both the ATtiny85 and the ATmega328P from the Arduino IDE. I use the Arduino-Tiny core with the IDE for programming the ATtiny: Google Code Archive - Long-term storage for Google Code Project Hosting.

Magic - thanks Jack. I'll try that core (I had been using one from HighLowTech) and LibC.

Another idea is since the ATtiny85 has 4 PWM pins (or maybe 6, I can't remember), you can control a TLC5940 with it, which happens to have a library for it and is capable of outputting 16 PWM channels, which can be used for leds and/or servos. If you don't wanna use it for that, then ladyada has lots of ideas.

I thought it would be best to post in this thread instead of starting a new one as I'm not sure if i can use them all.

I have been looking at a few different variations of this chip.

Breaking down the model number into a few bits
ATtiny[45] [v]-[10] [PU]

[25]/[45]/[85] As far as I can tell this refers to chips with slightly different functionality.
[v] Different speed grade. V means 0-4MHz, no v 0-10MHz not sure what that means as I thought the next number is clock speed
[10] Can be 10 or 20. Clock speed in MHz
[PU] Package type, either through hole or SMT.

I'm currently using the guide of "Shrinkifying" your Arduino project.

I think the 2nd number in the model number won't matter as by the look of it the chip has an internal clock.

So what I'm getting at is. For the "Shrinkify" project can I use any version of the ATtiny45 or ATtiny85 as long as its not one of the "V" versions? or can I use any of them.

Many thanks.

cjnewbs:
I thought it would be best to post in this thread instead of starting a new one as I'm not sure if i can use them all.

Hello cjnewbs,

The 25/45/85 differ only in the amount of memory. 2K/4K/8K bytes of flash, but also 128/256/512 bytes of EEPROM and SRAM.

The "V" versions can operate from 1.8 to 5.5 volts, their max clock speed is 10MHz.

The "non-V" versions can operate from 2.7 to 5.5 volts, their max clock speed is 20MHz.

The datasheet is your friend :smiley: See the first page for a summary of features, including the memory sizes.

See section 21.3 for clock speed vs. supply voltage.

See section 25 "Ordering Information" for a breakdown of all the part numbers including package types.