LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do you skip a state in a state machine for a given amount of time?

I am trying to simulate a temperature monior in which an alarm will go off if the temperature is too high or too low. However, once the alarm goes off once, I would like the data to still be acquired but I don't want the alarm to go off again for 2 minutes (or an arbitrary amount of time). This way the user will not have to continually press ok every second. I've tried several ways and cannot figure out how to do this. Here is my vi. Any help would be appreciated and if this doesn't make sense feel free to ask. Thanks!
Download All
0 Kudos
Message 1 of 3
(2,712 Views)

First, I recommend that you take a little time to clean up your code. Take a look at the style guides. The first thing I noticed was hidden wires (wires going under other constructs). Cleaning up the code will help to make it easier to understand and easier to maintain.

 

As for your original question I generally like to separate the data acquisition task from the UI task. If you separate these items it will be easier for you to achieve what you are looking to do. The UI task code activate the alarm and take care of the timing between alarms. Your data acquisition task can run continuously and not be impeded by the UI processing. Use a queue to pass the relevant data between the tasks. You could also use an action engine/functional global if you are basically passing state information between the tasks.

 

If you keep all the processing in the single task than you will need to add a state which will check if you need to generate the alarm again. This state will need to be inserted when in an alarmed state and this will track the timing for you. From here you can go back and read the data. Again though, it is generally best to isolate the data acquisition in its own task.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 2 of 3
(2,709 Views)

Hi Alana,

 

Firstly, i completely agree with Marks advice. If you do have time i would change the architecture of your vi as it is not suitable for what you want to do. Look at examples of Producer/consumer and Master/Slave architectures. I understand though that if you have a deadline and you are not familier with these architectures then you may be reluctant to start over.

 

I have written a small vi that i believe can be added to your existing code to overcome the current problem you are facing.

 

Timed False Latch Snippet.png

 

What this vi does is when a true value is detected it outputs it the first time. It then sets a timer. Whilst this timer is active the sub vi will only return a value of FALSE no matter what the input is. Once the timer has timed out it will reset. Having looked at your code i believe this will sort your problem.

 

Insertion Point.png

 

You can see above where i have added this sub vi in your code, in between the OR function and the Select case. The first time that you enter a true value, ie it alarms, you will select the 'Alarm State' state, all subsequent cycles will be forced to select the 'No Warning' State until the timer has elapsed. I have shown it here with a 20 second timer. You can adjust this to get the time you require.

 

Another quick point. I beleive that your 'No Warning' State is useless as all it does is select the 'DaQ Acquisition' state, which is the state you are currently in. Why not just select 'DaQ Acquisition' state from here?

 

Anyway, in summary, this will be just a quick fix as if you do not change the architecture im sure that you will encounter other problems, especially if some of the functionality changes in the future.

 

I will attach in LV2009 and LV 8.6 as you have not specified your version. Hope this helps,

 

Regards,

 

Lucither

Message Edited by Lucither on 03-24-2010 09:35 AM
------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 3 of 3
(2,686 Views)