High-Speed Digitizers

cancel
Showing results for 
Search instead for 
Did you mean: 

two channel timing measurment

I have a PXI-5112 digitizer and am trying to learn how to use it to make measurements in LabView 7.1. I have been able to make single channel scalar measurements, such as frequency, RMS voltage, etc. However, I now need to write code that takes a timing measurement between the two channels, something along the lines of a propagation delay measurement.
I want to start a timer based on some kind of (probably digital) trigger on one channel, and then stop the timer based on a trigger on the other channel.
I cannot figure out how to get started, and I cannot find any examples of a measurement like this.
0 Kudos
Message 1 of 11
(10,727 Views)
Delay measurements are part of the NI-SCOPE API. The attached example assumes you are digitizing two TTL level (0V - 5V) pulses on the two channels. The first channel is used for triggering the scope. The second digitizes the delayed pulse. The delay measurement takes the time difference between the two. There is a lot of configuration you can do around this basic technique, but that should get you on your way. Good luck.
Message 2 of 11
(10,718 Views)
I'm attempting to do the same thing, but I need to do it from a piece of legacy VB6 code that needs to be updated to support the digitizer. Can you perhaps tell me howto achieve the delay measurement using the NI-SCOPE API from VB6?

Thanks
0 Kudos
Message 3 of 11
(10,660 Views)
Hey FlexSA,
I assume that you do not have a copy of LabVIEW to look at the previously-attached code. I will translate the simple example into the NI-SCOPE functions that you will have to call. I will tell you also what each function will need to set. You will need to open the NI High-Speed Digitizers Help from your Start Menu (Windows Start Menu>>National Instruments>>NI-Scope>>Documentation)and figure out exactly how to call each function to achieve the desired effect.

niScope_init //you need to send this function the resource name of the digitizer in MAX
niScope_AutoSetup //nothing but the session handle is needed
niScope_ConfigureTriggerEdge //you need to tell this function that you have a positive edge triggering off of
//channel 0 (the trigger level is set at 1.5 in the other person's code, you put
//in what you need)
niScope_SetAttributeViString //Set the Attribute named "NISCOPE_ATTR_MEAS_OTHER_CHANNEL" to "1"
niScope_InitiateAcquisition //nothing but the session handle is needed
niScope_FetchMeasurement //use this to get "NISCOPE_VAL_TIME_DELAY " from Channel "0" with a timeout of 5 seconds
//this returns the time Delay
niScope_close //nothing but the session handle is needed

This should be all you need. Good luck and thank you for choosing National Instruments!

Sincerely,
Gavin Goodrich
Applications Engineer
National Instruments
0 Kudos
Message 4 of 11
(10,650 Views)
Thanks for the speedy reply, Gavin. That code worked just fine.
0 Kudos
Message 5 of 11
(10,626 Views)
OK, I was just going through the documentation for the functions used in the code-sample above, because the measurements that the code sample produced seemed a little off, and I have one more question for you:

According to the doc for NISCOPE_VAL_TIME_DELAY, "The algorithm finds the first time that the waveform from channel 0 crosses its mid reference level. Next, the algorithm finds the first TWO times that the waveform from channel 1 crosses its mid reference level. The time delay is the time between two edges with the same slope."

Am I correct in understanding that NISCOPE_VAL_TIME_DELAY will measure the time between the first two positive peaks on the channel 1 wave-form? The waveform on channel 0 is simply used to trigger the beginning of that measurement but does not affect the time delay directly.

If this is the case then this does not correctly solve my problem. I need to measure the time delay between the first peak on the channel 0 waveform and the first peak on the channel 1 waveform. I am measuring the velocity of an object as it passes two points. Each of these two points is represented as a separate waveform on the digitizers channels, point A is Channel 0, point B is Channel 1. The distance between point A and point B is known and constant. What I need to do is measure the time that elapses between the time that the object passes point A and the time the object passes point B.

Currently, my code (VB6) looks as follows:
niScope_ConfigureTriggerEdge (vi, "0", 1.0, NISCOPE_VAL_POSITIVE, NISCOPE_VAL_DC, 0.0, 0.0)
niScope_SetAttributeViString (vi, "0", NISCOPE_ATTR_MEAS_OTHER_CHANNEL, "1")
niScope_InitiateAcquisition (vi)
niScope_FetchMeasurement (vi, "0", 1.0, NISCOPE_VAL_TIME_DELAY, scalarResult)

How would I need to change the above code sample to get the desired results? Also, there is a separate function where I need to send n objects past points A and B in rapid succession and then calculate the average velocity and standard deviation as well. I assume that will be accomplished by adding the following:
niScope_FetchMeasurementStats (vi, "0", timeout, NISCOPE_VAL_TIME_DELAY, scalarResult, Mean, Stdev, Min, Max, numInStats)

Thanks again for your input.
0 Kudos
Message 6 of 11
(10,622 Views)

Message Edited by gaving on 03-29-2005 02:43 PM

0 Kudos
Message 7 of 11
(10,617 Views)
Hey FlexSA,
OK, I had to get clarification myself. The measurement returned IS the one you want. The confusion is where it states that the first two times the second channel crosses the reference point is returned. Basically, here is a breakdown:
1. The first channel crosses the reference point(note the slope-either positive or negative)
2. The second channel's next two times it crosses the reference point are recorded (i.e. grabs one positive and one negative slope)
3. The time the second channel crossed with the correct slope is subtracted from step 1.

I hope this makes more sense. I know I needed the clarification myself.

Gavin Goodrich
Applications Engineer
National Instruments
0 Kudos
Message 8 of 11
(10,612 Views)
Excellent! Thank you for the clarification. It appears that the discrepancy in test results I was seeing earlier was due to a slight shift of a sensor at point B, which threw off the calculations by about 5%
0 Kudos
Message 9 of 11
(10,601 Views)
I have a similar beginner's problem: I need LabView to monitor channel 2 (on an NI-DAQ card) for trigger indication, time-stamp it, then monitor channel 1 for impact and time-stamp the initial impact. Basically, I need measure the time between when channel 2 turns on and when channel 1 begins to read data (on the rising edge of the waveform). I have been successful in monitoring the channels. However, I think there is a flaw in the way I'm measuring the time difference.
0 Kudos
Message 10 of 11
(9,655 Views)