Showing results for 
Search instead for 
Did you mean: 

Getting incremental counter/sound to work along side with taking measurements with usb-6008 with labview tia sal22

Go to solution

Getting incremental counter/sound to work along side with usb-6008 with labview tia sal22


Greetings all


I can get this vi to work if they are separate vi's but I'm having trouble joining them together 


Example of my error:


If the buffers are set to 0 the freq increment counter works but no sound
If the buffers are set to 1 the audio works fine but the Freq counter doesn't increment
If the buffers are set to greater than 1 clicks and pops happen


This is what I'm trying to do:
1) have the frequency of my internal sound card increment at a certain level like .01hz a second until it gets to 20,000hz

2) Use my usb-6008 daq device that's connected to the same machine to measure the voltage at the same time. (I'm measuring very low voltages between 1-5volts)

3)Output to a spreadsheet text file that will show:

time in seconds, sound frequency, Voltage





I'm a little confused at how to connect the incremental counter and the audio while taking measurements with the usb-6008 on the same machine
at the same time and in the same VI.

Anyone have any ideas?  I'm using labview 8.5
tia sal22


0 Kudos
Message 1 of 11

Hi Sal22,


Good Morning and I hope your well today. Thanks for your post. 


Does the sound generate code work on its own? If so thats great. 


What Id like to clarify is what you need, you are create a waveform of X number of samples to output to your sound card. Are you hoping to acquire from the 6008 once per sample, one sample per frequency waveform or a continous acuqisition from the USB device i.e. you are acquire the voltage all the time and updating the output of the sound card everytime the waveform is compelted? 


As the 6008 only supports software timing (and hence a maximum sample rate of 150Samples per second) it would NOT be possible to acquire a voltage for every sample played by the sound rate (Default Rate - 22050 S/s). I think the only option is to  either,


1) Write waveform to sound card - wait until done and then acquire, or acquire then wait until done.. you don't want to iterate the for loop again until  the previous waveform has been completed.. surely?

2) Or, you could just have two loops, one for sound card and one for continous DAQ using the 6008. The only synchronisation you would have is in software. 


Lastly, did you want a while loop within your for loop? I thought you'd just want to output the waveform then move into the next iteration of the for loop, currently this wont happen until you press the stop button. 


Please let me know what you think, I'd be happy to help! 




Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
0 Kudos
Message 2 of 11

I would like to add some comments to the honorable Mr. Hillman answer

First of all let us take a look at the USB 6008 spec. It has Max sample frequency equal to 10Khz. But that is for one channel. If you use two, both channels has to share this bandwidth so the Max sample rate is then 5Khz pr channel.  Then you are working with a sampled signal it is a "dumb" thing called Nyquist Frequency. So this will again cut your effective bandwidth in two. And all you have left is then 2.5Khz at the best sigh;).

Also let me add that the sound card is made for sound, so frequency below 20Hz may be attenuated. It depend on the soundcard. 

I will also strongly recommend two loops. One for the sound card output and one for the 6008 unit. Let the frequency be controlled from the 6008 loop. I suggest you implement two loops then you post again. You can transfer the frequency setting with a local between the two loops. I can see you are a beginner so use the local to make I easy for you. But remember to always use locals with care. Many people hate locals. But one single numeric local will not hurt your program at all

Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 3 of 11

The click and pops that hear is because the sound system in Labview 8.x has some sort of a flaw. It does not manage the buffers very well. So glitches occur then buffers are changed. And the sound will not be continuous. This worked in Labview 7.1 but has never worked with the sound system introduced in Labview 8.x

This error has been ignored by NI, but the problem shows up quite frequently in this forum. So it is a problem. So why has it not been fixed Hillman, do you have any explanation? Is it a windows problem, and therefore little that can be done or is it just ignored by NI. I have never received a proper answer Hillman, so I would be very grateful for a proper answer. I understand that you may not know the answer but you can pass it on to someone who knows .

Ps the old sound system is actually included in some addons like the tuch panel module. It can be found in ..\National Instruments\LabVIEW 8.6\vi.lib\sound\lvsound.llb

Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
0 Kudos
Message 4 of 11

Hi Coq Rouge,


Good afternoon, and thanks for your post.


Thanks for your additions to the information I posted to Sal22. 


I have always tried to fully answer all forum posts that I have posted / subscribed to and I will intend to do the same now.


I have never (myself) have an issue with continuously reading from a sound file and then playing the sound using 8.x versions of LabVIEW. Are you referring  to just when the user is creating the waveform and playing it as per Sall22 application?  A better question maybehave these forum posts previously posted any details of CAR ID#s or reproducible code?


I am aware of a number of known issues & investigations/work on the sound aspect of LabVIEW, but I would have to look into this and update this thread in due course.





Kind Regards
James Hillman
Applications Engineer 2008 to 2009 National Instruments UK & Ireland
Loughborough University UK - 2006 to 2011
Remember Kudos those who help! 😉
0 Kudos
Message 5 of 11

Thanks for the all the great replies and suggestions.  At the moment I'm just using one channel from the audio card to test with.  I was hoping to use two later on, I'll remember to limit to 2.5Khz
when and if I use two channels.  I added one local variable like Coq rouge  suggested
(one that writes) and that seems to work great. 


I'm trying to acquire a voltage just when the frequency
increments, I hope this answers your Question Hillman.

1) I changed it to two for loops and took out
the while loop but how do I get it to stop once it hits 10,000hz if
I shouldn't use a while loop? I planned on saying stop when frequency
is equal to 10,000Hz.

2) I'm trying to record voltages from 4 different Analog inputs from the
usb-6008 Daq while the Frequencies are being played from the sound card but only one voltage shows
up when I check the output text file see example output below.  How can I get the 4 voltages
to show up?


3) how do I incorporate the old National Instruments\LabVIEW 8.6\vi.lib\sound\lvsound.llb
if I wanted to see if this would fix the clicks and pops?

Thanks for all your help!!


0 Kudos
Message 6 of 11
I have made som changes in your VI. Now it is...well let me put it this way "Less awkward"

Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 7 of 11



Thanks Coq Rouge that really does make things easier to understand.  I still have the problem

where the voltages don't all show up


output text file current looks like this:




It should look something like this:





The usb-6008 daq isn't recording and send all 4 voltages that it reads out to the array does anyone know why?




0 Kudos
Message 8 of 11
Accepted by topic author sal22

Ha ha you have been tricked by a dynamic wire. Insert a Convert from Dynamic Data Express VI (Owning Palette: Signal Manipulation Express VIs) between the daq read and build array function. Then it will work. Now the value in the dynamic data is only converted to a numeric value 

Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
(Sorry no Labview "brag list" so far)
Message 9 of 11
That did it!!! Thanks
0 Kudos
Message 10 of 11