LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use analog recording to trigger sound presenation at a delay

Hi! I am trying to make a program that can do sound presenation based on informaton from one analog input channel. That is, I want to start to present noise when one of my microphone has received a signal with its level above a threshold. Also, I only want to do the noise presenation after 1 second of the onset of the recording. In other words, i want to ignore events in the first second after the recording system starts. As is shown in the attached file, as well as in the screen shot, I have prepared such a program. However, I continually receive the error message saying that there is some problem with the trigger setting. But why it is invalid?

 

When I read the examples showing how to use analog input to trigger recording or analog output, they always use APFI. But as I said, I want to use a specific analog input channel as a trigger source. By the way, my daq card is PXIe 6358, and thus it has the analog triggering function.

 

I know this question can be very naive and I possibly have misunderstood APFI or analog trigger in general. Please feel free to teach me.

 

"Possible reason(s):

An attempt has been made to use an invalid analog trigger source.

Ensure that the trigger source you specify matches the name of the virtual channel in the task or matches the name of a non-scannable terminal that the device can use as an analog trigger source.

Property: Start.AnlgEdge.Src
Corresponding Value: PXI1Slot2/ai0
Valid Choices: APFI0, APFI1

Task Name: _unnamedTask<6>"

 

 

 

triggeredrec&play.jpg

0 Kudos
Message 1 of 7
(3,512 Views)

You are recording sounds from a microphone.  Unless you are recording Bat calls with very fancy microphones, I don't understand why your sampling rate is 250KHz (I would think 20KHz would be more than adequate for most ambient sounds and most analog microphones).

 

Bob Schor

0 Kudos
Message 2 of 7
(3,473 Views)

Dear Bob,

    You are right! I am working with echolocating bats.

0 Kudos
Message 3 of 7
(3,459 Views)

I know a little about this subject -- when I was a Graduate Student, I spent some time with Don Griffin (looking at how birds navigate during migration when they are flying in clouds).

 

Can you say a bit more about the two channels of analog inputs?  I'm assuming (for now) that you are sampling them "simultaneously" and intend to keep them in synch.  However, one of the two channels you want to use to derive a trigger signal (from the Analog waveform) that will be used to trigger (after a 1 second delay) an Analog Output channel used as a signal (noise) generator.

 

A couple of questions.  First, is the above scenario accurate?  If so, fill in the blanks.  I assume that you are using external amplifiers and other electronics to pre-process the signals from the microphones before you start sampling it.  What are the criteria you want to use for generating the Analog Output?  If, for example, it is detecting a bat cry, might it be easier to build (or have on hand) a tiny circuit (one or two op amps) that will produce a TTL signal suitable for your Analog Out Trigger?  Something like a full-wave rectifier followed by a "low-pass filter" with, say, a corner frequency of 50KHz and a TTL output with an adjustable level?  You could incorporate this gadget into your LabVIEW code, displaying the output of the filtered rectified signal on one channel and using another D/A output to set the trigger level.  Once you have this set appropriately for your recording equipment, you shouldn't need to change it for your recording session (indeed, you might just write a separate piece of code to use when designing and testing this "Bat-Cry Detector" -- if you put an adjustable Threshold Pot on the device, you could read the Pot (instead of making the Threshold voltage as I suggested above with a DA channel) and visually set it so it discriminates between "no bat signal" and a Bat Cry.  Or you could simply use an oscilloscope during this part of the Design phase (boy, how quickly we forget our Old Tools ...).

 

I think if you can simplify and separate the A/D and the D/A parts of your code, perhaps with the introduction of a Bat-Cry Detector to serve as the trigger signal for your D/A code, you will have an easier time with development, testing, and utilization of your code.

 

Bob Schor

0 Kudos
Message 4 of 7
(3,445 Views)

Dear Bob,

    Thanks for your suggestion. It's great to know that you were working with Don Griffin. I did not have a chance to him, but his influences on us are tremendous.

    Yes, you are absolutely right that I try to make simultaneous multi-channel sound recording and use one of the input channel to trigger noise presentation. The trigger signal is bat sonar cry. Since I am working in the lab and the only interfering sounds are the noise that I present, I am sure that using the level of the bat cry as a criterion to trigger noise presenation is suitable. After I calibrate the recording system, I will have clear information about the input channels regarding how loud is the bat cry and its corresponding digtal level that will be finnaly taken as the level threshold. I did something similar during my PhD, yet with tottaly different system.

    About the suggestion of incorporating the full-wave rectifier, I did not fully get it. Do you mean to incorporate it as a hardware before DAQ sampling, or do it through software DSP after DAQ sampling? If you mean hardware manipulation, I don't have such a device at this moment. If you mean soft-ware DSP, I see another potential problem: the speed of reaction. As you can see from my codes, I will only have access to the samples in the while loop after calling the function DAQmx Read (step 4). However, the loop is a slow process and only runs every 50 ms. It can go a little faster but won't be faster than a few dozens of milliseconds. On the other hand, I want to achieve a very fast response to the bat cry, which is about 1 ms. Note here it has nothing to do with the 1 second of delay, which serves for a different purpose. Thus, this can only be done before DAQms Read or before software control. According to my understanding, NI DAQ device first samples the sounds to FIFO buffer (which is before ADC process), and the DAQmx Triggering have direct access to FIFO buffer (see inserted picture).AnalogTriggerCircuitry.png

    So my best guess for the possible solution to my problem would be sticking to the analog triggering. However, I am very new to Labview, as well as to NI devices, and I do not fully understand the concept of APFI that is used as analog triggering source in the NI examples. Is it working as another Analog input channel that I can connect a microphone to and thus use it for triggering?

    Moreover, it should be possible to use any of the analog input channels for triggering purpose. I would be very surprised that if there is no this function for NI DAQ devices 

    

    

     

    

0 Kudos
Message 5 of 7
(3,427 Views)

What I meant was the following:  Microphone -> Microphone Amplifier/signal Conditioner -> NI PXIe hardware.  I'd build a tiny circuit with a fast op amp, a few resistors, and a capacitor or two (and maybe some diodes) that would take the output of the Microphone Amplifier and produce the "envelope" of the Bat Cry (by doing the FW Rectification followed by a little analog filtering).  This device could incorporate a "Level" control (a simple potentiometer) to output a TTL signal called "Bat Cry Above Threshold" -- the rising edge of this TTL signal could be directly used as a trigger signal for producing the Analog Out signal (you'd need to create a 1 second delay, but I suspect your hardware has a Counter/Timer function that can do this for you ...).

 

It has been many years since I built my own EMG and micropipette amplifiers, but I know it is not that difficult.  Surely you have some electrical engineers around who can advise you what parts to use, and can help you with the construction.  You can probably run this little circuit with a single 9v battery (which means you'll want to include an On/Off switch to save battery life ...).

 

Bob Schor

0 Kudos
Message 6 of 7
(3,408 Views)

Thanks Bob. I will try to talk to our engineers.

0 Kudos
Message 7 of 7
(3,393 Views)