01-05-2011 09:05 PM
I plan to synchronize counter PCI6602 and analog out PCI6722。6602 shares 6722’s ao/SampleClock as external clock and arm start triggered by 6722’s ao/StartTrigger。The master device is 6722, which refered as Dev1, and the slave device is 6602, which refered as Dev2. A RTSI line is used to connect the two devices correctly.
I use C API to finish my program and my code is as follows:
//config 6722 analog out task
1、DAQmxCreateTask("NI6672", &hAOTask);
2、DAQmxCreateAOVoltageChan(hAOTask, "Dev1/ao0", "", -10.0, 10.0, DAQmx_Val_Volts, "" );
3、DAQmxCfgSampClkTiming(hAOTask, "", 1000.0, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1000);
4、DAQmxWriteAnalogF64(hAOTask, 1000, 0, 10.0, DAQmx_Val_GroupByChannel, data, NULL, NULL);
//config 6602 counter task
5、DAQmxCreateTask("NI6602", &hCounterTask);
6、DAQmxCreateCICountEdgesChan(hCounterTask, "Dev2/ctr0", "", DAQmx_Val_Rising, 0, DAQmx_Val_CountUp);
//use /Dev1/ao/SampleClock for external clock
7、DAQmxCfgSampClkTiming(hCounterTask, "/Dev1/ao/SampleClock", 1000.0, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1000);
//use /Dev1/ao/StartTrigger
8、DAQmxSetTrigAttribute (hCounterTask, DAQmx_ArmStartTrig_Type, DAQmx_Val_DigEdge);
9、DAQmxSetTrigAttribute (hCounterTask, DAQmx_DigEdge_ArmStartTrig_Src, "/Dev1/ao/StartTrigger");
10、DAQmxSetTrigAttribute (hCounterTask, DAQmx_DigEdge_ArmStartTrig_Edge, DAQmx_Val_Rising);
//start counter task first
11、DAQmxStartTask(hCounterTask);
//start 6722 task
12、DAQmxStartTask(hAOTask);
I run it on the MAX virtual Device, and the Step 11 always returned error -89120。I try to slove this problem by changing the Step 7, use /Dev2/PFI9 instead of /Dev1/ao/SampleClock.
7.
DAQmxCfgSampClkTiming(hCounterTask, "/Dev2/PFI9", 1000.0, DAQmx_Val_Rising, DAQmx_Val_ContSamps, 1000);
The code runs well, but I don’t know which terminal is connected by /Dev2/PFI9. Does it connect to /Dev1/ao/SampleClock?After that, I use another API DAQmxConnectTerms to ensure that, I add a Step before Step 11.
DAQmxConnectTerms( "/Dev1/ao/SampleClock", "/Dev2/PFI9", DAQmx_Val_DoNotInvertPolarity );
The program also run well. But I am still not sure that 6602 is sharing /Dev1/ao/SampleClock。If not, which terminal of Dev1 is connected by /Dev2/PFI9?
Is my code right? If not, where's the problem? Is there any example code for me? Thanks!
01-06-2011
06:28 PM
- last edited on
02-06-2025
09:51 AM
by
Content Cleaner
Hi Shokey,
You may want to check into the DAQmxExportSignal function in the NI-DAQmx C Reference Help. You can take a look at this post for more info on how to get there. John explains, on this linked forum post, why this function is preferred to DAQmxConnectTerms. Functionally, they work similarly, but DAQmxExportSignal is a little more convenient.
That error may mean that you are trying to route something that is not available for routing, or that you may just have the name of your device mis-typed (based on what I've found.)
To see where your device can and cannot route to, you can always look at the "Device Routes" tab in your Measurement and Automation Explorer See this KB for information on how to do that:
How Can I Know What Internal Routes are Available on My Device?
Let me know if using these resources helps, or if I can clarify anything for you.
Regards,
Andrew