LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

cDAQ-9188, NI 9401 3 input frequency counters

Dear experts,

 

I'm trying to use NI 9401 in the slot 2 in cDAQ 9188 for measuring frequency but without success.

PF0-PF2 for independent measurement frequncey < 1 kHz.

I already read white papers about separate tasks, defining nimble as an input, for reservation and so on. 

Finally I can see some values (in some reason its ~ X3 than I expect to see) but two other acquisition functions return empty arrays without any errors.

I attached screenshots of code.

 

Thanks in advance! 

Download All
0 Kudos
Message 1 of 6
(331 Views)

Nothing has been attached. Instead of screenshots, it is better to attach the code, saved to an earlier version like 2019.

-------------------------------------------------------
Applications Engineer | TME Systems
https://tmesystems.net/
0 Kudos
Message 2 of 6
(325 Views)

Thanks for notifying!

I attached screenshots to initial message and attached LV2018 code here.

0 Kudos
Message 3 of 6
(311 Views)

You're doing some weird things.   Of particular note, by using the "magic number" -1 as the # samples to read from your continuous acquisition tasks, you're asking DAQmx to retrieve all the new samples it has acquired since your previous request.  If you do your requests fast enough, this could be as few as 0.   But whatever the amount is, DAQmx Read will return immediately with whatever it had stored up and waiting.

 

You then try to keep only the first 10 samples of that mystery amount from each task and build a 3x10 array out of the 3 tasks' data.  Three problems come immediately to mind:

1. If there's a lot more than 10 samples captured, why do you consider it ok to discard all but the first 10 in the group?  Those are the ones that happened the longest ago.

2. If any of them capture less than 10 samples, there won't be a "first 10" to retain.  You can end up with different size outputs from your 3 "Split 1D Array" functions

3. When you then build these 3 1D arrays into a 2D array, LabVIEW will force all 3 rows to have the same # samples, filling in default 0's as needed so that all rows have the same length as the longest input array.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 4 of 6
(259 Views)

thanks for your response. Let me explain.

In the acquisition loop I also get data from analog channels at 1 kHz and 40 kHz rate. I just get a certain amount of samples to ensure a stable cycle time around 10 ms. Getting 10 samples from 1 kHz and 400 samples from 40 kHz channels I manage to get all samples and ensure 10 ms cycle time. 

The same logic was for counters tasks, I planned to get 10 samples per cycle as I acquire data at 1 kHz but I faced with buffers overload and temporarily just take all available samples and get only first 10 from it.

I set 1 kHz acquisition rate for counters and expect that it will work like other channels. However its not so.

 

Please don't look at all that goes after reading VIs as it will be changed. More important how to get values on outputs of three reading functions. 

I think the problem with setup channels as for 9401 it seems not simple and no examples with more than one counter.

 

I attached the full code in the cycle in the screenshot 

 

Thanks for your help.

 

0 Kudos
Message 5 of 6
(240 Views)

My recommendation is to start with one of the shipping examples for measuring frequency with a counter.   Save it under a new name such as "Ctr freq test 1.vi"    Get it working with one of your signals.

 

Now save another copy as "Ctr freq test 2.vi".  Get them both working at the same time.   And then add the 3rd.

 

What I briefly noticed in your code was that the your "Frequency Parameters" array is an empty array in your block diagram constant.  When you index that array during your "Initialize" state, you're going to retrieve a default value for the cluster.  So you'll be trying to assign the same channel name and frequency terminal to all 3 tasks.

    I would expect that you'd either get an error or 3 duplicate data streams.  Why you get no data and no error isn't clear.  Hence the suggestion to back *way* up and use known-good shipping examples to explore the issue.

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 6 of 6
(215 Views)