LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

couting rising edge each 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 8
(3,785 Views)
depends on your card, somehow.
if you have one which supplies 2 or more counters, you can program the first counter to count your ttl signal, the second with a period of 50 ms to
trigger a buffered acquistion for counter #1.


--
Once the game is over, the king and the pawn go back into the same box.
0 Kudos
Message 2 of 8
(3,773 Views)

It seems that this question has been already answered here: I suggest you study the post linked in that page.

Anyway, if your card it that PCI-MIO 16E4 you are referring to in another question, I can confirm you have two counters available for this  task. This provided you are not executing other acquisitions in the same moments: some analog acquisitions use one of the internal counters for timing.



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 3 of 8
(3,764 Views)
Hi thank for your posts.
I indeed have 2 counters but the problem is that I don't know how to program the second counter with a period of 50 ms to
trigger a buffered acquistion for my counter1. Ican't find example for traditionnal DAQ , should I connect my second counter to an external clock and then programm this counter?
 
Thanks
0 Kudos
Message 4 of 8
(3,739 Views)
Hi, Dara, the second counter basically needs to output pulses with the appropriate period, so you can look at STCGenerateSquadreWave of STCgenerateRepeatedTriggeredPulse samples in <cvidir>\samples\daq\ctr directory, adapting values to your need.

Message Edited by Roberto Bozzolo on 11-14-2005 09:09 AM



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 5 of 8
(3,729 Views)

Hi, Ican't find your directory but I would like to know if you don't know where I can find example of simple event counts each 50 ms for a traditionnal DAQ on labwindows because I can't find anything......I've also looked on the DAQ QTC Technical reference, and found a chapter on "Simple Gated-Event Counting" but no exemples.

Thanks.

0 Kudos
Message 6 of 8
(3,705 Views)
Dara,
\samples\daq directory and all subdirectories are loaded in the computer while installing NI-DAQ. Maybe you have skipped this step or had some problems while installing the software. I suggest you reinstall NI-DAQ from the CD and check CVI support so that the installation program loads sample programs on the PC: there are several of them that can be useful.
 
Another way of obtaining some sample code is to browse the Developer Zone: if you select "Example code" in the menu on the left of this page you gain access to a vaste library of examples searchable by keyword. As an example, among them you can find DAQ-STC/NI-TIO: Counting the Number of Digital Pulses that Occur Between Consecutive Digital Trigger..., DAQ-STC: Repeatedly Generate a Digtal Pulse Upon a Trigger and Generating a Finite Pulse Train that can help you in designing your application.
 
Hope this helps
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 7 of 8
(3,697 Views)

Hi,I still have problem  Smiley Sad

As you said, 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_0, ND_ARMED, &compteur0);
    printf("%d\n",compteur0);

thanks.
0 Kudos
Message 8 of 8
(3,669 Views)