05-08-2021 03:48 AM
Hi all, I need a litle bit help with my program. I compare current and previous value of signal with shift register, if current value is different from previous it give me False for case structure and then I am storing current value to array (values in array are 0 or 1 or 2), but I need store only 4 values in array which I want compare with other array and then reset this array with 4 stored values. The values are periodically repeating, so perhaps reseting array after some specific value (lets say 2) is reached could be better solution but I need help how I can do it.
Thanks in advance
Mark
05-08-2021 04:20 AM
I can use element Array size and then if number of values in array will be equal to 4 then I can reset the array. But how can I reset array?
Thanks
05-08-2021 11:16 AM - edited 05-08-2021 11:38 AM
Please attach your VI instead of pictures.
What does "reset" mean? Set the size back to zero? Since the size can only grow after a new element is added, should the array contain the new element or no elements after "reset"? What is the max array size?
(This seems like a trivial problem. Have you done any basic tutorials. Why is one shift register not initialized? Why is there a coercion dot? Why is the indicator terminal inside the case structure? Why is there no way to stop the VI? What determines the lop time? To append an element to an existing array, "built array" is the correct function, not "insert into array". What is the purpose of this exercise? Maybe there is a better solution overall for whatever you are trying to do here.)
05-10-2021 08:08 AM
Hello,
yes, for reset I mean size back to zero. I tried something and this solution works for me.
Best Regards,
Mark
05-10-2021 08:37 AM
Hi Mark,
@MarkMc20 wrote:
yes, for reset I mean size back to zero.
IF ArraysSize >= 5 THEN
array := InitArray(size=0)
ENDIF
Instead deleting elements from an array you can also use the InitArray function to create an empty array. (Or use an empty array constant, the compiler will most probably do the same…)
05-10-2021 11:03 AM
@MarkMc20 wrote:
yes, for reset I mean size back to zero. I tried something and this solution works for me.
No, just no!!!
05-10-2021 11:09 AM - edited 05-10-2021 11:18 AM
Maybe something like this? (I still believe you are trying to solve the wrong problem here!)
(Since you seem to prefer pictures, I am not attaching a VI 😉 )
(You need to decide how you want to initialize the scalar shift register. It probably would make more sense to make an array with the new element once the size would be exceeded so modify the inner case (currently empty) accordingly if desired.)