LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a global array by shift register

Unfortunately i don't know how to use very well event structures.

I'll attach what i tried so far , it behaves strange

0 Kudos
Message 21 of 27
(740 Views)

Ok i'll specify more precisely although i don't know all the specific terms used in labview : I want to use the first 10 numbers  given by the user control to build the 1D Array , the first element choosen must be the first element of the array and so one . And the array must deny access to numbers that ar already contained

 

The homework has some additional easier demands that depend on the issue that i presented.

I attached , what i tried so far

0 Kudos
Message 22 of 27
(735 Views)

Some hints:

 

  • The "Number to input" control belongs inside the loop, else it will only get read once at the start of the program.
  • Since you know the number of iterations before the loop starts, you should use a FOR loop instead of a While loop.
  • The array itself (not the scalar) needs to be kept in a shift register.
  • The array needs to be wired across both cases of the case structure.
  • All you are doing is searching an "all-zero" array with each iteration. That does not seem very useful. You need to search the array of accumulated values.
  • You only need a height=1 shift register. No need for older historic values.

See how far you get now. 😄

0 Kudos
Message 23 of 27
(715 Views)

Thank you for the Hints 

With one of them i disagree ( using a for loop instead of a while loop ) 

The reason that for loops shouldn't be used is : If we choose 10 iterations - the desired size of the array , it works perfect only if you don't introduce numbers that are already contained in the array , but if you do ,you will waste iterations and the final array will shrink in size.

 

Using you hints i managed to repair some big mistakes but i don't know how to store an array into a shift register.

In one of the VI's that i tried , i initialised the shift register with an array constant ( 10 zeros ) , and then i tried to replace the elements of this initial array with elements from the user input but i still don't know what i'm doing wrong.

 

I attached are my VI's

Download All
0 Kudos
Message 24 of 27
(703 Views)

Laur wrote:

With one of them i disagree ( using a for loop instead of a while loop ) 


Yes, in this case you would also need an event structure. Why spin the loop if nothing is added? 😄

0 Kudos
Message 25 of 27
(693 Views)

Here is a quick draft to get you started (LV 2012).

 

You need to add to the existing array from the shift register, not built a new array with every iteration. You are currently creating a new array with the last element as only element with every new iteration and place it in the shift register.

You also need to initialize the shift register, else it retains data between runs and would stop immediately on the second run.

 

This is all much easier than you currently think, you simply need to learn. 😄

 

(Since the array starts out empty, the current control value is immediately added when you run the program. Modify as needed if you don't want that. There are probably quite a few tweaks needed to make it into a nice, fully functional program. As I said, try an event structure. Currently, the sorting and min/max finding is done with every iteration of the loop. In principle, this only needs to be done whenever a new value is added.) 😄

0 Kudos
Message 26 of 27
(690 Views)

Thank you very much for the draft , it works just fine

It helped me very much with my exercise 

0 Kudos
Message 27 of 27
(673 Views)