Go Down

Topic: toneAC v1.2 - Twice the volume, higher quality, higher frequency, etc. (Read 63162 times) previous topic - next topic

AdnanSamra

hi every one

can i use toneAC to get three cut identical frequencies and then stop like this

toneAC(3000);
delay(1000); toneAC(3000); delay(1000); toneAC(3000);
 }
 toneAC(0); // Turn off toneAC, can also use noToneAC().

 while(1); // Stop (so it doesn't repeat forever driving you crazy--you're welcome).
     
   
    }

robtillaart

Yes, such a sketch could be tested within a minute.

What makes you think it cannot be done?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

AdnanSamra

well, I thought it could be done, but never the less i wanted to make sure because i have not got any Arduino board yet , I am very new to this domain in fact,
thank you very much for your help

another question please is suppose that I have a code that would light a led through the digitalWrite (pin#, High) & after it there is the tone code as mentioned in my post earlier, Led will stay on even when micro controller is carrying on the tone code? because I was surfing through the forum I noticed that every one is mentioning that the micro controller does not perform tasks in parallel but rather in high speed that the user would not notice the difference in many applications , so if the LED will stay on even during the Tone process is it because of this or because the fact that I told it to switch on the led by digitalWrite order and the pin stayed on the high state ?

thank you all for all the help,

teckel

well, I thought it could be done, but never the less i wanted to make sure because i have not got any Arduino board yet , I am very new to this domain in fact,
thank you very much for your help

another question please is suppose that I have a code that would light a led through the digitalWrite (pin#, High) & after it there is the tone code as mentioned in my post earlier, Led will stay on even when micro controller is carrying on the tone code? because I was surfing through the forum I noticed that every one is mentioning that the micro controller does not perform tasks in parallel but rather in high speed that the user would not notice the difference in many applications , so if the LED will stay on even during the Tone process is it because of this or because the fact that I told it to switch on the led by digitalWrite order and the pin stayed on the high state ?

thank you all for all the help,
Not even your phone, laptop or desktop PC can technically do multiple things at the same time, it just seems that it can. Same goes for the Arduino. But just like other computers, you can seemingly do multiple things at the same time. Because toneAC uses timers it kinda works in the background, so it's like multitasking.

Basically, you shouldn't have these concerns. You need an Arduino and use it, it will all make more sense.

Tim
My hardware: Arduino, Teensy 2.0, Teensy 3.2 & custom ATmega328
My libraries: NewPing, LCDBitmap, toneAC, toneAC2, NewTone, TimerFreeTone
My Projects: https://dogblocker.com & https://baconorbeer.com
My beer: Great Lakes Brewing Co. Lake Erie Monster

AdnanSamra

thank you Tim,

to tell you the truth I am not a bit concerned about this as long as tasks that I assign the controller to do do not interfere or interrupt each other , so that is my only concern actually . i am working on a code were i need to initiate a relay while certain readings are obtained by an ultrasound sensor and start a sound for a certain period of time at the same time and then stopping it without interrupting the relay function at any time because the relay function could last for 1:30 hour or more,

so do you think that i can just use the readDigital function to read the pin I assigned as writeDigital (pin, High)
to activate the relay and link it in an If function to do the cut tones without affecting the relay function?

thanks,
 

   

teckel

thank you Tim,

to tell you the truth I am not a bit concerned about this as long as tasks that I assign the controller to do do not interfere or interrupt each other , so that is my only concern actually . i am working on a code were i need to initiate a relay while certain readings are obtained by an ultrasound sensor and start a sound for a certain period of time at the same time and then stopping it without interrupting the relay function at any time because the relay function could last for 1:30 hour or more,

so do you think that i can just use the readDigital function to read the pin I assigned as writeDigital (pin, High)
to activate the relay and link it in an If function to do the cut tones without affecting the relay function?

thanks,
Simple answer, "Yup!".  Once you change the state of a pin (from LOW to HIGH or whatever) it stays in that state till you change it (or you power the microcontroller down).  The microcontroller doesn't need to multitask to keep the state of the pin the same, it's stuck in that state till you change it.

Tim
My hardware: Arduino, Teensy 2.0, Teensy 3.2 & custom ATmega328
My libraries: NewPing, LCDBitmap, toneAC, toneAC2, NewTone, TimerFreeTone
My Projects: https://dogblocker.com & https://baconorbeer.com
My beer: Great Lakes Brewing Co. Lake Erie Monster

MarkT

I believe a piezo only acts like a capacitor when "charged" in one direction (for example, with the tone library).  The deflection of the disc is what generates the current.  However, with toneAC it can't charge in this way as an alternating current is being sent.  Therefore, the piezo is never charged and never acts like a capacitor.  From my understanding of how a charge on a piezo works, supplying an alternating current eliminates the need for a resistor.  But, maybe I'm mistaken.
Yes, completely mistaken.  The very same materials used in high value ceramic capacitors are used in
piezo elements because of their very high dielectric constant is due to the ferroelectric effect, where
charge movement is caused by atomic displacements within the crystal lattice.  Piezo elements are all
capacitive.

And like all capacitors the impedance goes down as the frequency goes up, so the current will be higher at
high frequencies.  And being mechanical devices they can also resonate, leading to the possibility of
higher voltages being generated than are fed in...
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

AdnanSamra

hi every one i need to know something please , since we are using pin 11, & 12 for arduino Mega 2560 to out put the sound using tone(AC) and there is no GND connection how can i use a push pull transistor output B class amplifier stage to an 8 ohm speaker? how can i connect this out put to the common bases of the npn & pnp transistors?

teckel

hi every one i need to know something please , since we are using pin 11, & 12 for arduino Mega 2560 to out put the sound using tone(AC) and there is no GND connection how can i use a push pull transistor output B class amplifier stage to an 8 ohm speaker? how can i connect this out put to the common bases of the npn & pnp transistors?
Ground alternates with toneAC, so you can't use a transistor.  But, you wouldn't need to use toneAC if you're going through a amplifier as you don't need to use toneAC to increase the volume.

Maybe I should ask, why are you wanting to use toneAC with an amplifier?

Tim
My hardware: Arduino, Teensy 2.0, Teensy 3.2 & custom ATmega328
My libraries: NewPing, LCDBitmap, toneAC, toneAC2, NewTone, TimerFreeTone
My Projects: https://dogblocker.com & https://baconorbeer.com
My beer: Great Lakes Brewing Co. Lake Erie Monster

Darkstar_Traceur

Hello, I absolutely love toneAC and have been using it on pretty much all of my projects.

Recently however, im trying to expand my project to the internet of things and picked up a Wemos D1 based on the ESP8266. (With inbuilt wifi)

And unfortunately, im getting errors. :( I know its this library is built for the ATmega but I had to try ;)

My question is do you have any support for the ESP8266 or even the new and powerful ESP32?

If not do you or anyone else have any suggestions for a tone library for the ESP boards?

teckel

Hello, I absolutely love toneAC and have been using it on pretty much all of my projects.

Recently however, im trying to expand my project to the internet of things and picked up a Wemos D1 based on the ESP8266. (With inbuilt wifi)

And unfortunately, im getting errors. :( I know its this library is built for the ATmega but I had to try ;)

My question is do you have any support for the ESP8266 or even the new and powerful ESP32?

If not do you or anyone else have any suggestions for a tone library for the ESP boards?
The non-timer based methods will work (like ping() and ping_cm() for example). But the time-based methods would never work on ESP boards as every microcontroller uses different timers and logic.

You shouldn't get errors if your using ping() for example.

Tim
My hardware: Arduino, Teensy 2.0, Teensy 3.2 & custom ATmega328
My libraries: NewPing, LCDBitmap, toneAC, toneAC2, NewTone, TimerFreeTone
My Projects: https://dogblocker.com & https://baconorbeer.com
My beer: Great Lakes Brewing Co. Lake Erie Monster

TryBit

Hi

I want to connect two speakers (left speaker & right speaker), I know the specs says connect pin9 & 10 to speaker wires. The speakers will not play at the same time, only one or the other.  I am using UNO, how to achieve 2 speakers connection? 

FYI, I know I can make a control switch circuit to switch between left and right speakers.  But I'd rather not do that if there is a way to connect two separate speakers. Again only one speaker will be active at one time.

Thanks in advance

teckel

Hi

I want to connect two speakers (left speaker & right speaker), I know the specs says connect pin9 & 10 to speaker wires. The speakers will not play at the same time, only one or the other.  I am using UNO, how to achieve 2 speakers connection? 

FYI, I know I can make a control switch circuit to switch between left and right speakers.  But I'd rather not do that if there is a way to connect two separate speakers. Again only one speaker will be active at one time.

Thanks in advance
toneAC must use the pins assigned to the timer.  The pin 9 & 10 requirement is a limitation of the microcontroller, not the library.  However, I do have a toneAC2 library which uses timer 2 and you can assign it to any other 2 pins.  So, you need to use both toneAC for one speaker (pins 9 & 10) and toneAC2 for the other speaker, which you can assign to any other two pins.

toneAC2:  https://bitbucket.org/teckel12/arduino-toneac2/wiki/Home

Tim
My hardware: Arduino, Teensy 2.0, Teensy 3.2 & custom ATmega328
My libraries: NewPing, LCDBitmap, toneAC, toneAC2, NewTone, TimerFreeTone
My Projects: https://dogblocker.com & https://baconorbeer.com
My beer: Great Lakes Brewing Co. Lake Erie Monster

Go Up