I want to measure the duty cycle of an input signal using a counter of a 6030-E board.
I work with a PXI Rack under Labwindows/CVI.
My program already works properly for duty cycle between 1% and 99%, but it is not able to detect 0% duty cycle (ie : signal to ground), nor 100% duty cycle (ie : signal to power supply).
The problem is I don't understand how the counter works in such a situation (it cannot detect any edge, as long as the signal is continuous 0V or continuous 12V).
Please have a look on the following code :
1- First, the counter is configured
// Reset Compteur
i_Status = GPCTR_Control(iDevice, iCptID, ND_RESET);
//Definition du type de mesure du compteur (mesure temps impulsion)
i_Status = GPCTR_Set_Application (iDevice, iCptID, ND_SIMPLE_PULSE_WIDTH_MSR);
//Definition de la vitesse d'echantillonage (20 Mhz)
i_Status = GPCTR_Change_Parameter(iDevice, iCptID, ND_SOURCE, ND_INTERNAL_20_MHZ);
//Definition du signal a mesurer (defaut)
i_Status = GPCTR_Change_Parameter (iDevice, iCptID, ND_GATE, ND_DEFAULT_PFI_LINE);
// initialisation du compteur
i_Status = GPCTR_Change_Parameter(iDevice, iCptID, ND_INITIAL_COUNT, 0);
// Preparation du compteur avant de l'armer
i_Status = GPCTR_Control (iDevice, iCptID, ND_PREPARE);
2- Then, every 10 ms, the value of the counter is read, so that I can calculate the duty cycle...
i_Status = GPCTR_Watch(iDevice, iCptID, ND_COUNT, ul_val_cpt);
3- ...and the counter is armed again for the next reading
i_Status = GPCTR_Control(iDevice, iCptID, ND_ARM);
When duty cycle changes from x% to 0% or 100%, the counter always keep the value corresponding to x%.
Even if I reset the counter between each measurement, it keeps this value ! I don't understand how it is possible.
How can I know that the counter didn't see any edge, and so that duty cycle is 0% or 100% ?
Thank you in advance for your help !
FraB