LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Auto press button


@Oesen wrote:

Thanks for the answers everyone. i also need a stopwatch to show the time in every measurement, so i have to use the elapsed time.. I so i must add a timeout event ?.. I made that program for a single scale, but the second scale is exactly the same type, so i copy/pasted the program and got two event structures. What is the disadvantage of having two event structures ?


 

If you have two event structures in a single VI it is possible for events to get dropped. Only one event structure may get an event.

 

As for copying and pasting code this is generally not a good way to reuse code. Make it a subVI. If you find a bug in the code now you have to fix it is two places. A single reusable subVI is easier to maintain. It also makes it easier to support 100 scales. Would you copy and paste the code 100 times? Code modifications there would be a real nightmare.

 

You don't need the elapsed timer if all you want to do is get a time stamp. Simply et the current time. If you want the delta than subtract your prior time from it.

 

Here is a basic example of what I mean.

 

Simlpe Event Timeout.png



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
Message 11 of 17
(1,093 Views)

Mark_Yedinak wrote:

Do not use two events strtuctures within a single VI. A VI should only have a single event structure.


THere's nothing really wrong about having two independent evet structures as you do here, because each is in it's independent loop:

 

However, the outermost case structure just potentially gums up the code once you add more cases. Event structures should never be inside case structures. DElete that case structure, tehre is no heed to wire anything to the tab terminal.

Also, the way you append new data to the 2D array is pure rube goldberg. All you need is a simple "build array". (no need to get the size and the use insert into array.)

There is some more constipation, for example the timer cannot be reset unless it is running. ...

Message 12 of 17
(1,074 Views)

@altenbach wrote:

Mark_Yedinak wrote:

Do not use two events strtuctures within a single VI. A VI should only have a single event structure.


THere's nothing really wrong about having two independent evet structures as you do here, because each is in it's independent loop:

 

However, the outermost case structure just potentially gums up the code once you add more cases. Event structures should never be inside case structures. DElete that case structure, tehre is no heed to wire anything to the tab terminal.

Also, the way you append new data to the 2D array is pure rube goldberg. All you need is a simple "build array". (no need to get the size and the use insert into array.)

There is some more constipation, for example the timer cannot be reset unless it is running. ...


I have had problems with two event structures within a single VI, at least if they were both registered for the same event. For example, with a common stop event only one event structure would actually receive it.

 



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
Message 13 of 17
(1,071 Views)

@Mark_Yedinak wrote:

I have had problems with two event structures within a single VI, at least if they were both registered for the same event. For example, with a common stop event only one event structure would actually receive it.

 



I have never seen that problem.  If two different event structures are registered for the same event, then they will both get it.  Now there are some issues if you are doing it using dynamically defined user events.  I think in that case you need to register the same event twice and pass each event refnum to the different event structures.  Two event structures can't share the same event refnum.

Message 14 of 17
(1,069 Views)

@RavensFan wrote:

@Mark_Yedinak wrote:

I have had problems with two event structures within a single VI, at least if they were both registered for the same event. For example, with a common stop event only one event structure would actually receive it.

 



I have never seen that problem.  If two different event structures are registered for the same event, then they will both get it.  Now there are some issues if you are doing it using dynamically defined user events.  I think in that case you need to register the same event twice and pass each event refnum to the different event structures.  Two event structures can't share the same event refnum.


All I know is that I was using a library of our system events and when I had used them in parallel within a single VI it didn't work. Placing the lops into subVIs resolved the problem. Each event structure had it's own refnum. Given the issues I had I adopted limiting VIs to a single event structure.

 



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
Message 15 of 17
(1,067 Views)

Hmm.. so i must add the "type" and "time" element in the "measurement" event case and move my write and read into the case structure in that basic example ?

Best regards

Oesen
0 Kudos
Message 16 of 17
(1,035 Views)

The type and time are not required. They are available for any event. You can't hide the information, at least not completely. However you should notice that it is not wired to anything so they are not used. And yes, you would either put the code you need inside the case statement or post a message to another task there. I avoid running any code in an event structure that takes more than about 10 ms to execute.



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
Message 17 of 17
(1,020 Views)