Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Generating pulses based on external trigger source

Hello,

I am using  NI USB-6215.

I want to write a VI that does the following:

 

1. External voltage generating source (square wave) is connected to one of the inputs of the DAQ card.

2. Generate a single pulse of square wave from one of the outputs of the DAQ card using the source mentioned in #1 to trigger (i.e. generate a pulse whenever the voltage from the external source rises).

3. Make plots for both 1 & 2 in the same plot (i.e. ai0 for #1 and ai1 for #2).

 

It seems like a simple code, but I don't have much experience with DAQmx so I need a detailed help.

 

I've tried DAQ assistant to do the DAQ write.  I've tried using "continuous sample" and get the pulses generated, but they were completely out of sync from the external source.  I think what happened was it triggered just once when it saw the rising of the external source voltage for the first time, and then tries to keep generating the pulses until I stop the code.  I guess that what I need to do is to use "N samples" but then the minimum # of samples I can specify is 2, although I want it to generate just 1 pulse for each trigerring.

 

The frequency of the square wave generated by the external source will be in ranges of 1 - 100 Hz.

Is the triggering rate be a problem with this DAQ card at this frequency?

 

Please help me.  An example VI would be very helpful.

 

Thanks.

0 Kudos
Message 1 of 4
(3,711 Views)

Hey wook,

 

Is there a reason you want to generate the same signal output, instead of just splitting the signal coming from your function generator and sending it to two different outputs?

 

Anything you try to write will have inherent delay between reading the input and outputting the signal.  The absolute fastest method would be to use FPGA and have a hardware timed method of reading in the signal and outputting it again.  However, that would require buying a new card.

 

With most M series DAQ devices, it would be possible to create a buffered digital output task that used change detection as the sample clock.  This would mean you have a digital output buffer of two points: T,F.   Then set the daqmx timing VI to use rising and falling edge change detection on the digital line that your external signal is coming in to.

 

However, USBbus powered M series devices, such as the USB-6215, do not support digital change detection.  Externally powered USB, PCI, and PXI M series cards do support digital change detection.

 

Therefore there is no hardware timing options available with that device.  Leaving the software possibility, which is that you can do a 1 sample digital read on the channel your pulse is coming in on, and then output the same value out on a different port.  Put this inside of a while loop, and you have the duplicate signal on a new port.  The problem is that there will be extremely large lag between the two signals, and the while loop will not be able to iterate fast enough to give correct output for fast signals.

 

 

 

So, the easiest would be to just split the wire, and do a digital input to read the pulse train.  If you have a 622x M series device then you could do the digital change detection technique. 

Eric S.
AE Specialist | Global Support
National Instruments
0 Kudos
Message 2 of 4
(3,694 Views)

Hi Eric,

 

I am generating the signal using the function generator just so that I can write a VI.  I will eventually replace the function generator with other source, which generates signals more randomly.

 

So, whenever the change in the signal (rise) is detected from the source,  I want the DAQ device to generate a short pulse.

 

I found an example VI from the LabVIEW help menu that does something close to what I want it to do.  The name of the VI is "Gen Voltage Update-Ext Reference.vi".

Using this VI, with the function generator connected to "APFI0," I was able to use this as an external reference and get "AO0" generate the voltage.

However, the problem is that the generated signal duplicates the exact shape of the source square wave, although I can alter the amplitude.  I want a pulse with a lot narrower width than the source width.

Is there a way to modify this width?

 

Thanks.

Message Edited by wook on 04-16-2010 01:12 PM
0 Kudos
Message 3 of 4
(3,688 Views)

Hey Wook,

Have you taken a look at the Example: Gen Digital Pulse-Retriggerable.VI? This is a good example that will generate one digital pulse with a particular number of high and low ticks every time it receives a trigger. You could specify the function generator as your trigger source and this should hopefully give you the behavior you need.

Matt
Applications Engineer
National Instruments
0 Kudos
Message 4 of 4
(3,658 Views)