LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

disarray clearing arrays !

i've written some code using 6.1 that acquires data for a given period of time,  storing it in an array via a  while loop and shift register etc. once the acquisition is complete (loop stops) the data gets saved to file. the program then sits there waiting for another trigger to start acquiring again. thing is on subsequent acquisitions data gets appended to the array. so on next file creation data contained is present acquisition and all those that ocurred before. only posts i find close are using 'replacing array subsets' etc, but can't seem to get away from dimesional/data-type errors etc going down this road. once the loop has stopped and file is written i want to clear the array ready for next acquisition. i'm in total array disarray. please can someone help!

thanks in advance.
0 Kudos
Message 1 of 11
(3,322 Views)
After writing the file, assign the shift register an array constant with no data. You can make an array constant by right clicking on the shift register and selecting "create constant".
0 Kudos
Message 2 of 11
(3,309 Views)

You need to initialize your shift register with an empty array on the left (see image). This way the shift register will be empty next time the loop starts.

Still, it is more efficient to preallocate a full size array (especially if you know the final size exactly) and use "replace array subset". That should be no problem. What are the dimensions of your arrays? Please attach a simplified example so we can figure it out.

Message Edited by altenbach on 07-11-2005 07:26 PM

0 Kudos
Message 3 of 11
(3,308 Views)
thanks guys for the replies. i've attached some code, so you can see what i'm trying to do. i think once the data array is built i need to pass it to another array prior to saving it to file. this second array can be 'replaced' with data from the next acquisition from the first data array. does this make sense? i tried doing this taking dimensional values from the first array to initialise array etc, but just got dimensional errors.

again, thanks in advance for any info that helps.
0 Kudos
Message 4 of 11
(3,285 Views)
Just a few comments to the code, I still don't quite understand your exact needs. (just an image, I no longer have LabVIEW 6.1).
 
I think you should built the entire thing into a statemachine, with each structure corresponding to a state.
Check the shipping examples for ideas.
 
Notes:
  1. It does not make sense to write to an indicator and its local variable at the same time. This is redundant.
  2. Use wires if possible.
  3. Use the proper path tools for paths. using string operations makes in platform dependent.
 
0 Kudos
Message 5 of 11
(3,273 Views)
I agree with altenbach, a state machine would be nice here and will make it easier to modify and maintain in the future, plus you'll be able to eliminate some of the structures that you are currently using.
0 Kudos
Message 6 of 11
(3,243 Views)
thanks for the pointers, i'll look into the statemachine approach and post up how i get on. got a couple of questions though. firstly, what do people use to convert their vi's to png's. is it an export from labview, or some thirdparty application? finally i can't find the function to simplify the boolean expression in the first loop. in altenbach's recorder.png what is used to get that what looks like a 1d string array?

thanks in advance.
0 Kudos
Message 7 of 11
(3,221 Views)

You can just take a screen capture of the active window (alt-PrtScr), paste it into a graphics program (e.g. MS paint, photoshop, corel phhotopaint) and save as png.

LabVIEW itself can get the panel and diagram image of any VI and save it as PNG. An example code is shown HERE

.

To create an string array diagram constant, first place an empty array container and then drop a string diagram constant in it.  🙂

0 Kudos
Message 8 of 11
(3,208 Views)
thanks for all the help, brilliant. things are running smoother now. going to rework a state machine version of the code too.
thanks again.Smiley Wink
0 Kudos
Message 9 of 11
(3,191 Views)
got working on a state machine version of my code.
a 'record' state aquires data for one minute, then changes to a 'file' state, that saves the data.  it then goes to a 'mode' state that sits there untill the next correct time to acuire data is reached. then it's back to 'record' and 'file' states. etc etc. problem i'm having is that the file created has no data. any pointers much appreciated.

thanks in advance.
0 Kudos
Message 10 of 11
(3,169 Views)