LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

event structures with multiple timers

Solved!
Go to solution

How would it be best to implement timeouts from an event statemachine where there would be three independent timers for LV8.6? one at 50ms, one at 300ms and another at 10s. The event control already handles value change events for a number of boolean VIs. I'd like to use the timers to know when I should update my display (50ms for LEDs, 300ms for current measurements via GPIB, 10s for temperature measurements).

 

What I've thought about so far:

* I'm not sure that the event timeout is what I want, as it  restarts every time the event structure is entered and there is only one timer value. I'd have to get the current time, look up when I expect the next event to fire and program that. That's the way I'm leaning towards at the moment.

* Using parallel loops to the event structure would be problematic as it lives inside a state machine and could only advance when an event occurs and a timer expired. It would also look complicated for what it is.

 

 

0 Kudos
Message 1 of 5
(3,813 Views)

Well,

 

in my opinion it is always a bad idea to use the timeout event. To be honest, i would remove that "feature" completly from the event structure.

The simple reason:

Either you want to poll or you want to work event based. Timeout somehow mixes that leading to difficulties.

So i suggest you to do the following:

1) Find out/define if the activities, which should happen in a certain timeframe, have something to do with functions included in the event structure. If they do, proceed with 2A), if not, take 2B).

2A) Create parallel loops which are timed properly for your activities. Since the activity is linked to code inlcuded in the event structure, you have to create and send user events as needed in order to execute the event structure and its appropriate case.

2B) Create parallel loops running completly independent to the event structure. Since there is no connection (except maybe stopping them), there is nothing more to do in the first instance.

 

hope this helps,

Norbert

 

PS: And please remove the timeout case 🙂 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 2 of 5
(3,799 Views)

Thanks for the reply. I guess I could rewire the LEDs somehow with advanced DAQmx to generate events on digital input changes (removes the 50ms timer) but the other two (300ms and 10s) needs to be polled. The while loops will need to be completely out of the while/case statemachine and I'd have to add logic because I don't want to poll for the entire program, only under certain states. A queue could probably do something like this I guess and have a second statemachine. Now it's getting complicated again.

 

So are you saying there are no such thing as "timer" events, where I put on a control and it can trigger an event that the event structure can react to?

 

I could be hackish and put a numeric control that get's incremented with a while loop running in parallel tot he while/case state machine and use value(signal) update that would trigger an event. Not sure I like this from a purist point of view.

 

Of course, by having a parallel while loop i've also just complicated the "stop" feature where to stop I need to send a bunch of notifications which could be handled very nicely when event driven.

 

Then I could get rid of the timeout event.

 

Thanks,
jason.

0 Kudos
Message 3 of 5
(3,792 Views)
Solution
Accepted by topic author jcurl

jcurl wrote:
[..]

So are you saying there are no such thing as "timer" events, where I put on a control and it can trigger an event that the event structure can react to?

[...]


Jason,

 

i am not sure if we are talking about the same thing here.

I just wanted to point out that to my experience, the timeout of event structure leads to confussion and most often leads to applications mixing event based programming with polling in a single loop. And that is a bad idea.

 

You can always define user events and create a case for this user event. The source for the user event could be a timer... so you have all possibilities you'd want.

So example:

Loop A contains the event structure (nothing more). The loops timing is defined by the frequency of incoming events. Eventsources are e.g. several buttons, a numeric control and one user event.

Loop B polls for certain states of your system. If the desired set of states is given, you'd create an user event.

So loop B would somehow "time" loop A.....

 

I hope that was now expressed in a better way,

Norbert

 

PS: Please keep in mind that it is recommended to use only one single event structure in the application! 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 5
(3,776 Views)

We're talking about the same thing. I haven't used user events yet but that's probably what I want.I was hoping LV86 might even have this as a static event. In case I have problems I'll start a new thread.

 

I'll be using two event structures because I have two operating modes (pre-test checks and verification and control) and automated tests that are sufficiently different from one another.. I'll see how that goes and if I have problems I'll figure out how to refactor it.

0 Kudos
Message 5 of 5
(3,771 Views)