02-10-2009 05:22 PM
Hi,
I have an application where I am generating an arbitrary waveform on the function generator and receiving it on the digitizer after it has been passed through some different mediums. I am measuring the phase change to determine properties of the medium. The generation needs to occur on an external trigger. I have encountered the following issues.
Scenario 1. When setting the two devices to use the same reference clock and passing the fgen waveform straight to the digitizer, I can achieve a known delay of the 43 sample clock periods + 110 ns (this is good), approx 84 us at 500 kHz, however I can not get the original waveform and the waveform recorded on the digitizer to have the same phase difference when on different runs.
Scenario 2. When using Tclk to synchronize the devices, I can achieve a constant phase difference between the original waveform and the recorded waveform for multiple runs, however the fgen start is not consistent. The generation delay varies between 500 - 1000 us at 500kHz and reduces as the sampling rate increases.
For a clearer description please see the attached PNG.
Would anyone have some suggestions on how to either 1. Keep the fgen and digitizer in phase or 2. Reduce the start delay to a known constant when using Tclk?
Any help would be greatly appreciated. Below is a link to the previous thread, where I was originally being helped.
http://forums.ni.com/ni/board/message?board.id=270&thread.id=6396
Regards,
Brett
02-12-2009 05:07 PM
Brett,
Thank you for posting on the NI Forums.
In Scenario 1, are you using the same start trigger for both devices? You should be sharing a reference clock and a start trigger for both devices. Your issue with this method is that the phase is different between the devices between iterations, which would result in not using the same start trigger for both devices. You should be able to set up this method and have a repeatable phase offset between the devices which is inherent to the cabling and devices.
In Scenario 2, the issue you describe is that there is a delay from the external trigger to the start of the devices. Is there an underlying reason why you need to know the delay from the trigger to the start, but as far as both devices starting, they will start at the same time. The image you posted does not seem to indicate that the digitizer and fgen are starting at the same time, though they are sampling at the same time, but they should both be starting and sampling at the same time in this instance.
If you need to know the exact time from the trigger to the devices starting Scenario 1 will allow you to do that. You will however need to measure the phase delay from one device to the other and if you are using start triggers on both devices it should be a constant phase offset as long as the hardware is the same. If you needs to correct the phase offset between the devices you will need to use scenario 2, but you will not necessarily know the time it will take to start once you send the external trigger.
Can you please verify for me that you are providing the same start trigger for both devices in Scenario 1. Also, is there any specific reason why you need to know exactly when the devices will start their tasks based on the start trigger in Scenario 2?
02-12-2009 05:51 PM - edited 02-12-2009 05:52 PM
Hi Aaron,
In scenario 1 I have been using an external trigger for either the fgen (PFI 0) or digitizer (Ext. Trig.) then exporting it to the other device (PXI trigger line). I have also set both devices to use the same reference clock (NIScope Configure clock.vi and NIFgen configure reference clock.vi). Do I need to pass the same external trigger to both devices, do I also need to use the same interface (e.g PFI)?
In scenario 2 I have been unable to capture the start of the fgen generation. I know this because I have been generating a sine wave and have yet to capture the start of the wave, the offset ranges. I believe I just need to play around with the reference position.
The reason I need to know the start is that I am trying to map the acquisiton to a position on a wheel. One rotation of the wheel will generate a trigger and the wheel can rotate at up to 80Hz.
I do not need to adjust for the phase difference, I just need it to remain constant between iterations.
Brett.
02-12-2009 10:35 PM
Hi Aaron,
I did some testing so I can give you some numbers.
In scenario 1. With the external trigger coming to to fgen, exporting the trigger to the digitizer and both devices using the PXI clock as the reference clock.
For the fgen @ 100kHz sample rate 10K samples and digitizer @ 100kHz 10K samples. I get a delay of 25.7ns. The waveform is a 100Hz sine wave. (This is an acceptable value)
For the fgen @ 100kHz sample rate 10K samples and digitizer @ 200kHz 20K samples. I get a delay of 10us. The waveform is a 100Hz sine wave.
For the fgen @ 200kHz sample rate 20K samples and digitizer @ 100kHz 10K samples. I get a delay of 5us. The waveform is a 100Hz sine wave.
I would expect that when sampling at integer multiples the sample clocks would allign since they are still using the same reference clock?
The delay = waveform period * max phase diff between iterations/360
Cheers,
Brett
02-13-2009 10:42 AM
Brett -
I believe the delay you are seeing in scenario 1 can be explain by how you are using the trigger. To make sure that both devices start at the closest possible time to one another you will need to provide the external trigger to both devices at the same time. You will also need to make sure that the cables going from the external triggering device to the FGEN and Digitizer are the same length to prevent delay in those two devices starting at the same time. The delay you are seeing is because when you export that trigger to the other device it has some delay when going through the initial device and some delay when going across the PXI Trigger Line. If you split your trigger signal from your external device and route that signal with equal length cables to both cards you should see your delay between card starts disappear.
02-16-2009 10:44 PM - edited 02-16-2009 10:45 PM
Hi Aaron,
I am now triggering both devices using PFI and the same external trigger. Both devices are using the same reference clock.
Sample rate of both devices Maximum phase difference between iterations Waveform Period Delay
KHz 0.36 degrees 0.01s 10us
1MHz 0.036 degrees 0.01s 1us
KHz 2.5 degrees 0.01s 69us
This is worse than what I was achieving when using the backplane to pass the trigger from the fgen to the digitizer.
At KHz for both devices and a waveform period of 0.01s the delay was approx 25ns
The delay is approximately 1 clock period, giving the impression that the devices reference clocks are not aligned.
Is there something simple I am doing wrong in the code that could fix the problem?
The code I am using is the driver_new.vi
Brett
02-17-2009 05:01 PM
Brett,
We were able to run your code on one of the test systems that we have set up here with the exact same hardware as you have. When we ran your code we watched the phase between the Scope and the FGEN and they remained almost constant, they had very little difference between the two of them. As far as the delay you are experiencing it is completely within the specs for the device. The specs give that delay relative to the period of the waveform and all those delays are within the appropriate specs. I would recommend going back to having the trigger route through the backplane if that gave you better results than you currently have. Also, we found that by starting the Digitizer first before the FGEN gave us a better phase result. While the phase was not perfectly aligned you can assume the 1 degree error between his FGEN and Digitizer phase and work from it. You will not be able to get perfect phase alignment reliably without using T-Clk, but you will not be able to know the delay while using T-Clk. That is the tradeoff between sharing triggers and reference clocks and using T-Clk.
02-17-2009 05:16 PM
Aaron,
Are there any other options in terms of additional hardware that will allow the phase to be better alligned?
We also have a PXI-6221 available if that would help at all?
Cheers,
Brett
02-18-2009 09:23 AM
Brett,
The current system that you have is your best option for keeping the phase aligned. The other option was to use T-CLK which might have aligned the phase better but then you would have to deal with the FGEN start not being consistent.
02-18-2009 04:29 PM
Hi Aaron,
Would there be any benefit for synchronisation if using a card that can generate and recieve the signal?
For example would using the PXI-6120 allow better synchronisation if using an external trigger because the input and output will be on the same internal sample clock?
Thanks
Brett