# LabVIEW

cancel
Showing results for
Did you mean:

Solved!
Go to solution
Highlighted

## how to determine the size of an output array

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.

Message 1 of 6
(361 Views)
Highlighted

## Re: how to determine the size of an output array

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 LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
Message 2 of 6
(353 Views)
Highlighted

## Re: how to determine the size of an output array

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

Message 3 of 6
(346 Views)
Highlighted

## Re: how to determine the size of an output array

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 LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
Message 4 of 6
(324 Views)
Highlighted
Solution
Accepted by topic author trishulnaik

## Re: how to determine the size of an output array

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

Message 5 of 6
(317 Views)
Highlighted

## Re: how to determine the size of an output array

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.

Message 6 of 6
(305 Views)