LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

PXI-6602 frequency measurment

Hi

I have a problem measuring a frequency of 2.5 Mhz with counter 1 en 2 with counter 0 as a gate signal of 100 Khz

With the code snippet I get an error gpctrDataLossError (on the Watch function)
This code snippet worked fine, but now I have this error, and I have not changed anything.

checkInstErr(GPCTR_Control(iDevice, ND_COUNTER_0, ND_RESET),NI6602);
checkInstErr(GPCTR_Set_Application(iDevice, ND_COUNTER_0,ND_PULSE_TRAIN_GNR),NI6602);
checkInstErr(GPCTR_Change_Parameter(iDevice, ND_COUNTER_0, ND_SOURCE,ND_INTERNAL_100_KHZ),NI6602);
checkInstErr(GPCTR_Change_Parameter(iDevice, ND_COUNTER_0, ND_COUNT_1,ulLOWcount),NI6602);
checkInstErr(GPCTR_Change_Parameter(iDevice, ND_COUNTER_0, ND_COUNT_2,ulHIGHcount),NI6602);
checkInstErr(Select_Signal(iDevice, ND_GPCTR0_OUTPUT, ND_GPCTR0_OUTPUT,ND_LOW_TO_HIGH),NI6602);
checkInstErr(GPCTR_Control(iDevice, ND_COUNTER_0, ND_PROGRAM),NI6602);

printf(" Frequency squarewave generation started...\n");


checkInstErr(GPCTR_Control(iDevice, ND_COUNTER_1, ND_RESET),NI6602);
checkInstErr(GPCTR_Set_Application (iDevice, ND_COUNTER_1, ND_BUFFERED_EVENT_CNT),NI6602);
checkInstErr(GPCTR_Config_Buffer(iDevice,ND_COUNTER_1,0,1000,Buffer),NI6602);
checkInstErr(GPCTR_Change_Parameter(iDevice, ND_COUNTER_1, ND_SOURCE,ND_PFI_35),NI6602);
checkInstErr(GPCTR_Change_Parameter(iDevice, ND_COUNTER_1, ND_GATE,ND_OTHER_GPCTR_OUTPUT),NI6602);
checkInstErr(GPCTR_Change_Parameter(iDevice, ND_COUNTER_1, ND_INITIAL_COUNT, 0),NI6602);

checkInstErr(GPCTR_Change_Parameter(iDevice, ND_COUNTER_1, ND_BUFFER_MODE, ND_SINGLE),NI6602);

checkInstErr(GPCTR_Control(iDevice, ND_COUNTER_1, ND_PROGRAM),NI6602);


do {

checkInstErr(GPCTR_Watch(iDevice, ND_COUNTER_1, ND_ARMED,&ulArmed),NI6602);
//iRetVal = NIDAQYield(iYieldON);

} while (ulArmed == ND_YES);


// After the counter is unarmed, read the buffer from the beginning.

checkInstErr(GPCTR_Read_Buffer(iDevice, ND_COUNTER_1, ND_BUFFER_START,ulReadOffset, ulNumPtsToRead, ulTimeOut, &ulNumPtsRead, Buffer),NI6602);

for (count=1;count printf("Punt %i is %i Frequentie is %lf\n",count,Buffer[count],(1/(10E-3/(Buffer[count]-Buffer[count-1]))));
}




checkInstErr(GPCTR_Control(iDevice, ND_COUNTER_0, ND_RESET),NI6602);
checkInstErr(GPCTR_Control(iDevice, ND_COUNTER_1, ND_RESET),NI6602);



An idea what the problem is ?
What does an gpctrDataLossError mean ?
0 Kudos
Message 1 of 2
(2,562 Views)
Hey SoftToon,

I am not exactly sure what is going wrong in your program, but here are some suggestions. Try running some of the shipping examples to verify that the device is still working correctly.

Here are some examples written in C for high frequency measurements.

http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3E81356A4E034080020E74861&p_node=DZ52329

http://sine.ni.com/apps/we/niepd_web_display.display_epd4?p_guid=B45EACE3DBEB56A4E034080020E74861&p_node=DZ52146&p_source=External

It's possible it could be a problem with the GPCTR_Watch command.

http://digital.ni.com/public.nsf/websearch/62F87FC2C7687FBA86256B53006AB5B8?OpenDocument

I hope this helps out.

Joshua P.
Application Engineering
National Instruments
Message 2 of 2
(2,562 Views)