LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger event with digital input

Hi all,

I've written a code that reads an input signal (35 ns wide) -> changes the width (to 800 ns wide) and than uses this signal as an external clock for Period measurement and Voltage measurement. I've attached the application below.
I have another incoming signal (TTL) that I would like to know its period measurement but unfortunately I ran out of counters (I'm using the pci-6251).
I tried to record the time with software every time a digital input port changes its state but it seems to be inaccurate.

If I can use a digital input port to  trigger an event that  saves the data and initializing it that would do the trick. Is that possible?

Thank you,
Eyal

0 Kudos
Message 1 of 8
(6,403 Views)
Hi Eyal,

Are you checking the digital input port statically or dynamically?  In other words, are you using a clock to time when the digital input checks the port?  If you're statically checking the port, that would explain the innaccuracies in your period measurement.  I don't believe that using any daqmx events would give you a better response.  I would take a look at the example here on correlated digital even counting.  One other option would be to just use an analog input at the maximum rate.  Depending on the speed of the TTL signal, this might be accurate enough to make a period measurement.  If these options won't work, you might take a look at some of our lower cost USB devices that have counters to supplement your hardware with the additional counters you need.

Regards,
Paul C.
0 Kudos
Message 2 of 8
(6,376 Views)
Hi Paul,

Thank you for your reply. I was checking the port statically and I guessing that was the reason for the inaccuracy. However, when I check it dynamically I run into different problems.
The internal clock with the lowest frequency I can use is 10MHzrefclock. When I try and use it I get I get an error (attached a screen shot of the error). I also realized that I need a clock with at least a 5MHz resolution otherwise I might miss the high state of the signal (which has a width of 200 ns).
I think the low cost USB might be a good option for me I just have one concern: if I understand correctly it is not possible to synchronize a period measurement on the pci-6251 and a period measurement on the low cost USB device. Is this really the case? Because if it is it might be a problem.

Eyal

0 Kudos
Message 3 of 8
(6,367 Views)
Hi Eyal,

Unfortunately, that signal is just too fast for an analog input to measure.  In regards to the questions about the low-cost USB DAQ, the USB-6008 and USB-6009 cannot use the period measurement task.  My recommendation would be to either purchase the counter/timer cards that include more counters such as the 6608 (this would easily synchronize) or purchase and additional m-series card (such as another 6251).  We do have some USB M-series cards that would work  If you have two m-series cards you can synchronize them using a start trigger and phase-lock looping (PLL) the two timebases together.  This requires a slower clock to PLL two (one within the RTSI bandwidth) and the RTSI cable between the two cards.  Unfortunately, the easiest way would be to generate this clock (typically 10MHz) from one of the counters (which uses up one of the 4 counters).  I'm assuming by synchronized you want the two timebases aligned such that two signals measured will always return the same period measurement.  Please clarify if that isn't the case.

Regards,
Paul C.
0 Kudos
Message 4 of 8
(6,346 Views)
Hi Paul,

Thanks again for your reply.

What I meant by synchronized is that the period measurements begin on the same edge of the timebase such that the starting time of both is exactly the same.

I'm currently using 2 counters and an analog input channel (at the maximum sampling rate of 1.25MHz). It seems like I would have to use another counter which means I need to use 3 counters and an analog input channel that has a sampling rate of 1.25MHz (or higher but I don't think such thing exists). I could not find one card that can combines all of the above. In case I buy another m-series card, do I have to compromise about the resolution of the period measurements? Will I still have a resolution of 80MHz on each card (assuming the second card will also have a 80MHz clock)? It seems like I would be using all 4 counters (one for synchronization) and an analog input channel in this case.

I have a back up plan of using another counter instead of the analog input channel. In this case I would have to synchronize 3 period measurements (+use  another counter to generate a signal). It seems like both the 6608 and the 6602 are good options. The price difference is really big, is there an advantage of using the 6608 for my application?

Eyal


0 Kudos
Message 5 of 8
(6,338 Views)
Hi Eyal,

The optimal solution for the period measurements would be to use the 6608.  This is because the 6608 uses a higher precision clock to generate the 80MHz timebase.  This increase in stability and accuracy of the clock improves the period measurement.  The 6602's clock is 50ppm while the 6608 has a clock at 0.075ppm (parts per million).   For example, a 10MHz clock with 50ppm is 10MHz +/- 500 Hz (10MHz * 50 * 10^(-6)).  The same 10MHz clock with 0.075ppm is 10MHz +/- 0.75Hz.  I would also like to add that the 6251's clock is 50ppm.  You will need to decide how much stability and accuracy are required for your measurement to determine whether or not the 6608 is required.  

In regards to synchronizing two m-series cards, it is actually pretty simple and I wasn't fully complete in my explanation.  You won't actually have to use one of the counters.  We have a reference clock available that you can export to synchronize the timebase's of both devices.  All you need to do is share the reference clock from one device to the other device and share a start trigger.  So, with two m-series cards, you would get 4 counters and several analog inputs.

Regards,
Paul C.


Message Edited by Paul C. on 07-11-2008 02:48 PM
0 Kudos
Message 6 of 8
(6,327 Views)
Hi Paul,

I am using a NI DAQ USB 6251.  Basically what I need it to do is pretty simple.

* DAQ card generates sine wave - 23Hz and 2.5V with 2.6V offset  (i.e. D/A)
* This signal is then used to drive a device, which then generates an output to be monitored by the DAQ card (A/D)

Problems:
1) I see the signal and the DAQ behaves the way it should except that the received waveform (on XY plot) just keeps on going (i.e. its not triggered and still - as it should be on a normal oscilloscope).

2) I would also like to see the sine waveform that I generate so that I can see where I am triggering it from. 

Can you please propose any solutions.  My VI is attached.   Btw the VI is a modified version of the one given in the NI examples called: Multi-Function-Synch AI-AO


Thanks

Sairam

0 Kudos
Message 7 of 8
(6,252 Views)

Hi zientist,

The reason why your waveform keeps on going is because although you have a start trigger for both the generation and acquisition, you are not generating any reference trigger for your data. Therefore since you are doing a continuous acquisition, you are simply reading a set number of samples in your buffer from where your last read left off. If every chunk of data that you read from this buffer does not align with an integer multiple of your input signal period, then every read operation will return a slightly shifted set of results. So unless you are taking the right number of samples, this will give you the impression that your data is shifting in phase on your graph. One way around this would be to calculate prior to your data acquisition the exact number of samples that will correspond to an integer multiple of your input signal period and acquire that many samples for your read. However, if you change the period of your input signal, you may have to recalculate this number. If this is an issue, you should be able to programmatically set the right number of samples to acquire by using a Counter task to measure the period of your input signal and use this value to set the appropriate value.

The other option would be to use an Analog reference trigger so that the data that is acquired always starts at the same point in your signal. However, this feature only works when doing a finite acquisition, thus once the data is acquired, you will have to restart the program to acquire more points.

To answer your second question, if you also want to plot the signal you are generating, you can wire your output to another channel and read off of multiple input channels to plot them on the same graph.

I hope this helps,

S_Hong
National Instruments
Applications Engineer
0 Kudos
Message 8 of 8
(6,213 Views)