Dynamic Signal Acquisition

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous Saving from DAQmx to a WAV File

Solved!
Go to solution

I am trying to save a waveform that was recorded by a DAQmx device into a .wav file.  I have found two sample vi's that I used to start with.

 

Sound Input to File.vi

This vi saves the waveforms from a microphone input to a .wav file.  The nice thing about this vi is it has no limit on how long you can record.

 

SVXMPL_WAV Record (DAQmx).vi

The vi saves the waveforms from the DAQmx input to a .wav file.  The nice thing about this vi is it shows how to get the waveform through the DAQmx device, but you can only record for just over 1 minute.

 

 

DAQmx Input to File.vi

This was my attempt at combining the best things of the above vi's, but it doesn't work and I don't know why.  I'm hoping somebody can tell me where I went wrong and/or how to improve my vi.

 

Thanks

Number 6

0 Kudos
Message 1 of 11
(9,937 Views)
Solution
Accepted by topic author The_Prisoner(No.6)

Hi Prisoner,

 

When you try to acquire more than a few minutes of data are you getting an error message that states the requested memory could not be allocated?

This error appears because the program tries to all acquire data in a single DAQmx read call (1 channel N sample).  You will need to instead, modify the program such that you call DAQmx read multiple times so you can use a smaller buffer size.  The best way to change this would be to implement a producer/consumer loop where the producer queues all the samples and the consumer dequeues them and feeds them to the Sound Write Waveform VI. 

 

 

Application Design Patterns: Producer/Consumer

http://zone.ni.com/devzone/cda/tut/p/id/3023

 

Producer/Consumer pattern 

https://decibel.ni.com/content/docs/DOC-8962

Anthony F.
Staff Software Engineer
National Instruments
0 Kudos
Message 2 of 11
(9,786 Views)

The error message that I am getting is similar, but not quite an out of memory error:

 

Error -50005 occurred at DAQmx Input to File.vi

Possible reason(s):

NI Platform Services:  The specified data width is not supported or cannot be transferred on the bus. The operation could not be completed as specified.

Task Name: _unnamedTask<0>

 

This error message happens right after the program tries to execute the DAQmx Read (Analog Wfm 1Chan NSamp).vi.

 

Would your solution solve this problem as well?

0 Kudos
Message 3 of 11
(9,784 Views)

From your original post it sounds like creating a producer/consumer loop will help you.  What is the acquisition duration you are using?  Do you receive this message when using a smaller value like 1 second?

 

 

Anthony F.
Staff Software Engineer
National Instruments
0 Kudos
Message 4 of 11
(9,763 Views)

This happens the very first time the DAQmx Read (Analog Wfm 1Chan NSamp).vi tries to execute.  It doesn't matter what sample duration I try to use.

 

Number 6

0 Kudos
Message 5 of 11
(9,758 Views)

What device are you using to acquire data?  It looked like you were using a myDAQ in one of the VIs, is this correct?

 

I have acquired data with a myDAQ here and it works fine.  Check your settings against mine

Anthony F.
Staff Software Engineer
National Instruments
0 Kudos
Message 6 of 11
(9,738 Views)

Thank you for showing me that the SVXMPL_WAV Recorder (DAQmx).vi works fine.  I can run that vi with the myDAQ device as well and it works with pretty much any values that I want to put in it.

 

The problem is with the DAQmx Input to File.vi that I wrote. The vi is included in my first post.

 

Number 6

0 Kudos
Message 7 of 11
(9,727 Views)

It looks like you have a numeric constant of 2147483647 going to the samples per channel VI,  what are you trying to do with this constant?

Anthony F.
Staff Software Engineer
National Instruments
0 Kudos
Message 8 of 11
(9,720 Views)

If you remove the numeric constant, and adjust your max and min values to +/-1 volts your VI seems to work correctly.  The +/-1 volt limitation is defined in the detailed help of the sound file write VI.

Anthony F.
Staff Software Engineer
National Instruments
Message 9 of 11
(9,719 Views)

Yes that works and seems to solve the problem.  Thank you.  I did have to connect the Number of Samples/ch input to the Sample Clock instead of the numeric constant that I had in order to prevent a different error message.

 

I can see that the producer/consumer solution would be more elegant than my method, however I have attached my solution in case anyone else ever wants to look at it.

 

Number 6

0 Kudos
Message 10 of 11
(9,703 Views)