LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

compteur

Bonjour, j'ai essayé de compter les fronts montants à partir de la broche ND_PFI_3 sur laquelle j'ai injecté un signal TTL, mais je ne sais pas comment spécifier sur quelle période je souhaite compter.

Mon programme de comptage est le suivant :

GPCTR_Control (1, ND_COUNTER_1, ND_RESET);

//Selects the application for which you use the general-purpose counter.
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_COUNT, &compteur);

printf("le compteur compte %d \n",compteur);

GPCTR_Control (1, ND_COUNTER_1, ND_RESET);

Merci si on pouvait m'aider, surtout me dire quelle fonction utiliser pour préciser la période de comptage d'un simple signal carré.
 
je pense qu'il faudtrait que j'utilise les fonctions
GPCTR_Change_Parameter (1, ND_COUNTER_0, ND_GATE, ND_IN_START_TRIGGER);
et
GPCTR_Change_Parameter (1, ND_COUNTER_0, ND_GATE, ND_IN_STOP_TRIGGER);

mais je ne sais pas comment  configuer les start et stop , car quand j'essaie ils me disent "invalid action"......
Merci par avance.
0 Kudos
Message 1 of 2
(2,867 Views)

As far as I can understand what you are trying to do is gated event counting, that is:

- Applying the signal to the SOURCE input of a counter

- Count events on this input while another input (GATE) is high

By using a second counter to drive the gate input of the first one, you are able to specify an exact period for counting the TTL signals on your source input.

For a discussion on gated event counting, you can look at this post, in which samples are present both for traditional daq and daqmx environment.

Also, take a good look at the last post from ElbaTech that can be very useful for your needs in case you can switch to DAQMx.

I'm sorry for not having answered you in french, but I cannot speak in that language

Hope this helps you a little

Roberto



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 2
(2,827 Views)