10-23-2008 11:47 AM
I can generate 2 synchronized pulse trains using this code on the first counter to generate a continuous pulse train
DAQmxErrChk DAQmxCreateTask("", ctr_taskhandle)
numSampsPerChannel = 0
DAQmxErrChk DAQmxCreateCOPulseChanFreq(ctr_taskhandle, m_ctr(counter_to_use).port, "coChannel" + Format(counter_to_use), DAQmx_Val_FrequencyUnits2_Hz, DAQmx_Val_Level1_Low, 0, frequency_Hz_or_COUNT_1, duty_cycle_percent_or_COUNT_2 / 100)
'Specify continuous timing
DAQmxErrChk DAQmxCfgImplicitTiming(ctr_taskhandle, DAQmx_Val_AcquisitionType_ContSamps, numSampsPerChannel)
'Start generating the pulse train
DAQmxStartTask (ctr_taskhandle)
and then
DAQmxErrChk DAQmxCreateTask("", ctr_taskhandle)
DAQmxErrChk DAQmxCreateCOPulseChanFreq(ctr_taskhandle, m_ctr(counter_to_use).port, "plsChannel" + Format(counter_to_use), DAQmx_Val_FrequencyUnits2_Hz, DAQmx_Val_Level1_Low, 0, frequency_Hz_or_COUNT_1, duty_cycle_percent_or_COUNT_2 / 100)
DAQmxErrChk DAQmxCfgDigEdgeStartTrig(ctr_taskhandle, pulse_triggered_by_other_counter, DAQmx_Val_Edge1_Rising)
DAQmxErrChk DAQmxCfgImplicitTiming(ctr_taskhandle, DAQmx_Val_AcquisitionType_FiniteSamps, numSampsPerChannel)
DAQmxErrChk DAQmxSetStartTrigRetriggerable(ctr_taskhandle, 1)
'Start generating the pulse train
DAQmxErrChk DAQmxStartTask(ctr_taskhandle)
on the second counter to generate a pulse triggered from the first counter timer output
However, this only works to sync the trailing falling edges of the pulses, I would really like to sync the front rising edges
Is this possible (or am i going about it the wrong way
regards nick 🙂
10-24-2008 03:44 AM
sad to answer your own post but for anyone else who want to generate 2 pulse streams locked together on the leading edges this seems to work
start the first counter with desired configuration.
then trigger a second counter with
1) DAQmx_Val_Level1_High in either DAQmxCreateCOPulseChanFreq or DAQmxCreateCOPulseChanTicks
2) DAQmxSetStartTrigRetriggerable set to 1
3)DAQmxCfgDigEdgeStartTrig triggered by the first counters internal output
4) DAQmxCfgImplicitTiming set to DAQmx_Val_AcquisitionType_FiniteSamps with 1 sample
the only extra thing is to remember to take the output of the second counter low when you stop the task (as it will naturaly stay high)
regards nick 🙂
10-24-2008 07:47 AM
I don't know any of the C-like syntax for DAQmx driver calls, but here's a couple quick comments:
1. Both counters will be driven off the same internal timebase clock, so the problem of keeping the pulse trains sync'ed on all rising edges can be reduced to gettting them sync'ed on their *1st* rising edge. (I assume here that they will be the same freq but potentially different duty cycle).
2. I would configure *both* counter tasks to use an "arm start" trigger, and be sure that both have the same value for "initial delay." This will make sure both of them sync their *1st* rising edge. After that, the internal timebase they both share will keep the rest of the rising edges in sync, assuming both pulse trains have the same freq or are some integer multiple/divisor of one another.
3. The solution you posted sounds like it works for you, but probably depends on some careful matching of pulse timing settings that weren't described in detail. Just a word to the wise for anyone else reading the thread...
-Kevin P.