Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tone library working only with Attiny85 and not with Attiny45 #124

Open
GoogleCodeExporter opened this issue Feb 5, 2016 · 16 comments
Open

Comments

@GoogleCodeExporter
Copy link

Used the below code on both attiny85 and attiny45, attiny85 gives the correct 
sound as pwm output on speaker pin. But the same code on attiny45 gives just 
"tip..tip..tip" sound on speaker. Tried different notes and its same also tried 
to play small array to see if its a memory issue but still same. I have few 
attiny45 which I want to use for door bell.

Pasting code below,

=========================


 #include "pitches.h"

 #define SPK_PIN 0 // pin 6


int melody[] = {NOTE_E5, NOTE_E5,NOTE_E5,   NOTE_E5, NOTE_E5,NOTE_E5,   
NOTE_E5, NOTE_G5, NOTE_C5, NOTE_D5,  NOTE_E5};
int noteDurations[] = {4, 4, 2,  4,4,2,  4,4,3,8,  1};

void setup() {

}

void loop() {
  playtone();
  delay(3000);
}

void playtone(){
 // iterate over the notes of the melody:
  for (int thisNote = 0; thisNote < 11; thisNote++) {

    // to calculate the note duration, take one second 
    // divided by the note type.
    //e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
    int noteDuration = 1000/noteDurations[thisNote];
    tone(SPK_PIN, melody[thisNote],noteDuration);

    // to distinguish the notes, set a minimum time between them.
    // the note's duration + 30% seems to work well:
    int pauseBetweenNotes = noteDuration * 1.30;
    delay(pauseBetweenNotes);
    // stop the tone playing:
    noTone(SPK_PIN);
  } 
}


===============================

Pitches.h


/*************************************************
 * Public Constants
 *************************************************/

#define NOTE_B0  31
#define NOTE_C1  33
#define NOTE_CS1 35
#define NOTE_D1  37
#define NOTE_DS1 39
#define NOTE_E1  41
#define NOTE_F1  44
#define NOTE_FS1 46
#define NOTE_G1  49
#define NOTE_GS1 52
#define NOTE_A1  55
#define NOTE_AS1 58
#define NOTE_B1  62
#define NOTE_C2  65
#define NOTE_CS2 69
#define NOTE_D2  73
#define NOTE_DS2 78
#define NOTE_E2  82
#define NOTE_F2  87
#define NOTE_FS2 93
#define NOTE_G2  98
#define NOTE_GS2 104
#define NOTE_A2  110
#define NOTE_AS2 117
#define NOTE_B2  123
#define NOTE_C3  131
#define NOTE_CS3 139
#define NOTE_D3  147
#define NOTE_DS3 156
#define NOTE_E3  165
#define NOTE_F3  175
#define NOTE_FS3 185
#define NOTE_G3  196
#define NOTE_GS3 208
#define NOTE_A3  220
#define NOTE_AS3 233
#define NOTE_B3  247
#define NOTE_C4  262
#define NOTE_CS4 277
#define NOTE_D4  294
#define NOTE_DS4 311
#define NOTE_E4  330
#define NOTE_F4  349
#define NOTE_FS4 370
#define NOTE_G4  392
#define NOTE_GS4 415
#define NOTE_A4  440
#define NOTE_AS4 466
#define NOTE_B4  494
#define NOTE_C5  523
#define NOTE_CS5 554
#define NOTE_D5  587
#define NOTE_DS5 622
#define NOTE_E5  659
#define NOTE_F5  698
#define NOTE_FS5 740
#define NOTE_G5  784
#define NOTE_GS5 831
#define NOTE_A5  880
#define NOTE_AS5 932
#define NOTE_B5  988
#define NOTE_C6  1047
#define NOTE_CS6 1109
#define NOTE_D6  1175
#define NOTE_DS6 1245
#define NOTE_E6  1319
#define NOTE_F6  1397
#define NOTE_FS6 1480
#define NOTE_G6  1568
#define NOTE_GS6 1661
#define NOTE_A6  1760
#define NOTE_AS6 1865
#define NOTE_B6  1976
#define NOTE_C7  2093
#define NOTE_CS7 2217
#define NOTE_D7  2349
#define NOTE_DS7 2489
#define NOTE_E7  2637
#define NOTE_F7  2794
#define NOTE_FS7 2960
#define NOTE_G7  3136
#define NOTE_GS7 3322
#define NOTE_A7  3520
#define NOTE_AS7 3729
#define NOTE_B7  3951
#define NOTE_C8  4186
#define NOTE_CS8 4435
#define NOTE_D8  4699
#define NOTE_DS8 4978


Original issue reported on code.google.com by [email protected] on 14 Nov 2014 at 7:40

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

using latest attiny-core arduino-tiny-0100-0018.zip with arduino 1.0.5-r2

Original comment by [email protected] on 14 Nov 2014 at 7:44

@GoogleCodeExporter
Copy link
Author

Forgot to mention I tried both attiny45 on 1mhz and 8mhz fuses. For attiny85 
its working only with 1mhz fuse and not with 8mhz but for me that speed is ok.

Original comment by [email protected] on 14 Nov 2014 at 7:48

@GoogleCodeExporter
Copy link
Author

No hardware details.

Original comment by [email protected] on 14 Nov 2014 at 7:49

  • Changed state: Invalid

@GoogleCodeExporter
Copy link
Author

What version of the product are you using? On what operating system?
I'm using the arduino IDE v1.0.5-r2 on windows 8.1 using 
arduino-tiny-0100-0018.zip

Original comment by [email protected] on 14 Nov 2014 at 8:01

@GoogleCodeExporter
Copy link
Author

Sorry forgot to put hardware in initial description please reopen the ticket 
just added one comment for hardware. Thanks in advance

Original comment by [email protected] on 14 Nov 2014 at 8:03

@GoogleCodeExporter
Copy link
Author

"attiny45", "speaker", and "1mhz" is not a description of the the hardware.  As 
long as you refuse to provide the details necessary to reproduce the problem I 
refuse to accept that this is a problem with Tiny Core.

Original comment by [email protected] on 14 Nov 2014 at 9:22

@GoogleCodeExporter
Copy link
Author

What steps will reproduce the problem?
1. Connect ATTiny45 with the following pinouts.
   1 - 100K to +5v
   2 - free pin
   3 - free pin
   4 - GND
   5 - 68E resistor to Speaker + and Speaker - to GND
   6 - free pin
   7 - free pin
   8 - +5v

2. Attiny45 at 1MHz and flashed the hex file using usbasp and used the code on 
description to flash file.

Please let me know if you need anything else

Original comment by [email protected] on 14 Nov 2014 at 9:30

@GoogleCodeExporter
Copy link
Author

5/(68+8)*1000 = 66mA.  66mA grossly exceeds the maximum current an AVR pin can 
provide.  Which means your test case is still invalid.

Original comment by [email protected] on 14 Nov 2014 at 9:47

@GoogleCodeExporter
Copy link
Author

I tried with 220E and 1k values all of these work with attiny85 kinda strange

Original comment by [email protected] on 14 Nov 2014 at 10:06

@GoogleCodeExporter
Copy link
Author

Do you need any more info? The bug still says invalid status

Original comment by [email protected] on 16 Nov 2014 at 4:46

@GoogleCodeExporter
Copy link
Author

In reply #10 you state tone works.

Original comment by [email protected] on 16 Nov 2014 at 11:59

@GoogleCodeExporter
Copy link
Author

oh reply 10 i mentioned they all work on attiny85 from 68E-1k values only 
difference is volume. But on attiny45 none of the values work. Same circuit and 
same sketch on attiny45 1mhz doesnt work. It works on attiny85 1mhz

Original comment by [email protected] on 17 Nov 2014 at 5:52

@GoogleCodeExporter
Copy link
Author

You very likely damaged the output driver on your t45 processor.  Until you 
confirm your results with a second undamaged t45 processor this report remains 
invalid.

Original comment by [email protected] on 17 Nov 2014 at 9:00

@GoogleCodeExporter
Copy link
Author

I tried with 3 attiny45 chips and same result with 220E,no output except tik 
tik repeating noise

Original comment by [email protected] on 17 Nov 2014 at 9:15

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 18 Nov 2014 at 1:46

  • Changed state: New

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant