12-01-2009 10:43 PM
Compiler: VC++ 6
DAQmx 9.0.2
Card: 6602
DAQmxSetDigEdgeArmStartTrigSrc(m_hTaskHandle, "/Dev1/PFI0");
Task: Buffered Period Measurement
When used the old driver 8.7, the DAQmxSetDigEdgeArmStartTrigSrc will trigger properly when the other task turn on the PFI0. However, when we bought some new 6602 card and installed with the latest driver (9.0.2). Then the code stopped working, PFI0 will not trigger the data collection. I have to change the above trigger source to:
DAQmxSetDigEdgeArmStartTrigSrc(m_hTaskHandle, "/Dev1/PFI1");
And jumper PFI0 with PFI1, then the data collection will be triggered properly. Is this a new feature/bug for the new Driver?
By the way, I couldn't find the documentation on DAQmxSetDigEdgeArmStartTrigSrc in the 9.0.2 help file either. Anyone knows where is the official doc on this function.
Thanks for the help.
12-02-2009 03:50 PM
Hi nyq,
This shouldn't have changed between those two driver versions. Have you tried using your old 6602 with the new code and the new driver? It is possible there could be an issue with your new 6602.
I was able to find the DAQmxSetDigEdgeArmStartTrigSrc in teh NI-DAQmx C Reference Help. The image is below.
12-02-2009 04:27 PM
Jim,
Thanks for the reply and email.
We don't have the old cards. They are being used in the plants. We did try two more cards. They behaved the same. This afternoon, we uninstalled the 9.0.2 driver and installed 8.7.1. PFI0 triggered the data collection as it should be. This works no matter we compiled our code with 8.7.1 lib/.h or 9.0.2 lib/.h files. So it seems that the problem was in the driver itself. The thing is that PFI0 is configured as output to trigger both 6602 and another DAQ card. I wonder whether the new driver will not allow this. If we added PFI1 as input and physically wired PFI0 to PFI1, then it will make 9.0.2 happy.
The help file problem was my fault. Since 9.0.2 didn't have the "NI-DAQmx C Reference Help" listed in the Start Menu. I had to go to Program Files\National Instruments\NI-DAQ\docs to find the file. I clicked "daqmxcfunc.chm" instead of "cdaqmx.chm".
Thanks for the help.
Ning
12-03-2009 01:49 PM
Hi Nyq,
Could you try putting a 5V DC input to PFI 0 then try to read this in test panels in Measurement and Automation Explorer then try the same test with ground? If you can read the line as high and low, could you then read try running your program again with PFI 0 as the trigger input? Also, could you reduce your code to the smallest amount that illustrates the problem and post it so we can try to reproduce the same behavior here?
12-03-2009 04:15 PM
Jim,
Measurement and Automation Explorer could read PFI0 as high if I put a 5 V DC on to it and ground would be low. If I configured PFI0 as output, I could see it get turned on and off using scope by our application. However, in 9.0.2, it will not trigger the data collection. If I configure it as input, and output from PFI1, then it will trigger. In 8.7.1, no matter PFI0 is input or output, it will trigger the data collection. The code I am using looks like:
int m_iStatus;
short m_nDeviceNo = 1, m_nCh = 0;
TaskHandle m_hTaskHandle
bool CNiCounterMx_Setup(unsigned int uiNoOfPts)
{
CString s;
DAQmxClearTask(m_hTaskHandle);
m_iStatus = DAQmxCreateTask("", &m_hTaskHandle);
s.Format("Dev%d/ctr%d", m_nDeviceNo, m_nCh);
// another return value DAQmx_Val_Ticks
m_iStatus = DAQmxCreateCIPeriodChan(m_hTaskHandle, s, "", 0.00000005, 0.1, DAQmx_Val_Seconds, DAQmx_Val_Rising, m_iMeasMethod, m_fMeasTime, m_uDivisor,"" );
if (DAQmxFailed(m_iStatus)) return false;
m_iStatus = DAQmxCfgImplicitTiming(m_hTaskHandle, DAQmx_Val_ContSamps, uiNoOfPts);
if (DAQmxFailed(m_iStatus)) return false;
m_iStatus = DAQmxSetArmStartTrigType(m_hTaskHandle, DAQmx_Val_DigEdge);
if (DAQmxFailed(m_iStatus)) return false;
m_iStatus = DAQmxSetDigEdgeArmStartTrigEdge(m_hTaskHandle, DAQmx_Val_Rising);
if (DAQmxFailed(m_iStatus)) return false;
s.Format("/Dev%d/PFI0", m_nDeviceNo);
m_iStatus = DAQmxSetDigEdgeArmStartTrigSrc(m_hTaskHandle, s);
if (DAQmxFailed(m_iStatus)) return false;
return true;
}
bool CNiCounterMx_Start()
{
m_iStatus = DAQmxStartTask(m_hTaskHandle);
return !DAQmxFailed(m_iStatus);
}
bool CNiCounterMx_ReadBuffer()
{
uInt64 uNo2Read;
int32 iNumRead;
m_iStatus = DAQmxGetReadTotalSampPerChanAcquired(m_hTaskHandle, &uNo2Read);
if (DAQmxFailed(m_iStatus)) return false;
if (uNo2Read < 1) {
m_strErrMsg = _T("No data pts collected!");
return false;
}
m_vdCorrData.resize(uNo2Read);
m_iStatus = DAQmxReadCounterF64 (m_hTaskHandle, DAQmx_Val_Auto, 2.0, &m_vdCorrData[0], uNo2Read, &iNumRead, NULL);
if (DAQmxFailed(m_iStatus)) {
m_vdCorrData.clear();
return false;
}
m_uiNoOfPts = iNumRead;
return true;
}
bool CNiCounterMx_Stop()
{
if (m_hTaskHandle)
DAQmxStopTask(m_hTaskHandle);
return true;
}
short m_nDevice = 1, m_nSlot = 0;
TaskHandle m_hTaskHandleDout;
bool DOut(bool bOn)
{
uInt8 uData[1];
CString s;
uData[0] = (bOn) ? 1 : 0;
if (m_hTaskHandleDout)
DAQmxClearTask(m_hTaskHandleDout);
m_iStatus = DAQmxCreateTask("", &m_hTaskHandleDout);
if (DAQmxFailed(m_iStatus)) return false;
s.Format("Dev%d/port%d/line%d", m_nDevice, m_nSlot, m_nCh);
m_iStatus = DAQmxCreateDOChan(m_hTaskHandleDout, s, "", DAQmx_Val_ChanPerLine);
if (DAQmxFailed(m_iStatus)) return false;
m_iStatus = DAQmxSetSampTimingType(m_hTaskHandleDout, DAQmx_Val_OnDemand);
if (DAQmxFailed(m_iStatus)) return false;
m_iStatus = DAQmxStartTask(m_hTaskHandleDout);
if (DAQmxFailed(m_iStatus)) return false;
m_iStatus = DAQmxWriteDigitalLines(m_hTaskHandleDout,1,1,1.0,DAQmx_Val_GroupByChannel,uData,NULL,NULL);
if (DAQmxFailed(m_iStatus)) return false;
if (m_hTaskHandleDout) {
DAQmxStopTask(m_hTaskHandleDout);
DAQmxClearTask(m_hTaskHandleDout);
m_hTaskHandleDout = 0;
}
return true;
}
void Test()
{
Dout(false);
::Sleep(50);
CNiCounterMx_Setup(80000);
CNiCounterMx_Start();
Dout(true);
::Sleep(2000); //should read 2 s of pulses
CNiCounterMx_ReadBuffer();
CNiCounterMx_Stop();
}
Thanks for the help.
Ning
12-04-2009 04:41 PM
Hey nyq,
Are you using PXI or PCI form factor? It sounds like you are triggering a task on the 6602 and a task on another card with PFI 0. The best way to do this would be to use either RTSI line with the PCI form factor or one of the PXI trigger lines in the PXI form factor. This would be the typical way to syncronize tasks between 2 cards.
12-07-2009 08:28 AM
Jim,
I am using PCI format. The other Card is not from National Instrument, so we cannot use RTSI line.
Thanks.
12-08-2009 11:21 AM
Hi Ning,
I've been looking into another issue that sounds related to this one. We had a bug in DAQmx (CAR ID# 102342) that resulted in the 6602 and 6608 double driving outputs in some cases. The bug was corrected in DAQmx 8.8.
Prior to the bug fix, it seems like you were able to output and trigger off of a PFI line simultaneously. It may be that a side effect of the bug fix is that it is no longer possible to trigger off of a line you are actively outputting on on the 6602 and 6608 (6601 is to be determined). I can still do this on my PCI 6251 (M Series).
I am merely speculating here but it makes sense to me so it's something we will have to look in further. I will file another bug on the behavior you are seeing, but I'm not sure if it was ever expected behavior that triggering off of the same PFI line would work in the first place. I'll keep you updated with a CAR ID and any feedback I receive on the issue.
Best Regards,
John
12-08-2009 11:40 AM
John,
Thank you very much for the information. We definitely would like to know about your investigation. So we will not depend on this feature (bug) in the future.
Thanks.
Ning