LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to determine the size of an output array

Solved!
Go to solution

Screenshot (455).png

I want to know how to determine the 2d array row size manually? is there a relation between sample clock rate, read samples per channel and the target time. To determine the size of the array.

0 Kudos
Message 1 of 6
(2,139 Views)

Hi trishulniak,

 


@trishulnaik wrote:

I want to know how to determine the 2d array row size manually? is there a relation between sample clock rate, read samples per channel and the target time. To determine the size of the array.


You already determine the ArraySize using the ArraySize function…

 

In the loop you are reading 20000 samples per DAQmxRead call (I guess, but you should use the AutoCleanup button more often!): so you should also get a row size of 20k elements (in case there's no DAQmx error)!

 

And yes, there is a relation between samplerate and number of samples:

num_samples := elapsed_time * sample_rate
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 6
(2,131 Views)

sir, when i'm playing with values of rate=1,sampled rate=1, elapsed time=5sec, i'm getting 7x1 array. why 7?

0 Kudos
Message 3 of 6
(2,124 Views)

Hi trishulniak,

 


@trishulnaik wrote:

sir, when i'm playing with values of rate=1,sampled rate=1, elapsed time=5sec, i'm getting 7x1 array. why 7?


Because of THINK DATAFLOW and race conditions!

 

ElapsedTime is called in parallel to DAQmxRead, but DAQmxRead takes (way) more time to execute than ElapsedTime…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 6
(2,102 Views)
Solution
Accepted by trishulnaik

You'd need to show code.  I don't know why you'd refer to "rate" and "sampled rate" as 2 distinct things for example.  I don't know if you've changed the dataflow relationship between the DAQ operations and the Elapsed Time check.

 

In your original screenshot, you set a sample rate of 10k and request 20k samples per iteration.  That'll take 2 seconds to return with data.  Elapsed Time has no dataflow relationship to the DAQ process, so it'll get checked at the beginning of that 2 seconds.

 

So at the first iteration, Elapsed Time will be ~0 sec, the second iteration it will be ~2, the third iteration it will be ~4, and finally on the 4th iteration it will be ~6.  That's when the boolean output will become true, the loop will terminate, and you'll have accumulated a 4 x 20k array of data at the auto-indexing tunnel.

 

If you understand why your original posted screenshot would behave that way, you might be able to figure out the present behavior too.  Or post the code.  (Actual code is better than a screenshot, best to use "Save for Previous Version" if necessary back to ~LV 2016 I'd recommend.)

 

 

-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 5 of 6
(2,095 Views)

Sir, 

Thank you for your detailed explanation, now I understand the thing going on. Yesterday I wrote CLAD exam and scored(67%) , there were 2 questions on the same model. I didn't consider the 1st case were my 1st iteration elasped time would be 0 sec. Rather I took 1st iteration 2 sec.

0 Kudos
Message 6 of 6
(2,083 Views)