11-13-2009 08:20 AM
I would like to synchronize the clocks of two counters to figure out the offset between them. Th floowing worked in Traditional, but not sure how to so that in NIDAQmx.
//Set Up Clock Counter
int Status = pGPCTR_Control(m_NIDeviceNumber, ulGpctrNum, ND_RESET);
if(Status){
AfxMessageBox("Could not Reset Clock Control.",MB_OK);
return FALSE;
}
Status = pGPCTR_Set_Application(m_NIDeviceNumber, ulGpctrNum,ND_BUFFERED_EVENT_CNT);
if(Status){
AfxMessageBox("Could not Set up Clock Buffering Event.",MB_OK);
return FALSE;
}
unsigned long Resolution = ND_INTERNAL_100_KHZ;
if(m_NIClockResolution==1)
Resolution = ND_INTERNAL_20_MHZ;
Status = pGPCTR_Change_Parameter(m_NIDeviceNumber, ulGpctrNum, ND_SOURCE,Resolution);
if(Status){
AfxMessageBox("Could not Set Counter to internal Clock.",MB_OK);
return FALSE;
}
Status = pGPCTR_Change_Parameter(m_NIDeviceNumber, ulGpctrNum,ND_GATE,Gate);//ND_PFI_7);
if(Status){
AfxMessageBox("Could not Set Counter SCANCLOCK/PFI7 Pin",MB_OK);
return FALSE;
}
unsigned long Polarity = ND_LOW_TO_HIGH;
if(HighToLow)
Polarity = ND_HIGH_TO_LOW;
Status = pGPCTR_Change_Parameter(m_NIDeviceNumber, ulGpctrNum,ND_GATE_POLARITY,Polarity );//
if(Status){
AfxMessageBox("Could not Change Polarity",MB_OK);
return FALSE;
}
Status = pGPCTR_Change_Parameter(m_NIDeviceNumber, ulGpctrNum,ND_INITIAL_COUNT, 0);
if(Status){
AfxMessageBox("Could not Set Counter to Zero",MB_OK);
return FALSE;
}
Status = pGPCTR_Change_Parameter(m_NIDeviceNumber, ulGpctrNum,ND_BUFFER_MODE, ND_CONTINUOUS);
if(Status){
AfxMessageBox("Could not Set Counter Buffering Mode",MB_OK);
return FALSE;
}
Status = pGPCTR_Config_Buffer(m_NIDeviceNumber, ulGpctrNum, 0,BufferSize,Buffer);
if(Status){
AfxMessageBox("Could not Configure Buffering Mode",MB_OK);
return FALSE;
}
Status = pGPCTR_Control(m_NIDeviceNumber, ulGpctrNum, ND_PROGRAM);
if(Status){
AfxMessageBox("Could not Set Clock Control",MB_OK);
return FALSE;
}
if(SyncToGpctrNum>0 && pGPCTR_Watch!=NULL){ //How do I get this done in NIDAQmx ???
pGPCTR_Watch(m_NIDeviceNumber,SyncToGpctrNum,ND_COUNT,&watchValue);
pGPCTR_Watch(m_NIDeviceNumber,ulGpctrNum,ND_COUNT,&watchValue1);
m_NIClockOffset=(watchValue-watchValue1);
11-16-2009 05:15 PM
11-23-2009 10:16 AM