01-09-2017 03:16 PM
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?
Solved! Go to Solution.
01-09-2017 04:28 PM
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.
01-09-2017 04:45 PM
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.
01-11-2017 10:58 AM
My end-goal is to have it begin monitoring the accelerometer again after 10 seconds and determine the case.
01-11-2017 10:59 AM
Thank you for your advice! I will look into maybe moving the case around and see if I can obtain my desired result.
01-11-2017 01:11 PM - edited 01-11-2017 01:12 PM
@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! 🙂
01-12-2017 10:12 AM
billko,
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?
01-12-2017 10:53 AM
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.
01-12-2017 01:05 PM
crossrulz,
Using the Elapsed Time VI worked. Thank you for your assistance!