From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Counter clock from PXI

Solved!
Go to solution

Hello, I thought it is a simple problem but still I was not able to solve it. I have a very generic counter VI as shown in the snippet.

The counting signal is a non-periodic TTL. The VI fails if this signal is used for a clock (as well). For now my solution is to run periodic TTL from the frequency generator as the clock. However, I think it is waste of the resource and that must be possible to get the clock running from PXI 1042Q express which I am using. This VI does not support use the on board clock or 10 MHz from the chassis (which does not make sense to me). My question is how can I still use the current VI and get the lock from the chassis.

Cheers !

0 Kudos
Message 1 of 9
(3,827 Views)

Between your description and the code screenshot, it isn't entirely clear what you're trying to do or what "failure" is stopping you.  All I can do is play Carnac and address the likely issues as I see them.

 

1. You've set up a buffered acquisition with a sample clock, but you're only reading out 1 sample at a time in the loop.  That's a bad combo.  As a general rule of thumb, buffered data should be read in chunks, a common starting point is to read about 1/10th second worth at a time.

 

2. I don't recognize the timer function in the loop with the metronome icon.  It may be part of the reason your loop can't iterate fast enough to keep up when reading only 1 sample at a time.

   You should generally have one and only one method for setting the loop iteration rate.  Either use a wait timer or a specific # of samples in a DAQmx Read, but not both at once.

 

3. Prior to X-series boards (circa 2011), NI DAQ counter acquisition often depended on configuring a 2nd counter for continuous pulse generation so it could be used as a sample clock by the 1st counter task.

 

4. Dunno what DAQ device you have, but in MAX you can select the device and then look at the "Device Routes" tab at the bottom of the middle panel.  The nature of what can be routed varies quite a bit across different generations of boards so it's difficult to offer any general advice.  One thing that will usually be possible is an indirect method that derives pulse train output using a reference clock (such as the 10 MHz chassis clock) as a timebase.  Then that pulse train can be used as the 1st counter's sample clock, thus keeping it "locked" to the reference clock on the chassis.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 9
(3,811 Views)

Thanks for your answer.

1) This was just an example. Samples to read can be varied.

2) It is just measuring time.The loop time iteration is set on a clock (PFI0 in this case).

3) Can you fetch an example ? Again, my counter signal is not periodic (essentially it has 3 different periods).

4) M-6259. Again, for the indirect method to get a clock, do you have an example ?

Thank again !

0 Kudos
Message 3 of 9
(3,803 Views)

Here's a snippet from LV 2016.  It ran without error using a simulated device.

 

It divides down the PXI 10 MHz ref clock to make a sample clock out of Ctr1.

Ctr0 counts edges on PFI8 and samples that count using the output of Ctr1.

The loop reads 1/10 sec worth of data per iteration.

 

counting sampling from PXI ref clk.png

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 4 of 9
(3,795 Views)
Solution
Accepted by topic author BB_King

Hi Kevin, success !

Thanks for the guidance.

However, the VI on the snippet works only with 1Samp. NSamp runs, but data are not read.

Not sure why is that ?

Thanks again!

 

0 Kudos
Message 5 of 9
(3,782 Views)

Speculating some possiblities about failures on "N Sample" reads:

1. Do you get an error on DAQmx Read?  Is it a timeout error?

2. Is the iteration count > 0 when the loop terminates? 

3. Do you get an empty array out of DAQmx Read?  Or is it an array containing one or more values of 0?

4. Are you sure you have a source of edges to count on PFI8?   How fast & how many?  (Code as written will expect 100 edges within the default DAQmx Read timeout time or 10 sec).

5. I may have inadvertently set you up for a lesson in a feature known as "duplicate count prevention."  I don't have time to write up that lesson myself now, but you can find a bunch of info here now that you know the right search term.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 6 of 9
(3,770 Views)

Hi Kevin,

thanks for your reply.

1) No error, but nothing is read in data.

2) Iteration runs and counts.

3) Empty.

4) Positive, I would have 1000 in a sec.

5) It is never too many of good examples.

Thanks !!

 

0 Kudos
Message 7 of 9
(3,765 Views)

No solid theory, a few suggestions for gathering troubleshooting info.

 

1. One little thing I noticed: in my code, I divided the sample rate by 10 and wired into the DAQmx Read '# samples' input.  You wired it into the 'timeout' input. 

   Go back to the N Sample version of DAQmx Read and wire that value into the '# samples' input.   (Note: I don't think this alone is going to solve things.)    You'll need your output indicator to be an array and I'd recommend you also feed the array to a waveform chart.

 

 

2. Try changing the PFI8 terminal constant to something like "/PXI1Slot4/20MHzTimebase".  Here's what *should* happen:

- the 10MHz ref clock is divided down to become a 10 kHz sample clock

- your counting task gets edges and counts at 20 MHz

- each sample of the count value should be 2000 larger than the previous sample

- the chart will show a perfectly straight line of counts that increase at a constant rate

 

 

3. Using either MAX or a shipping example (from the menu "Help->Examples..."), set up a simple edge counting task to confirm that your original PFI8 signal can be counted.

    Do a similar check to see if you can count the "/PXISlot4/10MHzRefClk" signal.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 8 of 9
(3,758 Views)

1) is working fine. My mistake. Thanks again Kevin !

0 Kudos
Message 9 of 9
(3,747 Views)