Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Counters Synchronization

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);

0 Kudos
Message 1 of 3
(5,022 Views)

Hi SoftwareGuy2009,

 

What hardware are you using?

Regards,
Jim Schwartz
0 Kudos
Message 2 of 3
(4,992 Views)

Hi SoftwareGuy2009,

 

Could you give me an idea of what you are trying to do?   You can find examples for DAQmx at Start>>Programs>>National Instruments>>NI DAQ>>Text Based Code Support.  These will give you a good idea of how to use your device with DAQmx. 

Regards,
Jim Schwartz
0 Kudos
Message 3 of 3
(4,953 Views)