LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

I am using a shift register to store an 1-d array of data to a file, but it always appends the initialized values to the start of the array and saves them too. why?

I am using a shift register with a for loop to build up a 1-d array of data (up to 32 items, each item having 6 properties), then when the loop is done, save it to a file. i know that you can save it as a 2-d array, but i am loading it elsewhere as a 1-d array, and dont want to change too much code...

when i load the file, i notice that at the front of the data list, there are 6 zeros (from the initialized shift register). I have initialized my shift register as an array of zeros. But, i dont want to save that, just clear the previous data stored in the left shift register, and then
save the new items without any trace of the old information being appended to my file.
0 Kudos
Message 1 of 7
(6,912 Views)
Can you include the VI? I'm having trouble visualizing it...

Mark
0 Kudos
Message 2 of 7
(6,912 Views)
Though not always a good idea, you may be able eliminate the shift register initializing and just set your initial array data to Zeros, then set that as your default values. When your VI runs, have it start with the default values, and then you won't be recording the zero values as presently set from your initialization. But as Mark says, to see you VI would be most helpful. Good Luck - Doug
0 Kudos
Message 3 of 7
(6,912 Views)
If you use the 'initialize array' function that should eliminate the zeroes. attached is an example vi that builds an array of integers. another option would be to use the array subset function with the index set to 6 to eliminate the zero padding.
Message 4 of 7
(6,912 Views)
Yes! that was the problem.

I was using "build array" and filling it with zeros, but, as I said, it used those zeros as the first entries in the array.

the "initialize array" function cleared the old values in the shift register AND didnt add zeros, which is what I wanted.

Thanks to all who posted. I'm glad it was such a simple fix 🙂
0 Kudos
Message 7 of 7
(6,912 Views)
I think I was able to recreate your problem. I made a for loop with a
shift register that I initialized with an array constant of a cluster
constant
with 3 elements(2 numerics and 1 string). (This was supposed to represent
your six pieces of data.)
If the array cluster elements are active(like they would be if you inserted
a numeric constant into a cluster constant) those values will show up in
your final 1-d array.

You need to right click on the initialization array and do data
operations>>delete element
Now the array still has your six elements, but they are greyed out. Now the
for loop
shift register is initialized with the correct information but no data. If
the array isnt greyed
out, the data in the initialization array will be at the beginning of your
data file.

Hope
I understood your problem and this is helpful.

Mark


--
Mark Sowa, Ph.D.
marksowa@one.net
Sowa Engineering
w3.one.net/~marksowa
P.O.Box 531251
Cincinnati, OH 45253
Voice (513) 259-9682
Fax (513) 598-4203




P wrote in message
news:506500000008000000931E0000-986697009000@quiq.com...
> I am using a shift register to store an 1-d array of data to a file,
> but it always appends the initialized values to the start of the array
> and saves them too. why?
>
> I am using a shift register with a for loop to build up a 1-d array of
> data (up to 32 items, each item having 6 properties), then when the
> loop is done, save it to a file. i know that you can save it as a 2-d
> array, but i am loading it elsewhere as a 1-d array, and dont want to
> change too much code...
>
> when i load the file, i notice that at the front of the data list,
> there are 6 zeros (from the initialized shift register). I have
> initialized my shift register as an array of zeros. But, i dont want
> t
o save that, just clear the previous data stored in the left shift
> register, and then save the new items without any trace of the old
> information being appended to my file.
0 Kudos
Message 5 of 7
(6,912 Views)
You can do two things from i can see. The first, initialize the shift register with an empty array, and append data to it. The second, initialize it with zeroes, but replace data instead of appending it. Both options could fit your needs.
Hope this helps
0 Kudos
Message 6 of 7
(6,912 Views)