LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

File I/O triggered by a digital signal

Hi,

I am trying to perform data logging based on the state of a digital trigger signal. I have the following setup:
I am monitoring a digital signal through a DIO line on a 6036E device and whenever the signal goes high, I am creating a new data file and start logging the data from 16 analog input channels to this data file. Naturaly, when the signal goes low, I am stopping the data logging and closing the current file and waiting for the next logic high trigger to occur.
However, the "real" digital trigger that is going to be used is expected to ehibit some bouncing. With my current setup, this would cause creation of several data files in a short time period as the program would "see" the rapid high and low changes and act
accordingly (the loop is running at 500 Hz).
My question is: Is there a way to implement this a different way, i.e. is an external hardware debounce circuit the best way to go? Or is there a more elegant software implementation?
Thanks.
0 Kudos
Message 1 of 7
(3,686 Views)
Hardware debounce is usually a good idea. However, if you know that the minimum on and off times are much longer than the bounce, you can filter the data in software. For example suppose that the bounce results in multiple transistions for 50 milliseconds or less and you expect to record for 1 second or more. Your sample interval is 2 ms (1/500 Hz). Up to 25 samples could contain "bouncing" data. If you wait until 25 consecutive samples are high and then start recording, you will have debounced, although with a delay of up to 100 ms from the first high sample (25 bouncing samples and 25 high samples).

If the delay is unacceptable, start recording on the first high sample and then do not look for a low to stop the recording until after the signal has sta
bilized high (the 25 consecutive high samples). This is a form of hysteresis. Stop on the first low and wait for a stable low before re-arming for the next trigger.

Lynn
Message 2 of 7
(3,685 Views)
The ON and OFF times are much longer than the bounce. It will normally be ON or OFF for hours depending on the type of test. I think that this idea of looking for a number of consecutive samples before starting or stopping the recording will work out since the delay is not an issue in my setup. Thanks.
0 Kudos
Message 3 of 7
(3,685 Views)
On this topic, I was wondering how you could control your file I/O with your digital trigger because that is what I am trying to do.  I need to save data from a analog input when a digital input trigger goes high.  Thanks.
0 Kudos
Message 4 of 7
(3,554 Views)
Hi baweur2,

It looks like you need to set up a triggered analog acquisition. Once you have set up the analog acquisition to wait for a trigger, the control flow waits at the DAQmx Read VI until a trigger is received. Once it sees the trigger, the DAQmx Read VI starts to acquire and ouput the data which can be written to a file. The file writing VI will not be writing any data as long as the DAQmx Read VI is waiting for a trigger. There are many excellent examples that ship with LabVIEW that can show how to set this up. You can open LabVIEW and go to Find Examples under the Help menu. Once you have the Example Finder open go to Hardware Input and Output -> DAQmx -> Analog Measurements -> Voltage and open the Acq & Graph-Int Clk-Dig Start.vi and this will show how to set up a triggered analog acquisition.

Have a good one.

Malay Duggar
NI
0 Kudos
Message 5 of 7
(3,528 Views)
I tried that but I think that the problem I am having is that I have a digital input into the PCI card which I need to use to tell the program to sample the analog input. I also need to have a clock signal being output of the card to be sent to the device continuously for the device to give us the digital trigger. Can I use the digital trigger signal that is being inputted as my sample clock somehow to tell LabVIEW when to sample the data, while also sending a continuous digital output signal in another task?
0 Kudos
Message 6 of 7
(3,515 Views)
Hi baweur2,

Your digital task and analog task can run independently. You can use one of the pulse train generation examples to generate a clock for your other device. If you need to trigger the analog acquisition only once then you can use the examples from the Example Finder. There are some examples that also show you how to write to file. However, if you want to do a retriggerable acquisition you need to use another counter. You can find an example program that shows you how to do that by clicking here.

Cheers
Malay
0 Kudos
Message 7 of 7
(3,492 Views)