01-11-2011 06:02 PM
Hi all,
I am trying to get this labview code that an NI engineer wrote for us to work (the engineer wrote it for us about a year ago but the project got tabled until now...he is no longer with NI!). What we need is code that can read a binary file of voltage data from the disk and stream it out through an analog output channel on a NIdaq 6251 to an ultrasonic capable speaker at high (350kHz) sampling rates. (We are outputing synthesized ultrasonic mouse vocalizations). Unfortunately I am a LabView newbie so I am really lost. The code is attached. We have contacted NI about helping with this but they have been clueless...I hope one of you can help! I think the idea, if I remember correctly, is for the code to read the data into a software buffer so that reading from the disk, which I am assumming may be slow, will not interfere with the data going out to the speaker at the desired sampling rate...Right now it does not work (gives no errors that we can see) but the buffer does not seem to be filling... To test it download a file I made that contains a binary file (16 bit signed integers) containing 5 seconds of a 90kHz, 1V amplitude sine wave sampled at 360kHz here http://www.keck.ucsf.edu/~schenk/testlabview.int16
Any help or insight you can give would be great!
katrin
01-12-2011 01:00 AM
Hi Finns,
I think your problem is to do with your 2nd top loop:
You should have a stop condition terminal like shown above, yours is set to continue. This will cause your bottom loop to be stopped prematurely, before all its data has been read from your queue (buffer)
Rgs,
Lucither.
01-12-2011 01:38 AM
Hi Finns,
I have never used any of the DAQmx vi's but it seems to me that you have configured the DAQmx output buffer to be 90,000 bytes, in the top loop you are then sending packets of 90,000 bytes but before the top loop starts you initially send 'Output Rate' amount of bytes to the first iteration of the bottom loop, which on the example you sent me is set to 300,000? This seems wrong to me.
What i have sent above, regarding the stop condition terminal, is still an error but looking at your code again this will only cause your bottom loop to miss the last 10 packets at most as this is your max queue size. The top loop is forced to wait until there is room for the next queue item. With this being the case i would imagine you would still get something so there is also another problem somewhere.
Rgs,
Lucither.
01-12-2011 01:47 AM
Finns,
Right, think i may have found the main problem:
In your bottom loop you are dividing your input array by 65536. In your version you are actually dividing it by a 'Double' Array of only 1 element. This is giving you an output array with only 1 element, losing all the other 89,999. If you want to divide the whole array by 65536 then divide the array by a scalar, as shown above. You will then get you full output array divided by 65536.
Rgs,
Lucither.
01-12-2011 02:13 AM
Just another quick point. You are dividing a Signed Integer array by 65536. From what you have said in your post i believe this is to scale your binary data to give a 1V amplitude sine wave. This will actually only give you a 0.5V amplitude wave as a Signed integer goes from -32768 to 32767. To Scale so your output will go from -1 to 1V you should divide by 32768.
Rgs,
Lucither.