Showing results for 
Search instead for 
Did you mean: 

Trying to Add a Timing Element to Case Structure

Go to solution

Hello, I am new to LabVIEW and currently working on a project to design a system that detects when an accelerometer has exceeded a predetermined value and then triggers a case statement. The condition to this is that I would like the case statement to be delayed 10 seconds to determine the final case. I have looked into multiple timing functions and LabVIEW and have had no success as I believe the while loop I am using prohibits them. I am currently using LabVIEW 2016 (Student Edition) with an NI MyDAQ to collect and analyze my data. Could someone help me with this issue?

0 Kudos
Message 1 of 9

The neat, standard way, to do it is to use a state machine. It is a ubiquitous design that is really useful for you to learn.


If I understand your requirements correctly you could also do it in a way more like your current design.

I am not going to do your homework, but here is a hint: Consider whether your "final case" should be in the same while loop as the initial detection code.

0 Kudos
Message 2 of 9

There is also the question of whether you only need to verify if it meets that condition after 10 seconds, or if you need to verify if it met that condition for the entire 10 seconds.

Part of what I'm seeing in your code is that the delay is outside of your data flow, so all it is doing is making the case statement wait for 10 seconds before it can exit.

using LV2017SP1
0 Kudos
Message 3 of 9

My end-goal is to have it begin monitoring the accelerometer again after 10 seconds and determine the case. 

0 Kudos
Message 4 of 9

Thank you for your advice! I will look into maybe moving the case around and see if I can obtain my desired result.

0 Kudos
Message 5 of 9

@BryceHina wrote:

Thank you for your advice! I will look into maybe moving the case around and see if I can obtain my desired result.

Don't just "move it around" randomly.  Think about what you are doing.  Think about DATAFLOW.  The two rules of dataflow: 1) A node will not execute until all of its inputs are satisfied. 2) A node will not produce and output until it has completed.


Follow your code around by using the lightbulb (highlight execution) to help you understand this concept.  By using the two rules of dataflow above, you should be able to predict what will happen and in what order.  If the rules don't dictate which node will execute first, either of them could execute in any order.


Good luck!  🙂

(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
Message 6 of 9



I understand what you're saying with the dataflow, but it raises a problem for me. When I separate the "Final Case" from my initial detection, I am unable to continue obtaining data from my MyDAQ. This is because the initial detection while loop has ended. I can't place a new DAQAssist and get data from that either. Is there a way that I can continuously read data, detect for a fall, and read to detect if there is movement over a ten-second period using one MyDAQ?

0 Kudos
Message 7 of 9
Accepted by topic author BryceHina

1. You do not want to use a hard Wait.  That pauses everything.  Instead, use the Elapsed Time VI.  It can tell you when X seconds have passed since the last reset.  When that much time has passsed, you perform your task in that "Final Case".  But the idea is that you are constantly looping and reading the DAQ while you are checking to see if the right amount of time has passed.

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 8 of 9



Using the Elapsed Time VI worked. Thank you for your assistance!

0 Kudos
Message 9 of 9