From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

User-defined measurement time

Solved!
Go to solution

Hello all,

 

I'm trying to do something which to my mind should be quite simple, but I'm having some issues with it! I'd like my VI to have a user-defined "Total run time = 30mins, Take a 10-second measurement every 5 minutes", for example. I can so far set up a loop to measure every e.g. 25 seconds, but the measurement is a single data point, plus I can't figure out how to stop the VI after a user-set period of time.

 

The system is essentially to measure a change in light level over a certain, changeable period of time. I'm using an Arduino with LINX, though the problem I have above is with standard LabView programming.

 

Any help much appreciated, thanks!

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

Hi RNG,

 

sounds like a nice example to learn basics of a statemachine, using states like:

- do measurement

- save data

- wait for next measurement

- stop after 6 measurements

 

Each state on it's own should be analyzed on it's own, then start the programming!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 5
(2,558 Views)

Thanks for the reply!

 

I've tried the State Machine (I hadn't used this before), and though as far as I can see each case should work on its own, there's no operability at all when the program is run. The LINX stuff is all fine. Is there a glaring error I'm missing? Cheers,

0 Kudos
Message 3 of 5
(2,518 Views)
Solution
Accepted by topic author RNG

Hi RNG,

 

you missed a main point of state machines: their unique state identifier!

You started with an enum to initialize the shift register, but in the loop you don't switch states according to that enum. Instead you wired some "elapsed time" outputs resulting in DBL values in shift register that should keep enum values instead…

 

Next point: When your state machine should run automatically it is a bad idea to stop states (or loops in the states) with some stop buttons on the FP.

 

Your elapsed time will be a stop condition. The stop button can/should be used for emergency stops (by calling for a different state)…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 4 of 5
(2,501 Views)

Hi there,

 

Thanks for the help (I've been on holiday the past week). I've implemented a basic State Machine, and it seems to have solved the problem. Attached is the VI for anyone in the future with a similar issue. Cheers,

 

RNG

0 Kudos
Message 5 of 5
(2,385 Views)