Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

PCI-6601 reading pulse without stopping the counter

Solved!
Go to solution

Hi, the problem seems to be simple, just at the moment I have not came with a reasonable solution. I am programming the 6601 counter for the following action using my own driver routines  (in C++ visual studio 2008) for writing/reading the registers. I closely follow the DDK examples. I started with example 1 and 4 and it works fine, and now have to somehow come with the following code:

1. I use external 10MHZ precise signal from the H. MAser as input to the counter.

2. I start the counter with software arm and am able continuously to read the values of the counter.

3. I want to simply read a single pulse (1PPS) and do absolute time  synchronization of the counter to UTC. It should simply give me the counter reading of the rising edge of PPS signal  but after that it should be possible to read the counter as usual by reading the save register values, so reading pps without stopping, or loading anything from counter registers a or b, simply give the reading of one pulse and continue further same as in 2..

 

 

Any suggestions?

0 Kudos
Message 1 of 3
(4,838 Views)

Hi Kirco,

 

You'll probably get a better response posting to the Driver Development Kit forum on this one.  I wish I could offer more help.

 

-John

Message Edited by John P on 10-30-2009 09:05 PM
John Passiak
0 Kudos
Message 2 of 3
(4,814 Views)
Solution
Accepted by topic author Kirco

Hi,

problem solved, but anyway for anyone who might have similar task, here is the rough excerpt of what I have done (the code and function names are similar to the DDK but has nothing to do with the DDK)

void yourclass::yourppscountfunction()

m_stopPPS=false;
 
//first reset internal values
 card1.Write_G01_Joint_Reset_Register_G0Reset(); //reset counter 0
 card1.G0_Reset_Registers_Values();//reset internal values
  //Disarm
 card1.Write_G0_Command_Register_Disarm(true);
    //load initial value of 0
 card1.Write_G0_Load_A_Register(0x00000000);//counter should start with 0
 card1.Write_G0_Command_Register_G0_Load();//tells to load initial counter value of A register
 //set source to external time base
 card1.Write_G0_Input_SelectRegister_SourceSellect(1);
 //select the pin dedicated to gate sellect (default in this case PFI_38)
 card1.Write_G0_Input_SelectRegister_GateSellect(1);
 card1.Write_G0_Mode_Register_Gating_Mode(2);//rising edge gating
 card1.WriteIO_Config_Reg_Pin36_Select_out(); //configure the pin PFI_36 to drive the output
 card1.Write_G0_Mode_Register_Output_Mode(1);//on out is the TC, connect this to counter2 to count the rollovers
 //configure the pin PFI_36 to drive the output (not done here)
 card1.Write_G0_Mode_Register_Trigger_Mode_For_Edge_Gate(3);//gate not used for starting or stopping
 card1.Write_G1_Command_Register_Synchronized_Gate(true);
 card1.Write_G0_Command_Register_Up_Down(1);//counting direction up
 
 card1.Write_G0_DMA_Config_Register_DMA_Enable(true);
 card1.Write_G0_DMA_Config_Register_DMA_Int_Enable(true);
 
 //arm the counter
 card1.Write_G0_Command_Register_Disarm(false);
 card1.Write_G0_Command_Register_Arm(true);
 //WRITE THE VALUES TO COUNTER
  
 card1.G0_Write_Mode_Registers();
 card1.G0_Write_G0_Input_Sellect_Registers();
 card1.G0_Write_G0_DMA_Config_Registers();
 card1.G0_Write_Command_Registers();
while(!m_stopPPS)
{
 PeekAndPump();
 //now loop to see if any PPS measurements available, if yes, read them and display
 if(card1.Read_DMA_Status_Register_G0_DRQ_Status()) //if something saved
 {
  unsigned long int counterValue1;
  
  int HWSaveorSWSave;
  HWSaveorSWSave=card1. Read_DMA_Status_Register_G0_DMA_Readbank();
  if(HWSaveorSWSave==1)
  {
   counterValue1 = card1.Read_Save_Register();
   m_editPPSreading=counterValue1*1.E-7;
  }
  else
  {
   counterValue1 = card1.Read_HW_Save_Register();
   m_editPPSreading=counterValue1*1.E-7;
  }

this->UpdateData(FALSE);
 }//if something red

} //while
card1.Write_G0_Mode_Register_Gating_Mode(0);//gating disabled
card1.Write_G0_DMA_Config_Register_DMA_Enable(false);//disable dma
card1.Write_G0_DMA_Config_Register_DMA_Int_Enable(false);//disable interrupts
card1.G0_Write_G0_DMA_Config_Registers();
card1.G0_Write_Mode_Registers();

 

 } //after this, you might read normally the counter (the PPS values are added to reading as offset to UTC ->not done here)

 

 

 

 

//for stop reading PPS and continue as normal counter where values are red simply from the SW save registers
void yourclass::yourstopppscount()
{
m_stopPPS=true;
}

Message 3 of 3
(4,804 Views)