About Here

This web blog is established for collecting useful information about building prototype with arduino or other applications. This page shuld help a designer with very basical technical cognition to build a working model or a prototyp for his design concept. We find prototyp or working model an excellent tool to test concept and understand it's usage in real condition (not only fantasy in mind). It's ofter very hard to realize every functions of a design concept. However it's our goal here to make this task easier.

What should be always keeped in mind is that we are not engineers and it's not our goal to design a perfect electron programme control. We are designers who are more willing to understand the users through prototype testing.

This web-site is still under construction and more information shall be collected. :)

Dec 17, 2013

Arduino ATtiny 84/85 (updated 2020/8/4)

ATtiny allows you to reduce the cost of your electronic prototype, even lower than Arduino Mini series. ATtiny84 or 85 is microcontroller from Atmel. ATtiny85 offers 6 I/O pins for communication and 8192 byte memory, and ATtiny 84 12 I/O pins and 8192 byte. You can use Arduino IDE to make a sketch and upload onto this tiny IC. To do that, you need to set up your Arduino as an ISP (In-System Programming).
I think, the original developers using ATtiny for Arduino projects are from High-Low Tech Lab of MIT (2009-2014). Visit their page for more information: http://highlowtech.org/ 
This post shows you how to use ATtiny84/85 for your project and other recent updates. 

ATtiny85


0. some feafures of ATtiny
_operating voltage: 2.7-5.5V (ATtiny25/45/85) / 1.8-5.5V (ATtiny25V/45V/85V)
_8-bit Timer

1. adding ATtiny into your Boards list in Arduino IDE
  open File> Preferences
  find the option Additional Boards Manager URLs and add "https://raw.githubusercontent.com/damellis/attiny/ide-1.6.x-boards-manager/package_damellis_attiny_index.json".
  click OK

an alternative way:
download Arduino ATtiny set here (http://code.google.com/p/arduino-tiny/), unzip the files, and follow the README file to install ATtiny cores into your Arduino program. Open your Arduino IDE (the arduino program), some new boards should now be seen in Tools>Board. 

2. set up Arduino Uno as your ISP for ATtiny:
You have to upload the example sketch named "ArduinoISP" by:
   open  file>Examples>11.ArduinoISP>ArduinoISP
   go tools>programmer>AVRISP mkll (the default setting)
   go tools>board> choose your board (Arduino Uno)
   go tools>SerialPort> choose the used USB port
   upload this sketch onto your arduino board

This sketch turns arduino into an AVRISP which allows you upload sketch onto ATtiny84/85 through arduino board. Arduino now uses pin 10 for slave rest, pin 11 for MOSI, pin 12 for MISO and pin 13 for SCK communication.

3. prepare your ATtiny microcontroller and your sketch
There is a dot on a corner of the ATtiny IC or a semicircle on an edge which indicates where the pin 1 is. The rest pins of the IC than are numbered countericlockwise (see below as an example).

 
You should make sure that your sketch is using the correct pin number. You have 6 I/O pins from 0 to 5. Pin 0 and 1 can be used for PWM. Pin 2-4 can be used for analog input (named A1 to A3; there is no A0 on ATtiny85). As you can see in the following diagram, for example, D2 can be called for digital I/O as pin "2" and for analog input as pin "A1". Use the correct name to call them in your sketch.
 
 
ATtiny 84 has 12 I/O pins. Define digital ouput pins from 0 to 11, analog output pins from 2 to 5 and (analog) inputs form A0 to A7. Similar to Attiny 85 you should note the pins with different "names" for different functions.

 
4. upload your sketch
If your sketch is ready, you can upload it onto your ATtiny microcontroller. First, connect ATtiny to Arduino as following:
  • arduino pin 10 to slave reset (ATtiny85 on pin1, ATtiny 84 on pin4)
  • arduino pin 11 to MOSI (ATtiny 85 on pin 5, ATtiny 84 on pin 7)
  • arduino pin 12 to MISO (ATtiny 85 on pin 6, ATtiny 84 on pin 8)
  • arduino pin 13 to SCK (ATtiny 85 on pin7, ATtiny 84 on pin 9)
  • arduino Gnd to GND
  • arduino 5V to VCC
Besides, put a 10 microfarad capacitor between Gnd and reset pin on arduino. (capacitor is polarized, negative to Gnd).

Now, you have to use arduino as ISP to upload sketch by:
   go tools>programmer>Arduino as ISP (Don't forget to set it back for your other projects!)
   go tools>board   choose the type of your ATtiny microcontroller with the desired settings
When choosing the board, if you are not use an external clock (oscillator), you should choose the option with "1 MHz, internal oscillator, BOD disabled."
   go tools>SerialPort  to choose the used USB port
   upload the sketch

If you receive "avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85" and "avrdude: please define PAGEL and BS2 signals in the configuration file for part ATtiny85" after uploading, just ignore these. It works fine.


I built a "shield" so that I can easily plug the ATtiny microcontroller onto the shield and this shield onto Arduino for sketch upload. This could be a convenient tool for you in practice. When building this, you may want to make a mark on your IC holders to inform yourself about the direction of your ATtiny. 

Use ATtiny to control Servo

Not all functions work on ATiny. The following functions are reported to be supported by Arduino Tiny:
  • pinMode()
  • digitalWrite()
  • digitalRead()
  • analogRead()
  • analogWrite()
  • shiftOut()
  • pulseIn()
  • millis()
  • micros()
  • delay()
  • delayMicroseconds()
  • SoftwareSerial
Otherweise, not all libraries are working on ATtiny chip, for example, the servo library. We tried the  approaches in the following, but, til now, they are not working on Arduino IDE. 

References:
http://hlt.media.mit.edu/?p=1229
http://highlowtech.org/?p=1229
http://www.3bm.de/2013/09/17/attiny84-mit-arduino-uno-programmieren/
https://forum.sparkfun.com/viewtopic.php?f=32&t=34507  (this is the key reference for this text to solve the problem of "avrdude: stk500_getsync(): sync error, resp=0x00")
http://forum.arduino.cc/index.php?topic=150690.0 and many other reports (to solve the problem of "arduino tiny did not find any usb device 'usb'")
Solution for simple servo movement http://tronixstuff.com/2011/11/23/using-an-attiny-as-an-arduino/
Solution by using SofrwareServo Library:
http://projectsfromtech.blogspot.de/2013/03/attiny85-servo-softwareservo-library.html
http://letsmakerobots.com/node/36523
http://playground.arduino.cc/ComponentLib/servo

No comments:

Post a Comment