Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

counting rising edge during 50ms for a TTL signal

Hello, I'm using Labwindows 6 and a traditionnal DAQ. I've injected a TTL signal on my card and I would like to count the number of rising edge each 50 ms without using an internal timer in labwindows so that the counting pace cannot be disturbed by Windows.
Do someone know how to process or which functions should I use?
Thanks
0 Kudos
Message 1 of 10
(5,658 Views)

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.

http://venus.ni.com/stage/we/niepd_web_display.DISPLAY_EPD4?p_answer=&p_guid=B45EACE3DF6D56A4E034080...

Regards,

Christophe S.
Account Manager East of France І Certified LabVIEW Associate Developer І National Instruments France

0 Kudos
Message 2 of 10
(5,624 Views)

Hello Christophe,

your link is not available Smiley Sad

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

0 Kudos
Message 3 of 10
(5,619 Views)

I have try to click on my link, and that work fine Smiley Surprised

Try this link : http://zone.ni.com/devzone/devzone.nsf/webcategories/4E62D0154FC6DF4686256786000BFD28

and after follow : Event/Time Measurements.
 
Regards,

Christophe S.
Account Manager East of France І Certified LabVIEW Associate Developer І National Instruments France

0 Kudos
Message 4 of 10
(5,615 Views)

 

Hi it's still me with still some troubles Smiley Sad

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.

thanks.
(ps : can you speak french?)
0 Kudos
Message 5 of 10
(5,603 Views)

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

0 Kudos
Message 6 of 10
(5,596 Views)
If you only want to count when the gate of counter 1 is high (and that signal is coming out of the counter 0 output) then you need to select the gate in this manner:
 
GPCTR_Change_Parameter(1, ND_COUNTER_1, ND_GATE, ND_OTHER_GPCTR_OUTPUT);
 
you may also need to change the polarity on the gate:
 
GPCTR_Change_Parameter(1, ND_COUNTER_1, ND_GATE_POLARITY, { ND_POSITIVE, ND_NEGATIVE} );
 
 
I hope this helps!
gus....
 
 

 

0 Kudos
Message 7 of 10
(5,582 Views)

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);

0 Kudos
Message 8 of 10
(5,571 Views)

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

0 Kudos
Message 9 of 10
(5,567 Views)
Hello Alex-
 
From the looks of your code, I can't see anything that would be immediately wrong.  Try running your app without the following lines:
 
    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);
Do you get data then?
0 Kudos
Message 10 of 10
(5,532 Views)