11-30-2022 12:37 PM - edited 11-30-2022 12:53 PM
I am trying to make a labview program that can play a .wav file stored in labview on an external speaker by using an arduino UNO as DAQ device.
I found several solutions to play a .wav file on the loudspeaker of the computer itself, but I am stuck at sending the analog signal to an external speaker.
Someone who has found a solution to this problem?
11-30-2022 12:55 PM
Hi Senne,
@SenneDG wrote:
I am trying to make a labview program that can play a .wav file stored in labview on an external speaker by using an arduino UNO as DAQ device.
I found several solutions to play a .wav file on the loudspeaker of the computer itself, but I am stuck at sending the analog signal to an external speaker.
Read the WAV file into an array of waveforms.
Then output the sample data of the waveform(s) to your Arduino…
what have you tried and where are you stuck?
11-30-2022 01:23 PM
Hello
I can read a WAV file with the 'sound file read simple' block and store the data in a waveform.
I am using the hobbyist toolkit and I think the problem I am having is that I can't use the 'Analog Write' because the Arduino UNO only has analog read ports or digital read and write ports.
So I tried using the 'Digital Write' block but in this way, I only can play the first frequency of the file.
11-30-2022 02:11 PM
Hi Senne,
@SenneDG wrote:
I can't use the 'Analog Write' because the Arduino UNO only has analog read ports or digital read and write ports.
So you want to output an analog signal without using an analog output???
How should this happen?
@SenneDG wrote:
So I tried using the 'Digital Write' block but in this way, I only can play the first frequency of the file.
How do you write an analog waveform to a DO?
What is the "first frequency"?
11-30-2022 03:23 PM - edited 11-30-2022 03:25 PM
@SenneDG wrote:
Hello
I can read a WAV file with the 'sound file read simple' block and store the data in a waveform.
I am using the hobbyist toolkit and I think the problem I am having is that I can't use the 'Analog Write' because the Arduino UNO only has analog read ports or digital read and write ports.
So I tried using the 'Digital Write' block but in this way, I only can play the first frequency of the file.
Um... yeah without an analog out (internal DAC [not DAQ]) you are kinda hooped
I guess you could use all of the Uno's digital outputs and an R-2R Ladder for 14bit resolution.
BTW: DAQ = Data AcQuisition DAC = Digital to Analog Converter
12-01-2022 09:45 AM
There's a few ways of doing analog out with an Arduino, such as the R-2R circuit, or PWM + filter cap. Unfortunately I don't think LabVIEW's LINX toolkit will be a viable option here. Using the LINX API to write serial data, and set digital / pwm outputs will likely be too slow for audio data.
It might be doable using an 8-bit R-2R circuit. custom Arduino sketch and custom LabVIEW code. The LV code would load a wav file, convert it to single channel 8-bit (0-255), then stream the data to the Arduino via its serial port. On the Arduino every byte received from the serial port would be read and written to the R-2R circuit using a port write. It would sound pretty lo-fi, but be enough for basic audio.
Once you have the analog signal output, you'll want to run it through an amplifier circuit of some sort to drive the speaker.