Pages: 1 [2] 3 4 ... 22   Go Down
Author Topic: Arduino Tiny  (Read 63410 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I'm working to get Arduino-Tiny up and running on an ATtiny85.  I think I have gotten as far as Burning the Bootload configuration to the ATtiny85 but am now stuck trying to upload my first sketch.  After the patch to AVRDUDE.CONF (see http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1274820597/90 reply #99, noting that reply #8 of this thread did not work for me either), I can successfully burn the bootloader config to the ATTiny85 (I think) with a "Done Burning Bootloader" in the IDE.  I am getting errors when I try to upload my first sketch.  I can compile my little blink.pde sketch, but when I upload, the errors I get in the IDE are:

Binary sketch size: 694 bytes (of a 8192 byte maximum)
java.lang.NullPointerException
   at processing.app.debug.AvrdudeUploader.getProgrammerCommands(Unknown Source)
   at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(Unknown Source)
   at processing.app.Sketch.upload(Unknown Source)
   at processing.app.Sketch.exportApplet(Unknown Source)
   at processing.app.Sketch.exportApplet(Unknown Source)
   at processing.app.Editor$DefaultExportHandler.run(Unknown Source)
   at java.lang.Thread.run(Thread.java:619)

I am hoping someone here can help me out.

Thanks,
George

Extra Background
My setup is Arduino-0021 on an Windows XP laptop.  I am trying to copy Coding Badly setup exactly so I am using a Pololu USB AVR programmer, which I like so far.  The configuration utility for this programmer (pgm03a_config.exe) runs and reports back the programmer serial number, and I get a ready to program status (flashing yellow led) when I have the target board hooked up and powered up so I think the hardware is all working.  Programmer shows up fine at COM5, with the optional TTL serial port showing on COM6 in the windows hardware device manager window.  My target board has an ATtiny85 installed, with no external crystal/resonator.  I wish to use the internal oscillator to clock the ATtiny85 at either 1 or 8 MHz.  The board has an LED hooked up to pin 2 of the ATTiny85.
 
« Last Edit: June 02, 2012, 09:30:11 am by MGeo » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Additional background #1:

C:\Program Files\arduino-0021\hardware\arduino\programmers.txt contents
Code:
avrisp.name=AVR ISP
avrisp.communication=serial
avrisp.protocol=stk500v1

avrispmkii.name=AVRISP mkII
avrispmkii.communication=usb
avrispmkii.protocol=stk500v2

usbtinyisp.name=USBtinyISP
usbtinyisp.protocol=usbtiny

parallel.name=Parallel Programmer
parallel.protocol=dapa
parallel.force=true
# parallel.delay=200

arduinoisp.name=Arduino as ISP
arduinoisp.communication=serial
arduinoisp.protocol=stk500v1
arduinoisp.speed=19200

pololu.name=Pololu USB AVR Programmer
pololu.communication=seria
pololu.protocol=avrispv2
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Additional Background #2:

excerpt from C:\Documents and Settings\gsmall\My Documents\Arduino\hardware\tiny\boards.txt
Code:
###########################################################################
#
# Example boards.txt from...
#
# http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1236434254/94#94
# http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1274754985/6#6
# http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1274820597/49#49
#
###########################################################################

attiny85at16.name=ATtiny85 @ 16 MHz  (external crystal; 4.3 V BOD)

# The following do NOT work...
# attiny85at16.upload.using=avrispv2
# attiny85at16.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
# attiny85at16.upload.protocol=avrispv2
# attiny85at16.upload.using=arduino:arduinoisp
attiny85at16.upload.using=pololu

attiny85at16.upload.maximum_size=8192

# Ext. Crystal Osc.; Frequency 8.0- MHz; Start-up time PWRDWN/RESET: 16K CK/14 CK + 65 ms; [CKSEL=1111 SUT=11]
# Brown-out detection level at VCC=4.3 V; [BODLEVEL=100]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]
# Serial program downloading (SPI) enabled; [SPIEN=0]

attiny85at16.bootloader.low_fuses=0xFF
attiny85at16.bootloader.high_fuses=0xD4
attiny85at16.bootloader.extended_fuses=0xFF
attiny85at16.bootloader.path=empty
attiny85at16.bootloader.file=empty85at16.hex

attiny85at16.bootloader.unlock_bits=0xFF
attiny85at16.bootloader.lock_bits=0xFF

attiny85at16.build.mcu=attiny85
attiny85at16.build.f_cpu=16000000L
attiny85at16.build.core=tiny
 
###########################################################################

attiny85at8.name=ATtiny85 @ 8 MHz  (internal oscillator; BOD disabled)

# The following do NOT work...
# attiny85at8.upload.using=avrispv2
# attiny85at8.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
# attiny85at8.upload.protocol=avrispv2
# attiny85at8.upload.using=arduino:arduinoisp
attiny85at8.upload.using=pololu

attiny85at8.upload.maximum_size=8192

# Default clock (slowly rising power; long delay to clock; 8 MHz internal)
# Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 64 ms; [CKSEL=0010 SUT=10]; default value
# Brown-out detection disabled; [BODLEVEL=111]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

attiny85at8.bootloader.low_fuses=0xE2
attiny85at8.bootloader.high_fuses=0xD7
attiny85at8.bootloader.extended_fuses=0xFF
attiny85at8.bootloader.path=empty
attiny85at8.bootloader.file=empty85at8.hex

attiny85at8.bootloader.unlock_bits=0xFF
attiny85at8.bootloader.lock_bits=0xFF

attiny85at8.build.mcu=attiny85
attiny85at8.build.f_cpu=8000000L
attiny85at8.build.core=tiny
 
###########################################################################

attiny85at1.name=ATtiny85 @ 1 MHz  (internal oscillator; BOD disabled)

# The following do NOT work...
# attiny85at1.upload.using=avrispv2
# attiny85at1.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
# attiny85at1.upload.protocol=avrispv2
# attiny85at1.upload.using=arduino:arduinoisp
attiny85at1.upload.using=pololu

attiny85at1.upload.maximum_size=8192

# Default clock (slowly rising power; long delay to clock; 8 MHz internal; divide clock by 8)
# Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 64 ms; [CKSEL=0010 SUT=10]; default value
# Divide clock by 8 internally; [CKDIV8=0]
# Brown-out detection disabled; [BODLEVEL=111]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

attiny85at1.bootloader.low_fuses=0x62
attiny85at1.bootloader.high_fuses=0xD7
attiny85at1.bootloader.extended_fuses=0xFF
attiny85at1.bootloader.path=empty
attiny85at1.bootloader.file=empty85at1.hex

attiny85at1.bootloader.unlock_bits=0xFF
attiny85at1.bootloader.lock_bits=0xFF

attiny85at1.build.mcu=attiny85
attiny85at1.build.f_cpu=1000000L
attiny85at1.build.core=tiny
 
###########################################################################

attiny45at8.name=ATtiny45 @ 8 MHz

# The following do NOT work...
# attiny45at8.upload.using=avrispv2
# attiny45at8.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
# attiny45at8.upload.protocol=avrispv2
# attiny45at8.upload.using=arduino:arduinoisp
attiny45at8.upload.using=pololu

attiny45at8.upload.maximum_size=4096

# Default clock (slowly rising power; long delay to clock; 8 MHz internal)
# Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 64 ms; [CKSEL=0010 SUT=10]; default value
# Brown-out detection disabled; [BODLEVEL=111]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

attiny45at8.bootloader.low_fuses=0xE2
attiny45at8.bootloader.high_fuses=0xD7
attiny45at8.bootloader.extended_fuses=0xFF
attiny45at8.bootloader.path=empty
attiny45at8.bootloader.file=empty45at8.hex

attiny45at8.bootloader.unlock_bits=0xFF
attiny45at8.bootloader.lock_bits=0xFF

attiny45at8.build.mcu=attiny45
attiny45at8.build.f_cpu=8000000L
attiny45at8.build.core=tiny
 
###########################################################################

attiny45at1.name=ATtiny45 @ 1 MHz

# The following do NOT work...
# attiny45at1.upload.using=avrispv2
# attiny45at1.upload.using=Pololu USB AVR Programmer

# The following DO work (pick one)...
# attiny45at1.upload.protocol=avrispv2
# attiny45at1.upload.using=arduino:arduinoisp
attiny45at1.upload.using=pololu

attiny45at1.upload.maximum_size=4096

# Default clock (slowly rising power; long delay to clock; 8 MHz internal; divide clock by 8)
# Int. RC Osc. 8 MHz; Start-up time PWRDWN/RESET: 6 CK/14 CK + 64 ms; [CKSEL=0010 SUT=10]; default value
# Divide clock by 8 internally; [CKDIV8=0]
# Brown-out detection disabled; [BODLEVEL=111]
# Preserve EEPROM memory through the Chip Erase cycle; [EESAVE=0]

attiny45at1.bootloader.low_fuses=0x62
attiny45at1.bootloader.high_fuses=0xD7
attiny45at1.bootloader.extended_fuses=0xFF
attiny45at1.bootloader.path=empty
attiny45at1.bootloader.file=empty45at1.hex

attiny45at1.bootloader.unlock_bits=0xFF
attiny45at1.bootloader.lock_bits=0xFF

attiny45at1.build.mcu=attiny45
attiny45at1.build.f_cpu=1000000L
attiny45at1.build.core=tiny
 
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


The entry in programmers.txt is missing a letter...

pololu.name=Pololu USB AVR Programmer
pololu.communication=serial
pololu.protocol=avrispv2
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


In the "boards.txt" file, change the "upload.using" entries for the ATtiny85 processor to these...

attiny85at16.upload.using=arduino:pololu

attiny85at8.upload.using=arduino:pololu

attiny85at1.upload.using=arduino:pololu


Please let me know if you do or do not get it working.  Thanks.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Coding Badly,

Thanks for the quick reply.

Checked programmers.txt, for some reason the version I pasted in dropped the l in serial, but my actual file has it spelled correctly.

Then I checked boards.txt, changed all the .upload.using entries from "=pololu" to "=arduino:pololu" as you recommended.

Success!!!  I have a blinking green LED on my ATtiny85 board.  Awesome.  I then changed the board to from 1 MHz to 8 MHz and burned the bootloader, recompiled and re-uploaded.  Success again.
 
I will now start exploring what I can do with the ATtinyX5s.  I need to hook up the TTL serial port on my Pololu programmer so I can get a serial monitor for debug.  Any questions or issues I will repost here.

So far the overall (your core + Pololu programmer) setup is Highly recommended.

Best Regards and thanks again.
George 
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Coding Badly,

Things are working great.  My next goal is to get ATtiny Arduino running as an I2C slave.

Out of curiosity, how did you discover the fix above?

Is the syntax for the Arduino configuration .txt files documented anywhere?  I have searched but as of yet no luck.

George
Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Things are working great.

Excellent!

Quote
My next goal is to get ATtiny Arduino running as an I2C slave.

There has been some discussion on the forum.  But, I've not done anything I2C so I won't be much help.  If you do get something working, please take the time to report about your success.  Even something as simple as "I got I2C slave working" is helpful to someone considering it as a solution.  At least they know it is possible.

Quote
Out of curiosity, how did you discover the fix above?

I truly have no idea.  It is a combination of experience (lots of mistakes trying to program ATtiny processors) and the way my brain works.

Quote
Is the syntax for the Arduino configuration .txt files documented anywhere?

Technically, it is documented by the fact that the source code is readily accessible.  I have not looked at the Arduino IDE source code so it is by observation that I found that "arduino:" syntax.

Quote
I have searched but as of yet no luck.

Sorry I can't be more help in your search.
Logged

Denver
Offline Offline
God Member
*****
Karma: 20
Posts: 779
Inactive - PM
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
next goal is to get ATtiny Arduino running as an I2C slave.

Quote
There has been some discussion on the forum.  But, I've not done anything I2C so I won't be much help.  If you do get something working, please take the time to report about your success.  Even something as simple as "I got I2C slave working" is helpful to someone considering it as a solution.  At least they know it is possible.

Kinda makes me wonder why I bother . . .
http://www.arduino.cc/playground/Code/USIi2c

or am I missing something?
Logged

"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom."
~ Clifford Stoll

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Kinda makes me wonder why I bother

Because you're a friendly helpful guy.  And because, even though we sometimes forgot about the work you've done, once we do remember we greatly appreciate it!   smiley-red   smiley-grin

Quote
or am I missing something?

In my case I really have not yet done anything with I2C and I could not remember if you had or had not tested operating as a slave.  I assumed @MGeo would easily be able to find your library and documentation and answer the question for himself.  After all, your stuff is the first and second hit on Google with the query string "i2c attiny85".
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Kinda makes me wonder why I bother . . .
http://www.arduino.cc/playground/Code/USIi2c

or am I missing something?

Keep the faith bHogan, I started with your library TinyWireS from that linked page.  You are just ahead of your time.

After a boatload of Google and ATtiny cores, I am stepping my way through getting ATtiny up and running with your TinywireS lib.  There are some questions that come up getting it going mainly associated with poorly documented areas for programmers, IDE config files and what not.   Sure would be great if the Arduino masters would just formally add the ATtiny to the platform.  I will report on my progress.

George
« Last Edit: May 07, 2011, 06:19:07 am by MGeo » Logged

Humboldt, CA
Offline Offline
Full Member
***
Karma: 2
Posts: 223
Arduino BBB
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just wanted to report in on my recent experiences:
Every thing worked great, except that for unknown reasons the bootloaders for attiny85 with internal oscillator (either of them) would not burn.
This is using ArduinoISP via a BBB, from IDE22, on ubuntu 11.04-64bit.  It programmed the attiny85 chips just fine, and by manually setting the fuses I was able to get the 8mhz I wanted.
Selecting the 8mhz board for uploading programs gets everything synced up nicely and it works great!

I'm very happy with it, it's almost nice that the bootloader didn't work for me as now I know how to set fuses smiley-grin


Anyway, thank you!
« Last Edit: May 14, 2011, 11:16:12 am by Bobnova » Logged

Global Moderator
Dallas
Online Online
Shannon Member
*****
Karma: 212
Posts: 13085
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Every thing worked great

Excellent!

Quote
except that for unknown reasons the bootloaders for attiny85 with internal oscillator (either of them) would not burn.

Uh oh.

Quote
This is using ArduinoISP via a BBB, from IDE22, on ubuntu 11.04-64bit

What is the error message?

Quote
I'm very happy with it, it's almost nice that the bootloader didn't work for me as now I know how to set fuses smiley-grin

That is a good thing.  The core sets the fuses to Brown Out Detector disabled (which is nice for battery gadgets) but I suspect is not appropriate for most applications.  Adjusting the fuse settings for the application is important.

Quote
Anyway, thank you!

You are welcome.  If you ever have comments, please don't be shy.
Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As promised I am reporting back on my attempts to use Coding Badly Arduino Tiny core together with BHogan TinyWireS lib to build an I2C slave on an ATTiny85.

After mucking around a bit I now have success!  Master is an Arduino Uno, and the slave is a minal breadboard with LED.  Slave code looks for a control code of 31d to turn the LED on, and 30d to turn it off.  It echos back the received char after adding 3 to it (to verify the slave can do perform an action on the code).

Attached is a photo of the setup (plus the Pololu USB Programmer used to program the ATTiny85), as well as a screen capture of the output)

Slave .PDE code:
Code:
/* ATtiny85 as an I2C Slave (G.Small, 02May11)
Example of ATtiny I2C slave receiving and sending data to an Arduino Uno master.
Gets data from master, adds 10 to it and sends it back.

ATMEL 6 PIN ISP CONNECTOR TOP VIEW:
                        +---+
                MISO  1 |o o| 2  +Vcc
(SCL, to UNO A5) SCK  3 |o o| 4  MOSI (SDA, to UNO A4)
              /RESET  5 |o o| 6  GND
                        +---+

ATMEL ATTINY45/ARDUINO:
                  +--\/--+
 Ain0 (D5) PB5  1 |      | 8  VCC
 Ain3 (D3) PB3  2 |      | 7  PB2 (D2) Ain1 INT0
 Ain2 (D4) PB4  3 |      | 6  PB1 (D1) pwm1
           GND  4 |      | 5  PB0 (D0) pwm0
                  +------+

TEST SLAVE BOARD SETUP:
                  +--\/--+
   (RESET) N/C  1 |      | 8  VCC (2.7-5.5V)
   (D3) to LED  2 |      | 7  (D2) I2C SCL (To UNO A5)
   (D4) to FET  3 |      | 6  (D1) to Servo I/O
           GND  4 |      | 5  (D0) I2C SDA (To UNO A4)
                  +------+  

UNO SETUP NOTES:
  Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of resolution.
  By default they measure from ground to 5 volts, it is possible to change the upper end of the
  range using the AREF pin and the analogReference() function. Also, some pins have specialized
  functionality:
  
  I2C: A4 (SDA) and A5 (SCL). Support I2C (TWI) communication using the Wire library.

Rx & Tx buffers set at 32 bytes - see usiTwiSlave.h
Credit due to Don Blake for the usiTwiSlave code.
*/

#include "TinyWireS.h"                          // wrapper class for I2C slave routines

#define TWI_slaveAddress  0x10                  // i2c slave address
#define LED_PIN           4                     // ATtiny Pin 3 (D4)

byte c = 30;

void setup(){
  pinMode(LED_PIN,OUTPUT);                      // for general DEBUG use
  LED_Flash(LED_PIN,2);                         // show it's alive
  TinyWireS.begin(TWI_slaveAddress);            // init I2C Slave mode
}

void loop(){
  if (TinyWireS.available()){                   // poll for I2C input
    c = TinyWireS.receive();                    // get the byte from master
    if (c == (31)) digitalWrite(LED_PIN, LOW);  //on
    if (c == (30)) digitalWrite(LED_PIN, HIGH); //off
    c = c + 3;                                  // add 10 to what's received
    TinyWireS.send(c);                          // send it back to master
  }
}

// LED blinker for status
void LED_Blink(byte pin, byte times){
  for (byte i=0; i< times; i++){
    digitalWrite(pin,LOW);
    delay (1000);
    digitalWrite(pin,HIGH);
    delay (1000);
  }
}

// LED flash for data (faster blinks than LED_blink)
void LED_Flash(byte pin, byte times){
  for (byte i=0; i< times; i++){
    digitalWrite(pin,LOW);
    delay (250);
    digitalWrite(pin,HIGH);
    delay (175);
  }
}
.


* DSCN0524.jpg (303.79 KB, 1632x1224 - viewed 93 times.)

* Arduino_ATTiny85_Slave.JPG (139.63 KB, 1440x900 - viewed 64 times.)
« Last Edit: May 21, 2011, 11:28:33 am by MGeo » Logged

Offline Offline
Jr. Member
**
Karma: 0
Posts: 64
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And below is the Master code running on the Uno.  It alternates between sending code 30d and 31d to the slave to toggle the slave LED, and echos what was sent and received to the serial monitor.

Code:
#include <Wire.h>

// Arduino Uno I2C: A4 (SDA) and A5 (SCL). Support I2C (TWI) communication using the Wire library

#define I2C_SLAVE_ADDR  0x10               // I2C slave address
#define LED_PIN         13                 // Uno LED Pin

byte x = 31;
byte rdata = 0;

void setup(){
  Wire.begin();                            // start I2C Bus as Master
  Serial.begin(38400);                     // start serial to send test output
  Serial.println("I2C Test Application");  // print out heading string to COM
  pinMode(LED_PIN, OUTPUT);                // set up LED for visual output
  LED_Blink(LED_PIN, 1);                   // show it's alive with 2 long flashes
}

void loop(){
  Serial.print("Sending x = ");
  Serial.print(x, DEC);

  LED_Flash(LED_PIN, 3);
  
  Wire.beginTransmission(I2C_SLAVE_ADDR);  // transmit to slave device
  Wire.send(x);                            // sends x
  Wire.endTransmission();                  // stop transmitting
  
  Wire.requestFrom(I2C_SLAVE_ADDR, 1);     // request single byte from slave

  if (Wire.available()){
    rdata = Wire.receive();
    LED_Flash(LED_PIN, 2);                   // flash out slave byte on LED
    Serial.print(" | Received x = ");
    Serial.println(rdata, DEC);                // print out slave byte to Serial monitor
  }
  else{
    Serial.println(" | Received nothing");  
  }
  
  if (x == 31)                                // toggle x control code
    x = 30;
  else
    x = 31;
  
  delay(500);                              // brief pause then loop again
}

// LED blinker for status
void LED_Blink(byte pin, byte times){
  for (byte i=0; i< times; i++){
    digitalWrite(pin,HIGH);
    delay (1000);
    digitalWrite(pin,LOW);
    delay (1000);
  }
}

// LED flash for data (faster blinks than LED_blink)
void LED_Flash(byte pin, byte times){
  for (byte i=0; i< times; i++){
    digitalWrite(pin,HIGH);
    delay (250);
    digitalWrite(pin,LOW);
    delay (175);
  }
}
« Last Edit: May 21, 2011, 11:27:55 am by MGeo » Logged

Pages: 1 [2] 3 4 ... 22   Go Up
Jump to: