LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

how to make a RESET button in labview ?

Have you tried to create a local variable from the array?

 

Read the above answers. There is one that works using a local variable (or a global variable).

Message 21 of 32
(2,334 Views)

Yes, I understand that example were they use an array local variable.

I haven't created a local variable but I've never done one, I will try do do that!

Thanks for your sugestion Cat Embarassed

0 Kudos
Message 22 of 32
(2,328 Views)

Just do a right click on the Block Diagram, select Programming\Structures\Local Variable.

Once created the local variable, click on it and a list of objects will be shown. Select wich object you want to use the local variable for.

 

 

 

Message 23 of 32
(2,323 Views)

Hi,

 

I tried but I couldn't find the array in the local variables.
I can only reset the array for the time. Am I doing something wrong?

 

 

0 Kudos
Message 24 of 32
(2,312 Views)

Local variables only link to controls or indicators.  Your VI does not have any arrays wired to a control or indicator.

 

I modifed your VI to show one way of resetting an array.

 

1. I used the Clean up tool to re-arrange the block diagram.

2. Add Case structure.

3. Use empty array to reset feedback nodes.

 

 

You do not need the local variable for Number(0 to 1).  Just wire directly to the terminal.

 

Lynn

Message 25 of 32
(2,285 Views)

Thank you so much!  It's working Smiley Very Happy

 

I have a question: When you insert an empty array into the 'Insert to an Array' function, it erases the whole array?

 

I also changed the VI so each time I start a signal aquisition in cleans up the arrays and time first, automatically

It was my first time using local variables. yayy

Another question is this the most efficient way? Should I do shift register?



0 Kudos
Message 26 of 32
(2,263 Views)

Technically you are not inserting an empty array into the Insert into Array function. The item being inserted is the scalar value from Elapsed Time or the Random function.  But, yes, it has the result that you are starting with a new empty array.

 

Insert into Array is not very memory efficient as memory re-allocation continually occurs as the array grows. Also, inserting at the beginning of the array requires moving all the elements of the array each time.  It is generally better to initialize the array to the maximum size you expect outside the loop and then use Replace Array Subset inside the loop.

 

I am sorry you got so excited about using local variables.  Local variables should not be used in this manner.  They are prone to race conditions, break dataflow, force execution in the UI thread, make extra copies of the data, and are slow.  The only common justification for use of local variable sis when the value of a control needs to be changed programmatically, typically at initialization or loading data from a configuration file.  Shift registers and wires are the preferred way.

 

Lynn

Message 27 of 32
(2,261 Views)

Thank you again!  I did Labview core 1 workshop a year ago but I never used it until now and actually remember something about not using local variables.

Should have practiced more then. Smiley Happy

 

I now understand I should use shift register in loops (While,for...) if I want to copy information from iteration to iteration.

I think I just finished my first labview VI with a Save File button. It must be a bit far from perfect but I'll post it here if anyone finds and want to use it.

 

Regarding the memory effiency of this project, sometimes I might acquire at time constants of 10 microseconds up to several minutes of aquisition time.

I understand I shoud allocate the arrays for better efficiency but sometimes a just acquire a few seconds.

Do you think the measurement could be 'slower' or error prone due to the constant re-allocation of the array?

0 Kudos
Message 28 of 32
(2,242 Views)

How many re-allocations of memory you have depends on the size of the arrays. The exact values are not published, as far as I know. How long it takse to re-allocate the memory is also not well defined. The OS may be involved or LV may be able to create a new allocation within memory is already has.  The data has to be copied to the new memory locations.  If your arrays never get very large, it may not be an issue.  If you are acquiring at 100 kHz for several minutes, you could have hundreds of megabytes of data (per channel).  At that level you definitely should be thinking about careful memory management.

 

I think your feedback nodes and shift registers are storing the same data. I do not think you need both. Since you are saving in the false case, the data needs to be available outside the case structure. I prefer shift registers, partly because they were the only option for some years. Either can be used.

 

Lynn

Message 29 of 32
(2,235 Views)

how to make a RESET button in labview ?

0 Kudos
Message 30 of 32
(1,350 Views)