Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you compare digital input to known value

I'm using a multifunction daq to detect a 1/100 second contact closure (5v) from an auto sampler.  I'm using the digital port and I want to write a vi that says when the contact closure is detected, write a line of data.  How do I go about doing that?
0 Kudos
Message 1 of 6
(3,589 Views)

Which DAQ card are you using??

0 Kudos
Message 2 of 6
(3,573 Views)
NI-USB 6008
0 Kudos
Message 3 of 6
(3,569 Views)

Hi Nspaulding,

I want to make sure I am clear on your application.  Do you need to verify that the the closure occurs for at least 1/100 of a second?  Or is it simply detect the digital high (that lasts for only 1/100s)? 

Also, the line of data you wish to write, is this a series of bits on one digital line?  Do you need a particular data rate?  Does the data have to be written at a particular time or delay following the point at which the contact is sensed?

Since the USB-6008 does not have correlated (timed) digital I/O, the application could be designed as follows:

1) The 5V pulse could be detected by wiring it to the PFI line to use as a digital trigger.  Since the the digital task cannot be triggered, you could trigger a single point read of an analog line and perform your digital task when the read completes. Alternatively you could wire the signal to an analog input line and acquire continuously and compare the readings to a threshold value to detect the pulse.  This acquisition would be done in a while loop and the stop condition would be set when the threshold is met. 
2) Assuming your message is digital, the data line could then be toggled high and low to send your message.  This will be software timed.  You can put a delay in a loop or use a timed loop to determine when to write the next piece of data to the line.  The data maximum data rate will be system dependant and slow in comparison to working with a correlated Digital I/O device.

Assuming you require precise timing or faster data rates for the sending of the data message, you will want to look at using a multifunction DAQ board with correlated or timed digital I/O such as the M-Series DAQ boards or a digital board.  This would simplify the programming.  You could start with one of the LabVIEW examples (Help>>Find Examples) such as Write Dig Chan-Ext Clk.vi.  You would be able to use a counter to generate a clock at your desired output frequency.

Hope this helps,

Jennifer O.
Applications Engineer
National Instruments 

0 Kudos
Message 4 of 6
(3,546 Views)
This is what I'm actually trying to do.  We run a continuous melter system in which ice cores are melted, the melt water is collected by an autosampler.  I'm using a rotary optical encoder to record the change in length of the core with time as it melts.  Each time a sample vial is filled the autosampler moves forward, when it moves forward it initiates a 1/100s contact closure equalling 5v.  I want to detect this 5v pulse and use it as a digital trigger that will tell the DAQ to record the count value from the rotary optical encoder.  Effectively I'll know what length of core is in each vial.  I know very little about this program, was just thrown onto this project.  Is there a simple way to do this?
0 Kudos
Message 5 of 6
(3,517 Views)

Hi nspaulding,

This would be a simple buffered event count task (see the LabVIEW Example Finder).  A buffered event count can be set up to latch the count on a rising/falling digital edge.  Unfortunately this is not supported on the USB-6008.  This type of task requires two PFI lines, one for the counter and one to externally clock the signal.  The USB-6008 only has one PFI line.

I recommend upgrading to a USB M-Series card for this type of application.

A work around for your application with your current hardware would be to sample the autosampler signal on an analog channel. You can use a waveform measurement function (Amplitude &Level, Basic Level Trigger Detect) to determine if the 5V has connected. At the same time, you can run an edge count task on the optical encoder to continuously count. When the analog signal is above a particular threshold (i.e 2.5V) then you can log the current value of the counter.  This work around will not have precise timing; you may end up with extra counts by the time the "software trigger" occurs.  For accurate timing with the counting, you will need a device which supports buffered edge counting.

Regards,

Jennifer O.

0 Kudos
Message 6 of 6
(3,495 Views)