Playing ultrasound wav file from SD

Hi,

So I am working on a bioacoustics project part of which is to reproduce certain beetle chirps. The chirps are distributed through 20 to 60 kHz, so I was planning to use Arduino board (I have at my disposal Uno, M0, M0 Pro boards), put the wav files to SD card and play them using tone() function. I found these speakers online, but now I am having hard time trying to understand how do I connect the Arduino pins to the speakers.
I've looked through other threads (some more or less similar to mine) and, as I understand, I need a resistor based on the impedance of the speakers (which is not mentioned in the speaker data sheet) with DAC or, possibly, an amplifier (this is the part I am getting totally lost at).

If anyone could help me with a fool-proof explanation on what do I need to connect the board and speakers (and maybe how), I would really appreciate it.

Thanks!

put the wav files to SD card and play them using tone() function

You can't play wav files with the tone() function. The wav files consist of many samples, each of which you would have to play back to a DAC. You must also play those samples back at the same rate at which they were sampled in the original wav file. What is the sampling rate of your wav files?

Pete

I am having hard time trying to understand how do I connect the Arduino pins to the speakers.

You don't. You will connect the speaker to the output of an audio amplifier, with good ultrasonic response, capable of producing up to 16V peak-to-peak.

Evidently, an Arduino Due can be used to play .wav files (at least for ordinary audio, limited to 20 kHz maximum), but there are many other possibilities.

el_supremo:
You can't play wav files with the tone() function. The wav files consist of many samples, each of which you would have to play back to a DAC. You must also play those samples back at the same rate at which they were sampled in the original wav file. What is the sampling rate of your wav files?

Pete

Oh, good to know that, thank you.

Sounds were recorded at a sampling rate of 192 kHz, so it, probably, would be too high to playback for an Arduino device.

jremington:
You don't. You will connect the speaker to the output of an audio amplifier, with good ultrasonic response, capable of producing up to 16V peak-to-peak.

Evidently, an Arduino Due can be used to play .wav files (at least for ordinary audio, limited to 20 kHz maximum), but there are many other possibilities.

Would something like this work then? Unless I am mistaken it has the frequencies and the voltage to work (I am looking at Vrms which is 0.3535*Vpp). or maybe you would have an amplifier in mind? Thanks.

erochester:
Sounds were recorded at a sampling rate of 192 kHz, so it, probably, would be too high to playback for an Arduino device.

You can output on the DUE two DACs at frequencies well above 192 KHz (in fact up to 2 MHz for one DAC or 1 MHz to output simultaneously on two DACs depending on the selected clock- page 1411 Sam3x datasheet).

Here is a tutorial to use these DACs (Google translate is your friend):
http://www.f-legrand.fr/scidoc/docmml/sciphys/arduinodue/synthese/synthese.html

Note that there is a more efficient way to program these DACs, this is with a PDC DMA. This last method reduces dramatically the number of interrupts.

Would something like this work then?

No.

Sounds were recorded at a sampling rate of 192 kHz, so it, probably, would be too high to playback for an Arduino device.

No.
Your problem might be getting the SD card to read that fast though, but you can always buffer it using faster paged memory.

So, if I understand correctly from the above comments, for this project I could use Arduino Due with SD card module and use buffering to output quickly enough to DACs, to an amplifier and from there to the speaker?

Grumpy_Mike:
No.

Can you explain a bit more why wouldn't it work, so I can find the one that would fit?

I could use Arduino Due with SD card module and use buffering to output quickly enough to DACs, to an amplifier and from there to the speaker?

It seems possible.

At 192 KHz, the DAC peripheral is not the bottleneck.

To ensure a maximum speed for SD card reading, you have the HSMCI peripheral on a DUE, see this thread, reply #9:
https://forum.arduino.cc/index.php?topic=188360.0

You might be interested by these libraries:

...

However, IMO, this project requires a good knowledge of what's under the DUE hood...

erochester:
Can you explain a bit more why wouldn't it work, so I can find the one that would fit?

From the data sheet:-

The NJM2794 is a ground noise isolation amplifier
designed for car audio system. It contains dual channel differential amplifier.
It is developed for those car audio applications where long connections between head unit and other components are necessary and ground noise has to be eliminated.

Which is nothing like what you want.
Also the test parameters says

AC CHARACTERRISTIC (Non-inverting circuit, f=1kHz, Vin=1Vrms, Rg=0Ω, RL=10kΩ

So unless you speaker has a 10K impedance, this is not designed to drive a speaker.

ard_newbie:
At 192 KHz, the DAC peripheral is not the bottleneck.

To ensure a maximum speed for SD card reading, you have the HSMCI peripheral on a DUE, see this thread, reply #9:
SD card storage using the HSMCI interface - Arduino Due - Arduino Forum

You might be interested by these libraries:

GitHub - macchina/M2_SD_HSMCI: Library for HSMCI-based SD Card access
Arduino-libraries/SD_HSMCI at master · jmgiacalone/Arduino-libraries · GitHub
...

However, IMO, this project requires a good knowledge of what's under the DUE hood...

Thanks a lot for the references!
And I agree with you, it seems I underestimated how many more things I'll need to figure out for this setup.

Grumpy_Mike:
So unless you speaker has a 10K impedance, this is not designed to drive a speaker.

I see, so I was totally of the mark then.

Just as a note and to make sure I am looking at the right thing this time - This means I am looking for an audio amp that has a good response at 20-60 kHz with Vin=3.3V and Vout = 16V and RL~4Ohm?

and RL~4Ohm?

What is the impedance of those speakers? A piezo transducer is likely to have relatively high, complex (capacitive) impedance.

See if you can get some actually useful information from the seller, like the impedance, the actual frequency response and the recommended driver characteristics. There isn't enough information on the page you linked.

Relevant application note on driving piezo transducers.

A piezo transducer is likely to have resonances which make some frequencies a lot louder than others. You need to know the output response.

It is likely that you will not find a single chip amplifier that will do what you want. Then you will need to add a power output stage to a conventional operational amplifier output.

The TDA2009A stereo amp chip has usable bandwidth to 80kHz or beyond - but hurry its obsolete!

jremington:
What is the impedance of those speakers? A piezo transducer is likely to have relatively high, complex (capacitive) impedance.

See if you can get some actually useful information from the seller, like the impedance, the actual frequency response and the recommended driver characteristics. There isn't enough information on the page you linked.

Relevant application note on driving piezo transducers.

Thanks for the reference.

I've contacted the seller with no luck as of yet, so I am looking if maybe I can find a proper description of these speakers or a different pair of speakers.

Someone else recommended for me to look into super tweeters as a possibility, so maybe that will work out too.

MarkT:
The TDA2009A stereo amp chip has usable bandwidth to 80kHz or beyond - but hurry its obsolete!

Sounds good. Thanks!

Grumpy_Mike:
A piezo transducer is likely to have resonances which make some frequencies a lot louder than others. You need to know the output response.

It is likely that you will not find a single chip amplifier that will do what you want. Then you will need to add a power output stage to a conventional operational amplifier output.

Haven't thought of that. Thanks.