LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Elapsed Timer working in Message Queue(Event-Message Handling Loop)

Hi All,

Good day. Beginner here. I have been developing a LabVIEW code for Pressure Drop project. I am using a relay to control the valve

and motor(switching it on and off). 

 

I am using Event-Message Handling loop as an example shown from attached screenshot. I can control switching ON/OFF the boolean

controls. However, the Elapsed Timer I am using does not seem to work properly. 

I have been searching some forums here about making the Elapsed Time work, like adding a "Timeout" case from Event Handling loop and do the code from there, however tried it but still does not seem to work properly or maybe I just don't know how to code it properly. 🙂

 

If someone can help me suggest the better or simpler way on how to get timing working on specific boolean(to switch ON/OFF) using Event-Message Handling loop then it would be great.

 

I have tried Flat Sequence structure, and the Elapsed Timer seems to work ok without any issues within my code.

 

Thanks for your help in advance.

 

Cheers!

StayHappy

0 Kudos
Message 1 of 4
(2,282 Views)

Hi StayHappy123,

 

I see in your VI that the Reset input of the Elapsed Time VI is wired to a control called Reset Valve Timer. Is the Reset Valve Timer Control the boolean control marked as "Relay 1 - VALVE (ON/OFF)" on your front panel?

 

I ask this because if the control is set to true and uses a switching action (as opposed to a latching action), the Elapsed Time VI will be stuck at 0.

 

Best Regards,

Ramsey Doany

Technical Support Engineering

National Instruments

0 Kudos
Message 2 of 4
(2,252 Views)

Hi Ramsey,

 

Many thanks for your reply. Yes, the Reset Valve Timer Control is the boolean control for Relay 1 - VALVE(ON/OFF.

This control is set as "Switch when released" as Latching is not allowed for this control.

 

The algorithm for this is that the "Reset Valve Timer" which is the control of Relay 1 - VALVE(ON/OFF, needs to be set to True so that once the timer expires, once this is switched ON, it will switched of the Relay 1-VALVE(ON/OFF) to OFF.

 

I don't think this is the issue that the Elapsed Time VI will be stuck at 0 as I used the same code using Flat Sequence and the Elapsed Time works fine.

 

So must be something to do on how timing is called/coded and works with Event-Message Handling loop.

 

Thanks

0 Kudos
Message 3 of 4
(2,238 Views)

Next time, please attach your sample VI rather than that picture.  You're asking people to troubleshoot your application and the timing associated with it based on that picture.  That's not often a trivial task.  There isn't anything here that begins to look like it's proprietary enough that you're gaining more value abstracting away what you're working on.

 

That said, the last post looks pretty accurate.  Let's look at the logic of your VI.

 

You have the EHL set to switch the value on and set off an event (which honestly, you should find a way to stop using the local variable so you can use your latching and get your value that way.  Now, I'd expect you to trigger two+ events each time you're pushing this button).  In that event, you enque a message to run the switchONVALVE case.

 

In the MHL, you're presumably handling multiple messages.  In one of those messages, you do some things including using a flat sequence structure that doesn't really do anything other than clutter your code, resets an elapsed timer, immediately outputs the value, and ends the case.

 

As this Elapsed Timer exists within a case that will only run when you call the message to reset the timer, it will always immediately output the 0.  That results in it only updating the Front Panel with that 0 value.  That Elapsed Time VI cannot run in any state other than reset valve timer = TRUE. 

0 Kudos
Message 4 of 4
(2,223 Views)