LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using an event handler with a elapsed timer to record data upon change in a control

Solved!
Go to solution

Hello,

 

I am still learning labview and read through the previous posts and did not see an appropriate solution, so your recommendations would be appreciated.

 

I am trying to design a .vi that tracks the results of a race for a 5/10k. Once the .vi is started, the elapsed time function begins and is displayed on the front panel. This would continue until the program is stopped with with "Stop" button on the front panel. While this timer is going, if the "Bib Number" control value is changed, it records the new bib number and the elapsed time of the event. I have this much working, but I have a few issues.

 

First, I have read that it is usually bad practice to use an auto-indexing tunnel with a while loop, which I am currently doing. Instead, should I be manually indexing the array, "Race Time by Bib number" array within the event structure or array? Would this allow me to see the "Race time by bib number" array update while the program is running?

 

Second, since I do not want anything recorded if the "Bib Number" is not changed, I have not wired anything to the output tunnel in the timeout event. Obviously, this will send the default zero to my array and store useless data points. If I use the default -1 input to the timeout event and put the "Elapsed time" outside of the event structure, the "Elapsed Time" does not show up on the front panel. How do I change this to avoid storing many rows that are only zeroes?

 

The .vi is attached to help you understand my question.

 

Thank you in advance for your assistance.

 

Brian

0 Kudos
Message 1 of 6
(1,258 Views)

This is one of those rare occasions where a local variable or two won't hurt too much.Pi Mile Run Race Timer and Runner Times_autoindexed while_BD.png

Too be fair. A Producer Consumer (Events) design pattern would be preferable for scaleability but the consumer State machine in this application is really a rock simple stupid Elapsed Time Express vi .

Scientists STAND on the shoulders of giants! They don't ride "piggyback" to keep their heads down.

"Should be" isn't "Is" -Jay
0 Kudos
Message 2 of 6
(1,249 Views)

Jeff,

 

That works, thank you. How can I see the "Race times by bib number" array updating as the .vi is running and new bib numbers are enetered?

 

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

Hi blaqua56

 

You have the indicator for "Race times by  bib number" outside the while loop. It is going to update the value when the loop stops. If you need to update it while the vi is running you should build the array and display the indicator inside the while loop.

 

Regards
0 Kudos
Message 5 of 6
(1,205 Views)
Solution
Accepted by topic author blaqua56

fromm8, thank you. 

 

In case someone searches for this solution in the future, I have attached my final .vi.

 

 

0 Kudos
Message 6 of 6
(1,199 Views)