Pages: 1 [2] 3   Go Down
Author Topic: ATTiny85 tone() core?  (Read 3333 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

A quiet click every 200ms.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The core I'm downloading is called "arduino-tiny-0100-0015" if that makes a difference. (Found it from the second link at the beginning of this post)
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4058
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well I thought it should be a click every 100ms but no matter smiley-wink

I think we've ruled out all the hardware. You've re-installed the Arduino IDE v1.0.3 and the current Arduino-tiny core. I'm out of ideas at the moment...
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4058
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The core I'm downloading is called "arduino-tiny-0100-0015" if that makes a difference. (Found it from the second link at the beginning of this post)

Yep, actually, I had arduino-tiny-0100-0014, so I installed 0100-0015, but no difference.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, I'm going to go to bed. Maybe tomorrow I'll think of another variable we can test. If so, I'll post here about it. In the mean time, thanks for all the help.
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4058
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sounds like a plan. I'll track this thread, will be interested what you might find and if any light bulbs (or LEDs) go on here I'll let you know too.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

Brisbane, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1122
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Just to rule out the piezo itself, since you have it already connected on one of the ATTiny PWM pins, can you get a sound from it using analogWrite, as an example:
Code:
analogWrite(3, 100);
Geoff
Logged

"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

Seattle
Offline Offline
Newbie
*
Karma: 0
Posts: 46
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

If you've verified you're running sketches ok, and verified you can blink an LED on this pin, it's time to check whether the buzzer polarity might be a factor, whether the buzzer is damaged, and to try a real 8 ohm speaker (with an additional small resistor).  Another reasonable step would be to try your buzzer with another Arduino.

good luck!
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 11
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Just to rule out the piezo itself, since you have it already connected on one of the ATTiny PWM pins, can you get a sound from it using analogWrite
AnalogWrite does not produce a sound.
Quote
it's time to check whether the buzzer polarity might be a factor
It's a non polar buzzer, which works no problem with the arduino itself.

Despite these not being the problem, I found the solution: there was an older ATTiny core that I never removed. It was overriding the new core with the tone() function. Once I removed the older core, the new one took effect and now the project works fine.
Thanks to everyone for their help!
Logged

Grand Blanc, MI, USA
Offline Offline
Faraday Member
**
Karma: 95
Posts: 4058
CODE is a mass noun and should not be used in the plural or with an indefinite article.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Good morning, glad to hear you found it. Just having coffee here, but I was about to suggest we start comparing sketch sizes, linker maps and such.
Logged

MCP79411/12 RTC ... "One Million Ohms" ATtiny kit ... available at http://www.tindie.com/stores/JChristensen/

London
Offline Offline
Full Member
***
Karma: 0
Posts: 146
Ugi was not declared in this scope
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm having a similar issue - at least it seems so.

I can't get tone or any PWM to work on PB3 but PWM works fine on PB0 (ATTiny85).

I was using Arduino 0022 with v 0012 of the tiny cores but I just installed the newest versions of each (1.03 & v0015) and that's made no difference.  I also wondered whether it was a fuse setting but I have used "burn bootloader", which I understand sets the fuses for the 'Tiny.  I've also tried two different chips - just in case I had managed to fry something - and that doesn't seem to make a difference either.

Is there some initialisation of the ATTiny that you should do on first use, or something, that I might have missed?

Any ideas appreciated.

Ugi

PS I'm running the ATTiny at 1MHz off a 3v lithium CR2032 button cell, if that could concievably make a difference
« Last Edit: January 23, 2013, 07:18:56 am by Dr_Ugi » Logged

Brisbane, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1122
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Ugi

I just ran the test sketch below using tone on D3 then D4 and both results were equivalent.  tone() works on PB3 and PB4 based on my tests.  I used an 8Ohm speaker and two different piezos for the tests (they sounded terrible in contrast - I'll stick to speakers for this kind of thing I think !)
Code:
const int testPin = 3;

void setup() {
  pinMode(testPin, OUTPUT);                   
}

void loop() {
  for(int val = 30; val < 3000; val++) {
  tone(testPin, val);
  delay(5);
  }
    for(int val = 3000; val >30; val--) {
  tone(testPin, val);
  delay(5);
  }
  noTone(testPin);
}
So while that worked, analogWrite() on PB3/D3 actually didn't which agrees with your findings.  It was a hard flash rather than the pulse I'd intended so acted as a digitalWrite.  I'm certain analogWrite() has worked for me in the past on PB3 but when I went back through past sketches I've not kept a sketch that used it.  Not at all certain on that one now.

Anyway I can confirm tone() works with the above sketch, so if it doesn't for you I'd be looking elsewhere.  I tested on an ATTiny85 running at 8MHz off a CR2032 3V cell - the only other component on my test rig is a 0.1uF decoupling cap.

Cheers ! Geoff
Logged

"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

London
Offline Offline
Full Member
***
Karma: 0
Posts: 146
Ugi was not declared in this scope
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Geoff - I was also finding the "hard flash" effect - analogWrite(3,128) and analogWrite(3,0) are both equivalent to digitalWrite(3,LOW) but analogWrite(3,255) is equivalent to a digital HIGH.

I've got to work for a few hours now but will try out your test sketch this evening.

Cheers

Ugi
Logged

Denmark
Offline Offline
Edison Member
*
Karma: 35
Posts: 1063
Happy Hobbyist
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I just ran strykeroz sketch, and tone is working on all 5 pins
Also I checked PWM and ADC pins

Working PWM pins: PB4,PB0 and PB1

Working analogRead() on pins A1,A2 and A3
Logged

London
Offline Offline
Full Member
***
Karma: 0
Posts: 146
Ugi was not declared in this scope
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Guys - I tried swapping PB1 & PB3 (only one needs to be PWM) and it works fine on PB1.  Odd that - I'm sure I checked the datasheet when I was planning this project.

Anyhow, tone works on PB4 (&PB3) - I think that may have been down to my old version before - and PWM works on PB1, which will do me fine.

I don't understand how tone works on PB3 if PWM doesn't, but maybe that's a cunning interrupt-based version.

Thanks for your help.

Ugi
Logged

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