NIDAQ External Clock Synchronization
bhclowers
More importantly I need to synchronize an external event that operates at a frequency of 10-20 kHz that can be accessed through a TTL signal. This TTL signal has negative peaks that last about 2 us which could potentially be used as trigger events and march through each row in a waveform.
To make things a little more complicated I'd like to use a master trigger event to start looking for the external clock and march through the custom wave. Any help would be greatly appreciated. I've tried the general waveform generation panel but when using an external master trigger and an external clock there seems to be a discrepancy as to when the waveform repeats. I would very much like the master event trigger to reset the waveform playback and interrupt any current playback to start a new one.
Cheers,
Brian
Here is a line of code that illustrates such usage:
Lookup the IGOR NIDAQ Tools Manual for the proper syntax and flags, and check your device specs to be sure they are applicable.
July 9, 2015 at 04:23 am - Permalink
DAQmx_WaveFormGen/DEV="dev1"/CLK={"/dev1/PFI10", 0}/TRIG={"dev1/PFI6"} "wave0, 0;"
I haven't actually tried this command...
It is intended to tell NIDAQ Tools to run your waveform generator with samples from a wave called "wave0", output through analog output channel 0, using PFI6 as the waveform trigger, and PFI10 (which is pretty arbitrary) as the waveform sample clock. I heartily recommend getting the waveform output to work using an internal clock before trying to use the external clock!
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
July 9, 2015 at 09:44 am - Permalink
Thanks for the suggestions. I am able to get the output waveform triggered and using an external clock to march through the waveform. The problem I am running into now has to do with the retriggerable nature of the process. While I would like the input clock to dictate which row of the waveform is output I would like the start trigger to reset the process and am not sure how to do this.
In essence, I'd like to have one period of the waveform that can be interrupted by an external trigger and started again immediately.
It seems like there was another function (e.g. http://www.igorexchange.com/node/5601) that you added a repeat function to that appeared helpful. I'm not sure this can be done with the DAQmx_WaveFormGen function, however, is there another combination of functions that might achieve the desired result.
Perhaps a clever way of using a hook to reset the trigger? Any help would be appreciated.
Cheers,
Brian
September 3, 2015 at 10:22 pm - Permalink
To refresh outline of the problem I am trying to solve, I have a master pulse that occurs every 6 seconds that is timed by another clock running at 16.667 kHz. I want the master trigger to start the playback of a waveform using the external clock at 16.667 kHz to march through the output waveform row by row. The key difference here is that I want the system to start back at first row of the playback waveform at each master trigger event. In my estimation I need to use the external clock as there is some amount of jitter involved with the master pulse so I can't simply set the period and let it ride. Again, any help is greatly appreciated.
#include <NIDAQmxWaveScanProcs>
#include <NIDAQmxWaveFormGenProcs>
#include <NIDAQmxPulseTrainGenerator>
#include <NIDAQmxSimpleEventCounter>
#include <NIDAQmxChannelSelectorProcs>
Function TestDaq()
resetDevice()
Variable numPeriods = 1//set to 0 for infinite
String EOSH
try
EOSH="endHook()"
DAQmx_WaveFormGen/DEV="dev2" /CLK={"/dev2/PFI5", 0} /TRIG={"/dev2/PFI0", 2, 1, 2.5} /NPRD=(numPeriods) /EOSH=EOSH /ERRH="errorHook()" "root:wave0, 0;"//outputWave, Channel
catch
print fDAQmx_ErrorString()
endtry
End
Function GoAgain()
DAQmx_WaveFormGen/DEV="dev2" /CLK={"/dev2/PFI5", 0} /TRIG={"/dev2/PFI0", 2, 1, 2.5} /NPRD=1 /EOSH="endHook()" /ERRH="errorHook()" "root:wave0, 0;"//outputWave, Channel
End
Function resetDevice()
Variable resetRtn
fDAQmx_WaveformStop("dev2")
resetRtn = fDAQmx_ResetDevice("dev2")
print resetRtn
End
Function errorHook()
fDAQmx_WaveformStop("dev2")
print "Error"
print fDAQmx_ErrorString()
End
Function endHook()
//Variable numRepeats = 1
//fDAQmx_WaveformStart("dev2", numRepeats)//doesn't produce the desired cyclic repeat it will only repeat once and then stop--doesn't loop.
GoAgain()
print "Repeating"
End
September 4, 2015 at 02:42 pm - Permalink
1) You can't have a fractional period. You will have to put up with a brief period of static output level when the last waveform period ends.
2) It silently occupies one of your counters to count the waveform periods.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
September 8, 2015 at 11:07 am - Permalink