Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Simultaneously run two counters with the internal 80MHz timing

Hi, I have a programming problem about the NI PCI-6602 counter card. I want to use the internal timing signal (80MHz) as the source signal and feed two external signals to the two counters. The operation mode is the Buffered Period Measurement.
I can succeed in one counter programming by using these old DAQ functions calls in sequences:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
    iStatus = GPCTR_Control(iDevice, ulGpctrNum, ND_RESET);
    iStatus = GPCTR_Set_Application(iDevice, ulGpctrNum, ND_BUFFERED_PERIOD_MSR);
    iStatus = GPCTR_Change_Parameter(iDevice, ulGpctrNum, ND_SOURCE, ND_INTERNAL_MAX_TIMEBASE);
    iStatus = GPCTR_Change_Parameter(iDevice, ulGpctrNum, ND_GATE, ND_PFI_38);
    iStatus = GPCTR_Change_Parameter(iDevice, ulGpctrNum, ND_INITIAL_COUNT, ulInitCount);
    iStatus = GPCTR_Change_Parameter(iDevice, ulGpctrNum, ND_BUFFER_MODE, ND_CONTINUOUS);    
    iStatus = GPCTR_Config_Buffer(iDevice, ulGpctrNum, 0, ulCount, pulBuffer); 
    iStatus = GPCTR_Control(iDevice, ulGpctrNum, ND_PROGRAM);
 
    while(RunStatus)
   {
       iStatus = GPCTR_Read_Buffer (iDevice, ulGpctrNum, readMode, readOffSet, NumPtToRead, timeOut, &NumPtRead, buffer);
       m_Chart1.DoPlot(); // Plot the data
   }
 
  iStatus = GPCTR_Control(iDevice, ulGpctrNum, ND_RESET);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
But when using two counters, I tried to open two individual counter tasks by just doubling the codes above (each counter has independent DMA buffer). The program hanged forever. After debugging, the codes stop after it comes to read the 2nd DMA buffer (the 2nd line below).
 
  iStatus = GPCTR_Read_Buffer (iDevice, ulGpctrNum0, readMode, readOffSet, NumPtToRead, timeOut, &NumPtRead0, buffer0);
  iStatus = GPCTR_Read_Buffer (iDevice, ulGpctrNum1, readMode, readOffSet, NumPtToRead, timeOut, &NumPtRead1, buffer1);
 
I also tried to check the labview codes that I have for the implementation of 2 counter measurement. There are two sets of function calls for each counter, "Counter Group Configure" -->"Source Slection" --> "Gate Selection" --> "Buffer Configure", in the same sequence structure, and two "Buffer Read" calls in a later, but also the same, sequence structure. My C programming is done just by following the labview codes above. But the labview program doesn't crash like the C program. Besides, one more question that I found is that I cannot find the fundtion "Counter_Group_ConfigInterface" inside the C function library. I tried to use the function "CTR_Simul_Op" but failed.
 
So, my problem is that what's the problem about my C codes and how can I do the two counter measurement by the same internal timing base. Sorry to put all the problem in such a mess. If you need more information about my codes or my experimental requirement, please let me know. Thank you for your help!
 
Sincerely,
 
 
Jung-Cheng
0 Kudos
Message 1 of 1
(3,066 Views)