LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

array

Hello All,

 

I need help on attached VI. This VI generates Random number indefinitely and stores into an array. I want to set the array size to be 50 and the while loop has to update the array every 1s with 50 set of numbers and the same has to be ploted on a graph and clear the graph and array so as to update the array with again 50 set of numbers.

 

Thanks in advance:)

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

Hi reva,

 

I want to set the array size to be 50

Then you should create an array with 50 elements. You don't do so…

 

the while loop has to update the array every 1s

Your loop is set to iterate each 100ms - this doesn't fit with your request…

 

with 50 set of numbers

Right now you add one value each 100ms to your array, again not as you requested…

 

the same has to be ploted on a graph

There is no graph in your VI…

 

clear the graph and array so as to update the array with again 50 set of numbers

Replace the plot data each second!

 

This is all very basic LabVEIW stuff. Did you take the free online resources to learn LabVIEW?

Your task really is a good example to learn basic array handling in LabVIEW!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 9
(3,345 Views)

Hi Reva, as Gear says you should study a bit 🙂

 

To do what you want, it depends if you want to generate a 50x array every second, or if you want to generate a number every second. It's not clear. To generate a 50x vi you should put your random generator inside a for loop with N = 50 indexing the output of the loop. If you want to add a single number it is a little (very little) more complicated but we can explain you how to do it.

 

PS: Timing of the loop is expressed in milliseconds, so if you want 1 second the constant is 1000, not 100.

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

 Hi gred.

 

Thanks for ur reply. I have modified the program as per your suggestions. Still I have doubt on two points. Pls clarify.

 

clear the graph and array so as to update the array with again 50 set of numbers

Replace the plot data each second!

 

The numbers are stored in array one after the other, how can I index the array to next 50 elements each time.

 

the while loop has to update the array every 1s

Your loop is set to iterate each 100ms - this doesn't fit with your request…

 

This will output random number for every 1 sec but I require 50 random numers for 1 sec and this 50 random numers has to be generated within 1 sec while loop execution.

 

Pls help.

0 Kudos
Message 4 of 9
(3,249 Views)

Hi reva,

 

what have you tried in the last few days? Mind to attach your current version of your VI?

 

The numbers are stored in array one after the other, how can I index the array to next 50 elements each time.

You don't need to index any elements when your array stores just 50 elements and all of them should appear in the plot…

 

This will output random number for every 1 sec but I require 50 random numers for 1 sec and this 50 random numers has to be generated within 1 sec while loop execution.

Ok. Sounds like you need to generate 50 random numbers per iteration of your while loop.

Any ideas how to generate exactly 50 numbers?

 

P.S.: Is it really so hard to type 5 chars in the correct order when you want to write my forum nickname?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 5 of 9
(3,236 Views)

hi GredW,

 

I believe the attached VI will work as per my requirement. But still doubt on timing part.

 

pls help

 

Thanks

0 Kudos
Message 6 of 9
(3,207 Views)

Hi reva,

 

I believe the attached VI will work as per my requirement.

Well, your requirement was always to generate 50 numbers. Right now you create 15 of them…

Your requirements seem to change very fast!

 

But still doubt on timing part. pls help

Help on what? On your "doubts"? Which doubts? What is your problem?

 

Why do you have this ElapsedTime function in the VI? Why have it measure time for 1s and then use auto-reset? In parallel with another "wait for 1000ms"?

 

P.S.: Still you have problems to type just 5 chars in the correct order…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 9
(3,197 Views)

Hi GerdW,

 

sorry that was a trial program so I set loop to generate 15 numbers. My doubt is how can I ensure that 15 numbers are generated within 1s of while loop iteration.

 

thanks:)

0 Kudos
Message 8 of 9
(3,139 Views)

Hi reva,

 

how can I ensure that 15 numbers are generated within 1s of while loop iteration.

Your outer loop is set to iterate once per second. The inner loop generates your 15 numbers as fast as possible. In conclusion with each iteration of your outer loop you get 15 new values and the outer loop will iterate once per second as nothing inside needs more than one second to execute…

(Well, if a virus scanner thinks it needs to pause other applications for such a time your VI will not provide new values within this period. But that's a problem you cannot solve inside your VI…)

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 9 of 9
(3,127 Views)