LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NI DAQmx Counter Input/Counter Output Loopback

Hi everyone, I am using the PXI 6229 DAQ card.  I am trying to set up a "Counter Output" (PFI 8 line) at 1KHz and feed it through the device under task and back into a "Counter Input" (PFI 9 line).  This test is essentially a loopback through the device under test. 

 

I originally set up my "Counter Output" and "Counter Input" as "Implicit Timing" with a constant for the "finite" number of samples to output at "Counter Ouptut"  and to read at  "Counter Input."  This did NOT work because for Finite DAQmx timing the "Counter Output" requires two clocks (cntr 0 and cntr 1) and the 6229 only has 2 clocks which means there is no counter for the "Counter Input."  I confirmed this from this article: http://digital.ni.com/public.nsf/allkb/9D1780F448D10F4686257590007B15A8?OpenDocument

 

The only thing I can think of to get around this issue is to make the "Counter Output" signal "continuous."  I am not sure this is the most sufficient way though. 

 

Does anyone else know how to get around this issue?

 

I have attached my VI for everyone's view.  Thanks!

0 Kudos
Message 1 of 7
(3,424 Views)

It's true that a finite counter output task requires 2 counters on M Series.

 

You *could* make the counter task continuous, but I'm not sure what it is you are trying to test.

 

Going with the assumption that you need finite counter output alongside a continuous counter input, the way I would go about this (without changing hardware) is the following:

 

Configure either AI or AO (assuming one of these subsystems is unused during this loopback test) as a finite task (make the number of samples equal to the number of pulses you wish to generate, and the sample rate equal to the rate at which you wish to generate your pulses).

 

Configure one counter as a single pulse output.  Use the AI/AO sample clock as a digital start trigger.  Set the "Retriggerable" property to TRUE.

 

Configure the other counter as a counter input (timing shouldn't be required, just read the count value after the AI / AO task has finished, or you can poll it if you want to report status as the test is running).

 

Start the AI / AO task which provides the clock after starting both counter tasks.

 

 

If you don't need the higher timing resolution of the counters, you could alternatively use a digital output task with a pre-defined waveform with the desired number of pulses in it.  The DO task needs to be provided a sample clock though (possibly from a continuous counter output task or from the frequency generator).

 

 

Best Regards,

John Passiak
Message 2 of 7
(3,407 Views)

Thanks John.  This may work for me.  One question though:  Would the AI/AO trigger be an external trigger or an internal trigger on the card?

0 Kudos
Message 3 of 7
(3,398 Views)

Either--assuming you want internal routing you would set your trigger source to be the following (replace ai with ao if you are using an analog output task):

 

/<device_name>/ai/SampleClock

 

 

Best Regards,

John Passiak
Message 4 of 7
(3,385 Views)

 

 

 

 

0 Kudos
Message 5 of 7
(3,380 Views)

I will go ahead and give it a try. 

 

Just to be certain the Counter Output (CO) channnel timing VI should be set to "IMPLICIT" and "HARDWARE TIMED SINGLE POINT", correct?

 

Just to be certain the Analog Output (AO) channel timing VI should be set to "SAMPLE CLOCK" and the "NUMBER OF SAMPLES" would be set to the number of pulses and the "RATE" would be equal to the rate I want the CO to be, correct?

 

In this step,

 

"Configure the other counter as a counter input (timing shouldn't be required, just read the count value after the AI / AO task has finished, or you can poll it if you want to report status as the test is running)."

 

How can I check if the AO task is finished?

 

Thanks so much for your help.

0 Kudos
Message 6 of 7
(3,371 Views)

If you just avoid configuring timing for the counter output the default will be single pulse.  You could also configure "Implicit" timing with finite samples = 1 (not hardware-timed single point).

 

You are correct on the AO configuration.  To determine when it has finished you can poll DAQmx Is Task Done.vi  (or you can use the blocking version DAQmx Wait Until Done.vi).

 

 

Best Regards,

John Passiak
Message 7 of 7
(3,355 Views)