Pages: 1 2 [3] 4 5 ... 8   Go Down
Author Topic: ATTiny85 port (work in progress)  (Read 14320 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Full Member
***
Karma: 6
Posts: 200
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just hadn't seen anybody mention anything about stuff besides the attiny85. I'll try harder to get this working later.

EDIT:
I got rid of some errors by changing simple stuff (like trying to identify the chip as attiny85v and not attiny85). Now I get
Code:
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/pins_arduino.c:49: error: conflicting types for 'port_to_mode_PGM'

/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/pins_arduino.h:54: error: previous declaration of 'port_to_mode_PGM' was here

/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/pins_arduino.c:55: error: conflicting types for 'port_to_output_PGM'

/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/pins_arduino.h:56: error: previous declaration of 'port_to_output_PGM' was here

/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/pins_arduino.c:61: error: conflicting types for 'port_to_input_PGM'

/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/pins_arduino.h:55: error: previous declaration of 'port_to_input_PGM' was here

Have you gotten around this yet?
« Last Edit: May 30, 2010, 12:31:16 pm by wyager » Logged

Toronto, Canada
Offline Offline
Full Member
***
Karma: 0
Posts: 144
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I want to use a Tiny45 for a tiny robot that uses 3 servos and 2 LDR sensors. For that I need the analog conversion to work and perhaps software servo, or I guess I'll just generate the servo pulses in my code, because the Servo library uses Timer1 that is 16bit in the mega, but 8 bit in the tiny. 8 bit PWM does not give a good enough resolution for servos.

So, I need to find out how to make it possible to compile and upload the sketches from the IDE (windows 7). I have tried in the past to port a Tiny861 but failed due to numerous libraries that do not work properly. I will be using a AVR ISP programmer to upload the sketches. Can someone point me what files I need to modify to make this work?

Thank you in advance.
Logged


Amsterdam
Offline Offline
Full Member
***
Karma: 1
Posts: 139
he's looking at you, kiddy...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

@Wyager: i did'nt have those errors so i cannot tell. at the moment i'm fixing tone.cpp. a lot to do with remapping timers because the attiny heas less. i think i fixed analogread pwm and analogwrite, but still without hardware proof.
Logged

--
"We're all in this together..."

USA
Offline Offline
Jr. Member
**
Karma: 4
Posts: 92
If you can't fix it with a hammer, it must be an electrical problem.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

attiny85 + avrstudio + avrdude = much less pain.
Logged


0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 55
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

have you seen this port
http://sites.google.com/site/elettronicaarduinoesperimenti/Home/arduino-ide-and-attiny45
it should be vary similar to this one
Logged

0
Offline Offline
Full Member
***
Karma: 6
Posts: 200
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That last one there worked for me, it was very simple to change boards.txt. I have to actually try putting it on the chip though, I only compiled. Another thing is that the size of the arduino sketch is HUGE compared to the same program in avr-c, like 700 bytes vs probably under 100. Still, it could be useful.
Logged

Amsterdam
Offline Offline
Full Member
***
Karma: 1
Posts: 139
he's looking at you, kiddy...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

well it has been really busy last week, so i finally have the time to test some things. blink works, fade works, if only on pin 0. and i upload it directly from the ide with a avrusbmkII. i have to compare my cores with that from the above link to see what are the differences.

the problems still exist with includes to other libraries :-( servo.h does not work (yet!)
Logged

--
"We're all in this together..."

ottawa, canada
Offline Offline
God Member
*****
Karma: 6
Posts: 993
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

any more progress?  I'm going to give this a go.
Logged

Bill Rowe
Olduino - An Arduino for the First of Us
www.olduino.wordpress.com

ottawa, canada
Offline Offline
God Member
*****
Karma: 6
Posts: 993
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm trying this out using the core from http://sites.google.com/site/elettronicaarduinoesperimenti/Home/arduino-ide-and-attiny45

installed in the sketchbook folder
Code:
What seems to work is
>sketchbook folder
>sketchbook folder\hardware
>sketchbook folder\hardware\arduino
>sketchbook folder\hardware\arduino\boards.txt //attiny85.build.core=attiny85
>sketchbook folder\hardware\arduino\cores
>sketchbook folder\hardware\arduino\cores\WProgram.h
etc...
Logged

Bill Rowe
Olduino - An Arduino for the First of Us
www.olduino.wordpress.com

ottawa, canada
Offline Offline
God Member
*****
Karma: 6
Posts: 993
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Whoah, cool.  I have an attiny85 running on the core ref'd above with all digital pins confirmed and software serial talking to the PC.

It's amazing what this community an amateur like me to do.  Thanks to all who've contributed to this.

Next step is to verify the timers for millis etc. and to get INT0 and pin change interrupts working.

I don't need softserial for my final application and i probably can't afford the ram but it's great for debugging.  I'm sure it would work fine at higher baud rates by the way - I was just being chicken.


Code:
/*
Thanks for the work on the tiny cores
  28-08-2009 for attiny84 R.Wiersma
  09-10-2009 for attiny45 A.Saporetti

 // ATMEL ATTINY45 / ARDUINO
//
//                 +-\/-+
// Ain0 (D5) PB5* 1|    |8  Vcc
// Ain3 (D3) PB3  2|    |7  PB2 (D2) Ain1 sck
// Ain2 (D4) PB4  3|    |6  PB1 (D1) pwm1 miso
//           GND  4|    |5  PB0 (D0) pwm0 mosi
//                 +----+
//* Pin 1 is Reset and tied high on my boards
//available digital pins are D0-D4

 */

// include the SoftwareSerial library so you can use its functions:
#include <SoftwareSerial.h>

#define rxPin 0  //ic pin 5
#define txPin 3  // ic pin 2
#define ledPin 4 // IC pin 3

// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);

void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  // set the data rate for the SoftwareSerial port
  mySerial.begin(300);
  mySerial.println("Hi!");
  blink(ledPin,7);
}

void loop() {
  mySerial.print("<");
  byte ch=mySerial.read();
  mySerial.print(ch);
  mySerial.print("> ");
  
  // toggle an LED just so you see the thing's alive.  
  blink(ledPin,1);
}



void blink( int pinnum,int count){
  pinMode(pinnum,OUTPUT);
  for (int i=0; i<count; i++){
    digitalWrite(pinnum,HIGH);
    delay(100);
    digitalWrite(pinnum,LOW);
    delay(150);
  }
}
Logged

Bill Rowe
Olduino - An Arduino for the First of Us
www.olduino.wordpress.com

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


What programmer are you using?  Or are you using a bootloader?
Logged

ottawa, canada
Offline Offline
God Member
*****
Karma: 6
Posts: 993
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have an avr dragon which doesn't work well with the ide so I'm compiling with the ide then using avr studio to drive the dragon for programming.

I think any standard programmer would work, I'm waiting for a pololu programmer to come in the mail.
Logged

Bill Rowe
Olduino - An Arduino for the First of Us
www.olduino.wordpress.com

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


This one?
http://www.pololu.com/catalog/product/1300
Logged

ottawa, canada
Offline Offline
God Member
*****
Karma: 6
Posts: 993
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

yes, that's it.
Logged

Bill Rowe
Olduino - An Arduino for the First of Us
www.olduino.wordpress.com

ottawa, canada
Offline Offline
God Member
*****
Karma: 6
Posts: 993
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

ok, as of this morning I have my 8mhz attiny85 running with software serial at 4800 baud, int0 interrupt works, pin change interrupt(from Bill Roy's bitlash code) works fine, and millis() seems accurate.  A million thanks to the contributors.  I'll move on to getting my app working now.  below is my clumsy code for the record.

Code:
/*
Thanks for the work on the tiny cores
  28-08-2009 for attiny84 R.Wiersma
  09-10-2009 for attiny45 A.Saporetti
and to Bill Roy at bitlash for the pin change interrupt code

 // ATMEL ATTINY45 / ARDUINO
//
//                  +-\/-+
// Ain0 (D5) PB5* 1|    |8  Vcc
// Ain3 (D3) PB3  2|    |7  PB2 (D2) Ain1 sck INT0
// Ain2 (D4) PB4  3|    |6  PB1 (D1) pwm1 miso PCINT1
//           GND  4|    |5  PB0 (D0) pwm0 mosi PCINT0
//                 +----+
//* Pin 1 is Reset and tied high on my boards
//available digital pins are D0-D4

 */

// include the SoftwareSerial library so you can use its functions:
#include <SoftwareSerial.h>

#define rxPin 0  //ic pin 5
#define pcint1pin 1 //prog change int pcint on PB1 on IC pin 6
#define txPin 3  // ic pin 2
#define ledPin 4 // ic pin 3
#define int0pin 2 //ic pin 7 - definition not needed - just marking off

int int0cnt=0; //interrupt0 count
int pcint1cnt=0; //program change interrupt 1 count
// set up a new serial port
SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);

void setup()  {
  // define pin modes for tx, rx, led pins:
  pinMode(rxPin, INPUT); pinMode(pcint1pin,INPUT); //not really needed
  pinMode(txPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  attachInterrupt(0, int0monitor, RISING);  //interrupt 0
  // Enable the pin-change interrupt
  PCMSK |= 1<<pcint1pin;      // enable pin change ints on pb1/pcint1/ic 6
  GIMSK |= 1<<PCIE;                  // enable master pin change interrupt
  mySerial.begin(4800); //set baud rate for software serial
  mySerial.println(" "); mySerial.println("Hi!");
  blink(ledPin,7);
}

void loop() {
  mySerial.print("@");
  mySerial.print(millis());
  mySerial.print(">");
  byte ch=mySerial.read();
  mySerial.print(ch);    
  mySerial.print("=");mySerial.print(int(ch));
  mySerial.print(" int0cnt=");
  mySerial.print(int0cnt);
  mySerial.print(" pcint1cnt=");
  mySerial.println(pcint1cnt);
  
  
  // toggle an LED just so you see the thing's alive.  
  blink(ledPin,1);
}
ISR(PCINT0_vect) {
  static unsigned long prevpcint1=0;
  if ((PINB & (1<<pcint1pin))) { //if it's a high on our pin
  if (millis()>(prevpcint1+5)){
    pcint1cnt++;
    prevpcint1=millis();
  }
  }
}  
  


void int0monitor(){
  static unsigned long prevint0=0;
  if (millis()>(prevint0+5)){
    int0cnt++;
    prevint0=millis();
  }
}


void blink( int pinnum,int count){
  pinMode(pinnum,OUTPUT);
  for (int i=0; i<count; i++){
    digitalWrite(pinnum,HIGH);
    delay(100);
    digitalWrite(pinnum,LOW);
    delay(150);
  }
}
Logged

Bill Rowe
Olduino - An Arduino for the First of Us
www.olduino.wordpress.com

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