Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Voltage input triggers sound file

I am trying to use an analog input to to play a wave file.  I saw the play sound function but I am unable to modify the parameters to respond to analog conditions.
 
For instance, when 2.0V is passed through DAQ, I want a wav file to be triggered.
 
 
Does anyone know how this is done?
 
Thanks in advance for any help.
 
 
0 Kudos
Message 1 of 8
(3,904 Views)
Hey SeniorDesign,

Thanks for contacting National Instruments support.  I assume you are working on your senior deisgn project.  Outputting a sound based on an analog voltage is certianly acheivable in LabVIEW.  There are a few things to consider however.  For instance if you want to play the sound once, then there is an example that monitors the data coming from the onboard buffer in software and sends a software trigger to output the data to a waveform, but you could do something else, like play a sound.  This example is in the Example Finder under Hardware Input and Output >> DAQmx >> Analog Measurements >> Voltage >> Cont Acq & Graph Voltage- Analog SW Trigger.vi

Or if you want to play the sound for each time it goes above 2V then you would want to send a notification to a second loop in LabVIEW to play that sound.  That would take some more coding, but it wouldn't be too bad.  You can see the LabVIEW templates for this kind of loop structure if you go to File >> New... and look through the design patterns for Events. 

Lastly, you could only want to play the sound once, so you know that reached that value, but then just keep recording.  All these scenarios are coded differently. 

Let me know if you have any more specific questions as you start coding.

Regards,


Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 2 of 8
(3,890 Views)

Thanks for the suggestion.  The example helped me learn more about Labview. My next question...

 

I would like to create a VI that simulates the following cascading if statment:

{

if voltage from analog input = X,

       initiate sound1.wav

if voltage from analog input =X again within specified time frame,

       intitate wave sound2.wave

if voltage from analog input =X again within specified time frame,

       intitate wave sound3.wave

}

I would like this to continue 50 times.  Any suggestions on how to make this work in LABVIEW 7.1?

Thank in advance,

Kurt

 

0 Kudos
Message 3 of 8
(3,850 Views)
Hey Kurt,

Long time no hear, glad to see you able to get things figured out a bit more.  There is a few ways to program what you are trying to do.  Given that you are playing sounds and, from what I can tell, you may play all three sounds in a given loop iteration you will probably want three case structures inside of a flat sequence structure.  You would have 3 frames for the sequence structure with a case structure in each frame.  Then depending on the input to the case structure you would or wouldn't play the sound.  Then when the sound was finished it would go to the next frame.  All of this would be inside of a For Loop that would iterate 50 times.

Let me know if you ahve any further questions.

Regards,
Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 4 of 8
(3,843 Views)

Kenn,

 

So instead of using the time elapsed function, the flat sequence would take care of the timing issue?  Another question, wouldnt i need 50 case structures inside of a flat sqeuence since I may play all 50 sounds in a given loop iteration?  Do the case structured have to be placed inside of eachother or just oriented somewhere inside the flate sequence frame?

 

Kurt

0 Kudos
Message 5 of 8
(3,839 Views)
Hey Kurt,

I'm not sure where your timing comment  fits in to this discussion, the flat sequence is not taking car of any timing.  I misunderstood the previous post about 50 times.  If you you would possibly want 50 sounds to play, yes one way to do it would be to have 50 case structures in 50 flat sequence frames, but that is messy.  You could probably ditch that idea entirely and just loop 50 times and pass your decision data through a shift register and make the decision to play or not play based on that data.  You could even change the decision data and put the new data back on the shift register. 

Hope this helps.

Regards,

Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 6 of 8
(3,832 Views)
I think I see where our miscommunication occured.
 
I would like a new wave file to trigger when two conditions are met;
 
1) at a specified analog voltage
 
2)  when this voltage occurs within a specified time. for example,
 
 2 volts is sent from DAq --> triggers sound file,
 another 2 volts is sent from DAq within 5 seconds of previous 2 volt analog signal --> friggers sound file 2.
 
 
Could you point me to some tutorials or other resources regarding shift registers?
 
Thanks again,
Kurt
0 Kudos
Message 7 of 8
(3,831 Views)
Hey Kurt,

There is a Learn LabVIEW 8 in 3 Hours tutorial with excersizes that goes over a lot, not just shift registers, but they are discussed in there as well.  To accomplish the timing you can use the Elapsed time vi and poll whether the 5 seconds has elapsed in your loop and when it does elapse you will need to reset the time.  The system you are describing would be well-suited for a state machine.  In LV you can go to File >> New... and in the templates area there is a State machine template that you can added states to. 

Your states would be:
Start : Initialize your hardware to start acquiring data
Analysis: determine which sound to output and go to that state, and reset or start the clock
Output Sound file 1
Output sound file 2
Time check:  Check to see when 5 seconds elapses and reset the clock or stop the clock to be restarted when the next voltage level is hit.
And finally the Stop case, where you shut things down.

Hope this helps.

Regards,
Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 8 of 8
(3,820 Views)