03-30-2009 04:41 AM
I am using PXI-5124 digitizer and developing codes in C++ for measuring the time delay between 2 channels. I set the trigger to channel 0. I need to measure the delay time of CH0 RISING to CH1 RISING, CH0 RISING to CH1 FALLING, CH0 FALLING to CH1 RISING, CH0 FALLING to CH1 FALLING.
I encountered the following problems.
1. When I tried to inverted to signals by using niScope_AddWaveformProcessing() function, I needed to call the NISCOPE_VAL_ARRAY_GAIN twice. Second call with gin=1. Otherwise, the waveforms being feteched were not inverted. This happened to both channels. Here is the code I am using.
niScope_SetAttributeViReal64(session,"1",NISCOPE_ATTR_MEAS_ARRAY_GAIN,-1));
niScope_AddWaveformProcessing(session, "1",NISCOPE_VAL_ARRAY_GAIN));
niScope_SetAttributeViReal64(session, "1",NISCOPE_ATTR_MEAS_ARRAY_GAIN,1));
niScope_AddWaveformProcessing(session,"1",NISCOPE_VAL_ARRAY_GAIN));
niScope_FetchArrayMeasurement(session, "1", timeout, NISCOPE_VAL_ARRAY_GAIN, actualRecordLength, wave[channel], &wfmInfoPtr[channel]));
// Code that write the wave[] to a file for checking
2. Even though with above method to get an inverted code, I cannot get a correct results for CH0 FALLING to CH1 RISING. Also, I am not sure if the other delays are correct or not.
Please see the attachment for the codes of the functions dgz_measure() and NI_DGZ::meas_delaytime();
Other scalar measurements seem ok. I have also tried FFT, it should be ok too.
What did I do wrong? Is there any example code for time delay?
I have checked the AdvancedMeasurementLibrary already.
Solved! Go to Solution.
03-30-2009
01:32 PM
- last edited on
01-27-2025
03:46 PM
by
Content Cleaner
Hi kkwong,
The following lines should be all that are required to change channel 1 to be inverted and measure the delay of channel 1 relative to channel 0.
niScope_SetAttributeViReal64(session,"1",NISCOPE_ATTR_MEAS_ARRAY_GAIN,-1));
niScope_AddWaveformProcessing(session, "1",NISCOPE_VAL_ARRAY_GAIN));
niScope_FetchMeasurement(session, "1", timeout, NISCOPE_VAL_TIME_DELAY, ScalarResult);
The first two lines can be added to the Advanced Measurement Library example, selecting the Scalar Measurement as "Time Delay", processing step "none" (since you hard coded the step) and Array Measurement as "none" to see the inverted and non-inverted signals displayed.
There was a bug fix in NI-SCOPE 3.5 which "Fixed an issue where applying gain to waveform data using the NI-SCOPE measurement library processing steps could be done incorrectly for two-channel waveforms" as documented in the readme. If you are not already working with NI-SCOPE 3.5, this may explain what you are seeing. You can download the latest NI-SCOPE driver here. Refer to the readme to verify compatibility with your hardware, API and operating system.
Hope this helps,
Jennifer O.
04-01-2009 04:15 AM
Hi Jennifer
I have downloaded the NISCOPE 3.5 and updated the lib. But still have the same problem regarding to the NISCOPE_VAL_ARRAY_GAIN.
04-03-2009 04:01 PM
kkwong,
We are going to look into the issue and see if we can replicate the behavior that you are seeing with your device. I just wanted to let you know that we were working on it.
04-09-2009 01:32 PM
kkwong,
We were able to look into the issue with multiple gains applied with your 5124. We were able to run an example and verify that indeed the NI-Scope 3.5 driver does operate as it should in regard to applying gain. The issue could be cause by applying the gain multiple times in your code. I think this could be in the step listed below:
niScope_FetchArrayMeasurement(session, "1", timeout, NISCOPE_VAL_ARRAY_GAIN, actualRecordLength, wave[channel], &wfmInfoPtr[channel]));
When you call the FetchArrayMeasurement and then call NISCOPE_VAL_ARRAY_GAIN again you will be applying the gain one more time. If you are applying a gain of -1 in the processing step and then using the FetchArrayMeasurement as listed above then you would be applying a gain of -1 again getting you back to the original waveform. I believe this could be what is causing you the problem in the code. You might also try applying a gain different than -1 or 1, that way you would see an amplitude difference and you would be able to tell exactly how many times the gain was being applied to the waveform.
In the code above if you need to FetchArrayMeasurement you can always use "None" instead of using the NISCOPE_VAL_ARRAY_GAIN, and that would prevent you from applying the gain in the code again. If you could give these items a try and let me know if that takes care of the issue or not I would greatly appreciate it. Thanks.
04-19-2009 09:17 PM
Hi Aarron,
It works fine now. What it needs is calling niScope_FetchArrayMeasurement after setting Attribute. There is no need to call niScope_AddwavefromProcessing. Both niScope_FetchArrayMeasurement and niScope_AddwavefromProcessing will peform the operation. So, if I called both of them, the operation will be performed twice. Here is the code that works.
niScope_SetAttributeViReal64(session,"1",NISCOPE_ATTR_MEAS_ARRAY_GAIN,-1));
niScope_FetchArrayMeasurement(session, "1", timeout, NISCOPE_VAL_ARRAY_GAIN, actualRecordLength, wave[channel], &wfmInfoPtr[channel]));
Many thanks!
04-20-2009 05:12 AM
Hi Aaron,
By the way, how to set the FetchArrayMeasurement to "None"? Also, I have not got the delay time measurement working correctly. I just want to measure the delay from ch0 falling edge to ch1 rising edge. Do you have any sample code for that?
05-14-2009 09:20 AM
Hi there,
I hope you have your application up and running for measuring the time between ch0 falling edge and ch1 rising edge. In case you still have questions, or if someone else is looking at this thread, I will summarize.
This process takes two steps:
1)Apply a processing step setting the array gain to -1 for ch0. This will invert channel 0 for any measurements that are taken. A fetch will return the raw data, but the fetch measurement will have the processing step applied.
2) Fetch the time delay measurement. This will measure the time between two rising edges of the data, after any processing steps have been applied. Therefore the rising edge on ch0 is actually a falling edge (since the channel is inverted).
If you wish to see the two signals without any processing, perform a fetch, as opposed to a fetch measurement step. If you wish to see the two signals with ch 0 inverted, and ch1 untouched, you call the fetch measurement function, but the measurement type is "none" instead of "Time Delay" for example. This will return data with any processing steps applied that you have previously added.