11-10-2005 11:00 AM
11-15-2005 04:12 AM
Hello Dara,
have you try to use Counter function to count number of rising edge ?
In this board we have two counter, they can count frequency, period, or number of rising or falling edge.
In LabWindows/CVI, we have example to make this function, search this in "Find example", or see this link, they have one example to count pulse with counter function in LabWindows/CVI.
Christophe S.
Account Manager East of France І Certified LabVIEW Associate Developer І National Instruments France
11-15-2005 09:30 AM
Hello Christophe,
your link is not available
I'm using a ND_SIMPLE_EVENT_CNT to count the rising edge but I don't know how to count during 50 ms without using a timer callback.
I think I should use a "Simple Gated-Event Counting" in order not to disturb the period counting, do you know where could I find Gated-Event Counting exemples?
Thanks
11-15-2005 10:15 AM
I have try to click on my link, and that work fine
Try this link : http://zone.ni.com/devzone/devzone.nsf/webcategories/4E62D0154FC6DF4686256786000BFD28
Christophe S.
Account Manager East of France І Certified LabVIEW Associate Developer І National Instruments France
11-16-2005 12:15 PM
Hi it's still me with still some troubles
I've generated with my counter0 a square wave of 50 ms pulse width from an internal source but then, I don't know how to specify that this signal will also be the pin gate (ND_PFI_4) of my counter1 which will count the rising edge.
Moreover I also don't know how to specify my counter1 just to count rising edge while my gate is at high state; here 's mys code :
//Generation of an internal 100 KHZ square wave
GPCTR_Control(1, ND_COUNTER_0, ND_RESET);
GPCTR_Set_Application(1, ND_COUNTER_0,ND_PULSE_TRAIN_GNR);
GPCTR_Change_Parameter(1, ND_COUNTER_0, ND_SOURCE,ND_INTERNAL_100_KHZ);
//Generation of a 100 ms gate
//50 ms => low state
//50 ms => high state
GPCTR_Change_Parameter(1, ND_COUNTER_0, ND_COUNT_1,5000);
GPCTR_Change_Parameter(1, ND_COUNTER_0, ND_COUNT_2,5000);
//output the counter pulse, you must call Select_Signal.
Select_Signal(1, ND_GPCTR0_OUTPUT, ND_GPCTR0_OUTPUT,ND_LOW_TO_HIGH);
GPCTR_Control(1, ND_COUNTER_0, ND_PROGRAM);
//configuration CPTR1 that will count each rising edge while the gate is at high state
GPCTR_Control (1, ND_COUNTER_1, ND_RESET);
GPCTR_Set_Application(1, ND_COUNTER_1,ND_SIMPLE_EVENT_CNT);
GPCTR_Change_Parameter(1, ND_COUNTER_1, ND_SOURCE, ND_PFI_3);
GPCTR_Change_Parameter (1, ND_COUNTER_1, ND_SOURCE_POLARITY,ND_LOW_TO_HIGH);
GPCTR_Change_Parameter (1, ND_COUNTER_1, ND_INITIAL_COUNT, 0);
GPCTR_Control(1,ND_COUNTER_1, ND_PROGRAM);
GPCTR_Watch (1, ND_COUNTER_1, ND_ARMED, &compteur);
printf("%d\n",compteur);
And the value of compteur is not the value expected at all.
11-16-2005 12:50 PM
Hi,
If i understand, you generate on counter 0 a square wave, and you want use this to Counter 1.
The more easy is to connect by the connector bloc the out (pin 5) of counter 0 to the gate or source on counter 1.
If you want root the signal directly in the internal of the board, you need use route function in NI-DAQ (Select_Signal ())
For example :
Select_Signal (1, ND_GPCTR0_OUTPUT, ND_GPCTR1_GATE, ND_DONT_CARE);
And yes i speak french, do you work in france or in United State ?
Regards,
Christophe S.
Account Manager East of France І Certified LabVIEW Associate Developer І National Instruments France
11-17-2005 10:43 AM
11-18-2005 05:02 AM
Hi Guss, thank you for your help but I don't understand, my counter always count 0, but I don't know where I have done a fault :
//Generation of an internal 100 KHZ square wave
GPCTR_Control(1, ND_COUNTER_0, ND_RESET);
GPCTR_Set_Application(1, ND_COUNTER_0,ND_PULSE_TRAIN_GNR);
GPCTR_Change_Parameter(1, ND_COUNTER_0, ND_SOURCE,ND_INTERNAL_100_KHZ);
//Generation of a 100 ms gate
//50 ms => low state
//50 ms => high state
GPCTR_Change_Parameter(1, ND_COUNTER_0, ND_COUNT_1,5000);
GPCTR_Change_Parameter(1, ND_COUNTER_0, ND_COUNT_2,5000);
//output the counter pulse, you must call Select_Signal.
Select_Signal (1, ND_GPCTR0_OUTPUT, ND_GPCTR0_OUTPUT, ND_LOW_TO_HIGH);
GPCTR_Control(1, ND_COUNTER_0, ND_PROGRAM);
//configuration CPTR1 that will count each rising edge while the gate is at high state
GPCTR_Control (1, ND_COUNTER_1, ND_RESET);
GPCTR_Set_Application(1, ND_COUNTER_1,ND_SIMPLE_EVENT_CNT);
GPCTR_Change_Parameter(1, ND_COUNTER_1, ND_SOURCE, ND_PFI_3);
GPCTR_Change_Parameter(1, ND_COUNTER_1, ND_GATE, ND_OTHER_GPCTR_OUTPUT);
GPCTR_Change_Parameter(1, ND_COUNTER_1, ND_GATE_POLARITY,ND_POSITIVE);
GPCTR_Change_Parameter (1, ND_COUNTER_1, ND_INITIAL_COUNT, 0);
GPCTR_Control(1,ND_COUNTER_1, ND_PROGRAM);
GPCTR_Watch (1, ND_COUNTER_1, ND_COUNT, &compteur0);
printf("%d\n",compteur0);
11-18-2005 05:15 AM
Salut christophe, en fait je suis étudiant français et c'est la première fois que je me sers de labwindows pour mon projet et donc j'ai un peu de mal là :s
J'ai écrit Select_Signal (1, ND_GPCTR0_OUTPUT, ND_GPCTR1_GATE, ND_DONT_CARE); mais on me dit "invalid parametric value" lorsque j'éxécute mais bon je crois que j'y suis presque.
En fait, nous avons besoin de déclancher une interruption à partir du compteur de notre carte (PCI MIO 16 E 4) avec un driver traditionnel. Nous essayons d'utiliser la bibliothèque VXI mais sans succès pour l'instant.
Nous aimerions trouver un exemple similaire ou avoir quelques conseils
Merci d'avance,
alex
11-23-2005 04:53 PM