Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

How can one counter be sources (or gated) with the output of the other?

I'm trying to use the counters to generate a square pulse train that contains a certain number of pulses (on 6036E). For that I need to gate counter0 with the output of counter1. The manual seems to indicate that I need to use

GPCTR_Change_Parameter (deviceNumber, ND_COUNTER_0, ND_GATE, ND_COUNTER_1) ,

however it makes no difference to the output; I see no gating. What am I doing wrong? Am I missing something?

I would also like to source counter1 with the output of counter0. There's a similar function call to choose the source signal, but so far I've been unable to source a counter with anything but the internal timer.  I guess the reason for it might be the same as the gating problem.

Petro
0 Kudos
Message 1 of 4
(3,765 Views)
Hi Petro-
 
We have an example that shows how to output a finite gated pulse train on an E Series board.  It mentions that it is a CVI example, but the main .c file does not include any CVI-specific functionality so it should work if you're using ANSI C.
 
Equivalent functionality is available in NI-DAQmx for your board and is considerably more intuitive.  An example of pause-triggered pulse train generation is available in the "C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Counter\Generate Pulse\Dig Pulse Train Cont-Pause Trig" directory of your local drive.  One method to generate the "pause trigger" pulse train is shown in "C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C\Counter\Generate Pulse\Dig Pulse Train-Cont" .
 
I'm not sure what you mean when you say "I would also like to source counter1 with the output of counter0."  What do you need to perform this operation for?  The reliance of counter 1 on counter 0 and counter 0 on counter 1 creates a type of circular reference that is almost guaranteed to be problematic.
 
Hopefully this helps-
Tom W
National Instruments
Message 2 of 4
(3,750 Views)
Hi Tom,

I figured out what I did wrong by now. Sorry I didn't remove my post right away and thanks for the example. What confused me was that I needed to specify ND_OTHER_GPCTR_OUTPUT as the gate and not ND_GPCTR1_OUTPUT, as I was trying to do. Beginner's mistakes, I guess. You are absolutely right, creating a circular reference with gating+sourcing causes a problem and is not necessary anyway, just gating is enough.

I could not find the NI-DAQmx file you talked about; my "\National Intsruments\NI-DAQ\Examples" directory only contains the "\Visual C\" folder in it. Is it something that I didn't install? If yes, can this NI-DAQmx functionality be used with Visual C? I've never used it before.

Thanks for the help and best regards,
Petro

0 Kudos
Message 3 of 4
(3,741 Views)
Hi Petro-
 
Glad to hear you got it working now.  In order to check out the NI-DAQmx examples, you will need to install the driver first.  Make sure to include support for VC6.0 or .NET as needed.
 
Best of luck with the rest of your development-
Tom W
National Instruments
0 Kudos
Message 4 of 4
(3,735 Views)