LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

stoing values into an array when a button is pressed

Hello

 

This is the desired scenario.

I have created a stopwatch using LabView.

Pressing the GO button, the time runs.

Pressing the GO button again, the time stops and the values will be transferred into an array.

Pressing the GO button again, the time runs again.

Pressing the GO button again, the time stops and the values will be transferred into the next array member.

 

My question is, how can i get the values to be stored into the array?

  

Thank you. 

0 Kudos
Message 1 of 6
(3,918 Views)

I am going to assume that you will have a set number of elements in your target array.

 

  1. Initalize your array to default values
  2. Feed this array into a shift register
  3. Use another shift register (Count SR) to keep track of which element to replace
  4. When you want to save the timer value - use a Replace Array Subset function indexed with the "Count SR" to update the array
  5. Increment the "Count SR" after step 4 and check to see if the count value needs to be reset to zero (i.e you reached the end of your array and need to restart at the beginning)


Note that you will also have to detect whether you are in "go mode" or "stop mode" to determine if you are starting the timer or stopping the timer and storing the result.

 

From a user standpoint, it would be nice to have the button change from Go to Stop so it is clear what will happen when the button is pushed.

 

If you have more questions please ask. If you post your code I can be more specific on a solution.

 

steve

----------------------------------------------------------------------------------------------------------------
Founding (and only) member of AUITA - the Anti UI Thread Association.
----------------------------------------------------------------------------------------------------------------
0 Kudos
Message 2 of 6
(3,909 Views)

As it is a stopwatch, there wont be a fixed number of elements

it has to be dynamic

 

any changes for this method? 

0 Kudos
Message 3 of 6
(3,884 Views)
I'm lazy, I didn't use a GO button, but this code add's one element to an array every second. Is this what you need?
0 Kudos
Message 4 of 6
(3,881 Views)

i think i can get some ideas from that program of yours

i will try mine out 1st

 

 

thanks a lot 😃 

0 Kudos
Message 5 of 6
(3,877 Views)

Hi,

 

A simple soluce (use an event structure with build array) => see attached files

0 Kudos
Message 6 of 6
(3,855 Views)