LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

add new element to existing array by pushing a button

hi 

i have empty array  i want to add adjustable number to first array by pushing button 

then by pushing the button again the adjustable number goes to second array without losing my first number and continue doing this.

 

0 Kudos
Message 1 of 6
(2,176 Views)

On the first page of this Forum, there is a section called "LabVIEW Training Resources" which list Tutorials and Videos that you should view and follow.  You need to learn about more than putting fancy gadgets on a Front panel.  If you have had some programming experience (Basic, Matlab, C), some of the LabVIEW concepts may seem familiar, but the power in LabVIEW comes from some of its "unconventional" components designed to make it an Engineering Workbench.  These include the concept of Data Flow, the use of Time as almost a "data type" (including a number of tools and data structures built around data sampling, such as the Waveform data structure), how data acquisiition and process control arise "naturally" (and how easy it is to collect data with DAQmx).

 

Once you've spent a little time (and you should have plenty of time now) with this material, you should be more than able to start over and design a VI (or VIs) that will do this task for you.

 

Bob Schor

Message 2 of 6
(2,168 Views)

I recommend you learn about the following concepts:

1. While Loop (repeat code until you give it a stop condition)

2. Shift Registers (hold data from previous iterations of a loop)

3. Event Structures (easily detect when a button is pressed)


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 6
(2,156 Views)

this vi is what i did with while and case structure and shift register.

do you have any idea to make it optimized?

Thank you.

0 Kudos
Message 4 of 6
(2,135 Views)

1. Store your array in the shift register.

2. Use Replace Array Subset to update the one value you care about.

3. How often should this array be updated?  If you only want it updated on a button press, then use an Event Structure with the button's Value Change event to update the array.

4. You need to supply a real stop condition on your loop.  Do NOT rely on the Abort VI in the toolbar to stop your VI.  A simple Stop button on your front panel will do the job.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 6
(2,129 Views)
  • Please give your VI a reasonable and unique name before attaching ("untitled 1.vi" is not a reasonable name. My browser renamed it to "untitled 1 (15).vi" because so many others did the same as you :().
  • Please don not maximize the front panel and diagram to the screen. You need to be able to look at the LabVIEW help while programming. Do you?
  • There is a "+1" primitive.
  • It is a really bad idea to set the index of an empty array diagram constant to 10, because it would be impossible to tell if it is really empty.
  • Do not use "continuous run". That's only a debugging tool. Yes, you need a toplevel while loop with a reasonable small wait.
  • Notice the red coercion dots? Make sure that the array constant matches the element representation.
  • To append a new element to an existing array, use "built array", not "insert into array". Of course you want to carry the accumulated array also in a feedback node, else you are inserting into a nonexistent position once the index is no longer zero.
  • In addition to the suggested learning resources, also search the forum. There are plenty of examples for exactly what you are trying to do.
Message 6 of 6
(2,097 Views)