LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help with using a reference trigger

I have a USB-6341, and trying to set up a counter that will count between two rising edges of the same trigger channel. When I try to run the VI I get an error -200452  "DAQmx reference Trigger: Specified property is not supported by the device or is not applicable to the task".

 

I was able to run an example VI that was using a reference trigger, and so I'm thinking I just don't have it setup correctly since this is the first time I am trying to use a reference trigger. Is there a simple mistake I have made, or is the I am trying to do this completely wrong?

 

reference trigger.png

0 Kudos
Message 1 of 9
(2,537 Views)

To the best of my knowledge, counter tasks have never supported the Reference Trigger type.  The example you ran was likely for Analog Input.  The good news however is that the counters are super flexible in other ways and I suspect there'll be another way to accomplish the timing measurement you need.

 

Counting between consecutive rising edges of the same signal would normally be configured as "period measurement".  To buffer up a sequence of interval times, call the "Implicit" timing version of DAQmx Timing to set up a buffer.   No trigger config is needed -- the signal itself determines the measurement and sample timing, hence the term "Implicit".

 

There's also a measurement mode called "Two Edge Separation Measurement" for measuring time intervals between two distinct signals.   And there are other measurement modes as well (pulse width, semiperiod, etc.).

 

 

-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
(2,508 Views)

Kevin,

That would explain why my VI wouldn't run, as the example was using an analog input. Can you please go into a little more detail with the correct way to use implicit timing, or if you know of a good example that shows it being used for two channels? I can get the period to work, but I'm not sure how to use that with the implicit timing to capture on another channel. Attached is what I thought to try, but it gives the same error, and I think it is from having the two task together.

 

Thanks

 

Implicit Timing.png

 

0 Kudos
Message 3 of 9
(2,502 Views)

I think the first thing to establish is that for your board and any others I'm familiar with (cDAQ might be an exception, but I'm not sure), counter measurement tasks only allow 1 counter per task.  Removing the two nodes related to Edge Counting in your screencap looks like it would allow the period task to run.

 

 

To accomplish edge counting, you'd need make a separate task for it using a separate counter.  To capture edge count samples at the same time as the implicitly-timed period samples, you'd use the Sample Clock version of DAQmx Timing while specifying PFI9 as the sample clock source.  (One caveat: on your X-series board, the 1st period measurement happens on the 2nd edge at PFI9 while the 1st edge count measurement would happen on the 1st edge.  More background here.)

 

 

-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
(2,490 Views)

I've manged to get it partially working now. Right now I am using a function generator to create the signals. I have PFI9 set to 10kHz and PFI8 at 100kHz. When I run the VI I never get a count above 10, but it jumps every run between 0 and 10. I slowed down PFI9 to 1Hz, and the VI would run for longer at times. It seems like it starts to count at the same time as the the VI starts, instead of waiting for a PFI9 rising edge. I'm not sure if that has to deal with your caveat, or if there is still something not perfect. I would think from your caveat it should always at least be a constant number though.

 counter.png

,

0 Kudos
Message 5 of 9
(2,488 Views)

After playing around with it some more I ended up with this. So far it has given the correct count value for every different frequency values I have given it. Not sure if it is how it should be done, but it seems to be working.

 

counts.png

0 Kudos
Message 6 of 9
(2,482 Views)

For experiment and learning:

 

1. Change your edge counting task to Finite Samples and specify 100 samples in DAQmx Timing.  Change the version of DAQmx Read to be 1ChanNSamp and make an array indicator for the set of sampled edge counts.  At 10 kHz and 100 kHz, all values will be counts that increment by 10.   (It's possible that differences in accuracy and phase between your 2 signals might cause just one interval to be 9 or 11 counts).

    The first value (which is the *only* one your posted code looks at presently) is entirely unpredictable.  It's the # of PFI8 edges that happen to occur between when your software call manages to arm the counter and whenever the PFI9 edge arrives to cause the count to be sampled.  Nothing syncs your software call to the PFI8 or PFI9 signal edges, so that value can vary every run.

 

 

On a totally different topic, your period measurement task at the top of your code isn't really doing anything.  It may run without error, but you stop it immediately after starting it without ever reading any measurements.  

 

 

-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 7 of 9
(2,480 Views)

You were correct at the period measurement not doing anything. Removed it and still got the same values.

 

When I changed to Finite Samples and 100 samples, I got an error that the Finite acquisition has been stopped before the requested number of samples were acquired. Also, when changing to 1Chan NSamp the array never got populated with values. This is the only combination I have been able to use that doesn't have an error message, while also giving the correct answer.

 

counter.png

0 Kudos
Message 8 of 9
(2,478 Views)

Here's an example that worked for me on a real board (PCIe-6341) with Finite Sampling.

 

 

-Kevin P

 

buffered edge counting.pngbuffered edge counting.vi Front Panel.png

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).
Download All
0 Kudos
Message 9 of 9
(2,473 Views)