LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multibutton App

Feel free to use "save for previous" before attaching your VI. Most here cannot open LabVIEW 2021 yet.

 

You already got some excellent advice why your code concept (that we have not seen!) is a bad idea overall.

 

Your CPU runs at GHz speed and even a fast gamer cannot press a front panel button more than a few times per second. From the perspective of the computer, literally eons pass between clicks. trivial to keep up!

 

It is also incorrect to use mouse-down events. Use a value changed and latch mechanical action buttons. (Mouse down events can be dangerous, because they also trigger on disabled controls and even indicators. They have their use, but that's not it!)

 

Not sure how (and why!) you are passing data to "other events".

 

All you need is one toplevel while loop and one event structure, assuming that the code inside each event can execute sufficiently fast. If each event triggers lengthy algorithms, use a producer-consumer architecture and do the processing elsewhere.

Message 11 of 17
(1,104 Views)

OK, I had a chance to look at your code and it is beyond repair. Obviously, you have not concept of dataflow and what an event structure actually does! The entire lower loop is completely constipated. it can only go to the next iterations once all event structures have fired, and unless they all fire exactly once per iteration, you'll get event queue buildup that can never be serviced.

 

At this point, you need to start with the learning resources listed at the top of the forum and familiarize yourself with the magic of dataflow and graphical programming. Then write your program without the use of any event structures! (event structures are an advanced topic with several landmines unless you really know what you are doing. They should only be used once you are very familiar with LabVIEW.

 

Also: There is no need to use value property nodes, but your code is peppered with them. (you must be coming form a text based programming background.). Don't use decorations to structure your code. They have no function.

 

 

altenbach_0-1655997171379.png

 

Message 12 of 17
(1,096 Views)

Thanks for your reply,

 

the reason why I want to pass data to other events is the following:

With one button I want to initialize my port and other parts of my software. And I need this initialized Port later for other functions. At the moment, I have no clue how I should pass the data on a other way.

 

I think I need to do a lot of research about the dataflow etc.

0 Kudos
Message 13 of 17
(1,083 Views)

You definitely need to go through the learning resources before you move on. As Christian () said, this code is a total mess and you will basically need to start over. A well written LabVIEW program should very rarely need to use local variables or value property nodes. These should only be used in more complex UI code. General program logic should not use them. Look into shift registers for passing data through your application.



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 14 of 17
(1,076 Views)

You're not quite "thinking dataflow" yet. Remember, any node (VI, structure, whatever) cannot execute until ALL of its inputs have triggered. And a loop will not finish until ALL of its internal code has fired.

 

Since you have multiple event structures in your lower loop, that lower loop will never fire until ALL structures have fired, which isn't what you want.

 

You need only one single event structure, but one that can handle multiple events. Right click on the top of the Event Structure and click "Add Event". Then, that event structure will return when, and only  when, exactly one event fires. You'll probably have one event per button.

 

Use shift registers to loop all of your data back around, and do one "thing" per iteration of the loop. Inside each event case you put the logic for that event. That way, the loop runs when anything happens, not when everything happens.

0 Kudos
Message 15 of 17
(1,067 Views)

@altenbach wrote:

 The entire lower loop is completely constipated.

 

 


Is that your new favourite word... granted, it accurately describes the code.

6 Event structures?! That has to be a new record.

 

(Oops, not adding anything constructive here, am I)

---------------------------------------------
Former Certified LabVIEW Developer (CLD)
0 Kudos
Message 16 of 17
(1,050 Views)

@Frozen wrote:

Is that your new favourite word... granted, it accurately describes the code.


I am sure there is a medical term for it. 🙂

0 Kudos
Message 17 of 17
(1,038 Views)