LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop an event from passing from one frame to another with Flat Sequence

Hi! I'm new to LabVIEW and I'm trying to create a simple calculator, I'm using a flat sequence to get the first number with event structure and then get the second number also with event structure also.

 

So far I'm not able to choose the second number, because when i press the button to choose the first number, the event at the first frame gets triggered, and it also gets passed to the second frame, so the same event goes for the first and second number.

 

I'm wondering how is it possible to stop the event from passing between the frames automatically? and if there is a better way to do this?

 

I also tried it with while loop, but the event get passed the same way from one iteration to the another, so the same thing happens.

 

My VI is attached, thank you for your help!

0 Kudos
Message 1 of 9
(302 Views)

All you need is one toplevel loop and one event structure with several events.

 

(Your code makes no sense. Start with some simple tutorials. Learn about the basics of dataflow. Search the forum and examples for calculator to get some ideas.)


LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 2 of 9
(288 Views)
Highlighted

When using event structures, I would recommend reading up on the caveats and recommendations.

 

https://zone.ni.com/reference/en-XX/help/371361R-01/lvhowto/caveatsrecmndtnsevnts/

 

To explain at a high level what is happening in your VI the event isn't being "passed" into the second frame, the click is actually sending that event to both structures at the same time. Each event structure is configured to handle a set of events and when one of those events happens it ends up in that event structures queue. When it comes time for the event structure to execute, it looks at its queue and if there is an event that needs to be handled it goes ahead and executes that case. When you run your VI and click "1" LabVIEW basically sees that there are 2 observers waiting for that event and separately tells both of those observers that "1" has been clicked.

 

As mentioned, you could probably do this whole thing by putting the event structure in a while loop. You'll also want to look up shift registers for storing information between iterations.

Matt J | National Instruments | CLA

GCentral
Message 3 of 9
(229 Views)

Hi altenbach! thank you for your answer.

you are right the code didn't make much sense, i have changed it and it kind of works correctly now with one while loop and one event structure, but i'm still learning how data flow works.

 

I looked up some calculator examples and they were very helpful.

0 Kudos
Message 4 of 9
(188 Views)

Thank you Jacomson for your detailed explanation, i wasn't sure how the events were being handled, but now it's much clearer.

 

I will take a look at the events caveats, and understand all the details.

0 Kudos
Message 5 of 9
(183 Views)

@salaryunis wrote:

Hi altenbach! thank you for your answer.

you are right the code didn't make much sense, i have changed it and it kind of works correctly now with one while loop and one event structure, but i'm still learning how data flow works.

 

I looked up some calculator examples and they were very helpful.


Good! It seems you are a fast learner. Fell free to ask more question or show us your "kinda works" efforts and we probably can speed up the learning curve even more with specific advice. Good luck!


LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 6 of 9
(146 Views)

I have changed it a bit and now i got this VI. Now it works for individual numbers (1 digit) only, and simple math operations.

 

Any ideas on how to implement it for larger more digit numbers would be appreciated.

0 Kudos
Message 7 of 9
(89 Views)

Your VI is broken. Did you attach the right one?


LabVIEW Champion. It all comes together in GCentral GCentral
0 Kudos
Message 8 of 9
(69 Views)

Hi altenbach, sorry it was the wrong VI.

0 Kudos
Message 9 of 9
(51 Views)