LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reduce coding ways

Hi

i am trying to build a project which logs time when a button goes high the first time after a traget time is reach.and in the same way i want to know the last time a button was pressed .

i have made it already , however, i want to reduce the code is there any simple way of doing this.

 

0 Kudos
Message 1 of 5
(2,868 Views)

Try using an Event Structure. You can do all of your comparisons in one event case and then use the result to determine which indicator to update.

0 Kudos
Message 2 of 5
(2,828 Views)
Hi,

In your second loop, instead of performing two comparisons and a logical AND maybe you could use the "In Range and Coerce" VI 😉
CLAMaxime -- Kudos are a great way to say thank you
0 Kudos
Message 3 of 5
(2,819 Views)

You only need one loop and you don't need any local variables.

 

Place a string array with two elements in a shift register (stor, last press) and replace the approriate one depending on the state.

 

You could also use a string in a shift regsiter and append a line with a time and description whenever a button is clicked, for example.

You need to be very careful the way you are doing time comparisons, because the numbers are compared alphabetically as strings and the times roll over at midnight. For example if you would start the code right before midnight, the lower loop would stop immediately.

0 Kudos
Message 4 of 5
(2,786 Views)

@altenbach wrote:

Place a string array with two elements in a shift register (stor, last press) and replace the approriate one depending on the state.


I would actually just keep the timestamp instead of the strings.  This would make the calculations a lot simpler.  It is easy enough to change differences to strings when you have to report.


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
0 Kudos
Message 5 of 5
(2,780 Views)