You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.creole
+7-7Lines changed: 7 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -12,9 +12,9 @@ Replacement to the standard tone library with many advantages:
12
12
* Can set not only the frequency but also the sound volume
13
13
* Less stress on the speaker so it will last longer and sound better
14
14
15
-
Disadvantages are that it must use certain pins and it uses two pins instead of one. But, if you're flexible with your pin choices, this is a great upgrade. It also uses timer 1 instead of timer 2, which may free up a conflict you have with the tone library. It exclusively uses port registers for the fastest and smallest code possible (which also makes it **ONLY compatible with ATmega microcontrollers**).
15
+
Disadvantages are that it must use certain pins and it uses two pins instead of one. But, if you're flexible with your pin choices, this is a great upgrade. In case of ATmega microcontrollers, it uses timer 1 instead of timer 2, which may free up a conflict you have with the tone library. It exclusively uses port registers for the fastest and smallest code possible.
16
16
17
-
== Difference between toneAC and toneAC2 ==
17
+
== Difference between toneAC and toneAC2 (ATmega) ==
18
18
19
19
First off, toneAC is **SUPERIOR** to [[https://bitbucket.org/teckel12/arduino-toneac2/wiki/Home|toneAC2]]. It's called [[https://bitbucket.org/teckel12/arduino-toneac2/wiki/Home|toneAC2]] only because it uses timer 2, not because it's a newer version of toneAC. [[https://bitbucket.org/teckel12/arduino-toneac2/wiki/Home|toneAC2]] is an alternate but **INFERIOR** version of toneAC that uses timer 2 instead of timer 1 and allows for any two pins to be used. You should use toneAC instead of [[https://bitbucket.org/teckel12/arduino-toneac2/wiki/Home|toneAC2]] if at all possible because toneAC is more accurate, higher quality, allows for higher frequencies, uses fewer CPU cycles, and creates smaller code. However, if you're having a conflict with timer 1, or just can't use the default PWM pins for timer 1, then [[https://bitbucket.org/teckel12/arduino-toneac2/wiki/Home|toneAC2]] may be your answer.
20
20
@@ -49,19 +49,19 @@ Help future development by making a small donation (the [email protected] payee is
49
49
50
50
== Compatibility ==
51
51
52
-
toneAC is written specifically for the ATmega AVR platform as it uses timer events that only exist with this platform. Compatibility includes the following platforms/microcontrollers:
52
+
Compatibility includes the following platforms/microcontrollers:
Connection is very similar to a piezo or standard speaker. Except, instead of connecting one speaker wire to ground you connect both speaker wires to Arduino pins. The pins you connect to are specific, as toneAC lets the ATmega microcontroller do all the pin timing and switching. This is important due to the high switching speed possible with toneAC and to make sure the pins are alyways perfectly out of phase with each other (push/pull). See the below list for which pins to use for different Arduinos. Just as usual when connecting a speaker, make sure you add an inline 100 ohm resistor between one of the pins and the speaker wire.
58
+
Connection is very similar to a piezo or standard speaker. Except, instead of connecting one speaker wire to ground you connect both speaker wires to Arduino pins. The pins you connect to are specific, as toneAC lets the microcontroller do all the pin timing and switching. This is important due to the high switching speed possible with toneAC and to make sure the pins are alyways perfectly out of phase with each other (push/pull). See the below list for which pins to use for different Arduinos. Just as usual when connecting a speaker, make sure you add an inline 100 ohm resistor between one of the pins and the speaker wire.
The library is named toneAC because it produces an alternating push/pull between two pins. It's not really AC (alternating current) as in-wall electrical wiring because it's a square wave and never produces a negative voltage. However, the effect of the alternating push/pull creates an effective double voltage differential which produces the higher volume level.
119
119
120
-
The ATmega's PWM takes care of the alternating push/pull so the accuracy is exact. When you send a tone to a speaker with the standard tone library, the loudest is at 50% duty cycle (only on half the time). Which at 5 volts, is like sending only 2.5v to the speaker. With toneAC, we're sending out of phase signals on two pins. So in effect, the speaker is getting 5 volts instead of 2.5, making it nearly twice as loud.
120
+
The ATmega's PWM and ESP32 MCPWM take care of the alternating push/pull so the accuracy is exact. When you send a tone to a speaker with the standard tone library, the loudest is at 50% duty cycle (only on half the time). Which at 5 volts, is like sending only 2.5v to the speaker. With toneAC, we're sending out of phase signals on two pins. So in effect, the speaker is getting 5 volts instead of 2.5, making it nearly twice as loud.
121
121
122
122
The sound quality difference has to do with allowing the Arduino's PWM to take care of everything and careful programming. Longer piezo life happens because instead of driving the transducer disc only ever in one direction (deforming the disc and reducing sound and quality), it drives it in both directions keeping the disc uniform.
0 commit comments