From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use a Timer and an Event case with LIFA/Arduino

Solved!
Go to solution

Hi everyone,

 

I feel like my question will sound really stupid, but I cannot find the solution. I want to use my arduino to do two task at the same time. I want to use a while loop with a timer, to read my pins in my arduino. That is really easy. But then, I want to use also an event case to do different type of things. In the example I downloaded, I simply use an event to activate my fan. Once again, I have no problem to use this by itself. But I cannot find a way to use the both at the same time, especially when I want to exit my app. Because I use my arduino inside of my event case, I put it in another while loop. But, I also want another while loop, but which uses the timer. In my example, if you use the Highlight Execution tool, you clearly see that my signal goes to the while loop that contains the event case, but not the other one I want to use as a timer. It's probably because I miss something about the architecture, it's just to give you an idea. I simply want to know what is the smartest way to combine my event case and my while loop using the timer, and how to close them correctly. I'm not really a Labview expert, so it's kinda difficult for me. If what I say sounds obscure, I'll answer all your question without any problem.

 

Thank you so much for your help, and your attention.

0 Kudos
Message 1 of 4
(3,808 Views)

LIFA is no longer supported and has been replaced by LINX https://www.labviewmakerhub.com/doku.php?id=libraries:linx:start

 

You used 7z, please post just the VI or use a standard compression program like the ZIP built in to Windows so we can open your file without having to install another program.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 4
(3,774 Views)
Solution
Accepted by topic author FrenchLizard

@FrenchLizard wrote:

if you use the Highlight Execution tool, you clearly see that my signal goes to the while loop that contains the event case, but not the other one

 


Because of LabVIEW dataflow model: Stop button value is connected from first loop to second loop. You might want to check on "How to stop multiple loops using single Button" then you can use any one implementation. http://digital.ni.com/public.nsf/allkb/267704CDE91156D186256F6D00711AAE

Thanks
uday
0 Kudos
Message 3 of 4
(3,765 Views)

In adittion to the suggestion of replacing LIFA with LINX, do some reading on the event structure and check out the nice examples about it, already shipped with LV. Basically, you don't want an event structure inside a loop that must be running without interruptions (such as a loop that controls machinery), as it will only allow execution of the while loop it resides in when either a user event occurs, or the timeout event triggers. So if I were you, I would just place user events in one while, and main control in the other; however, is there a particular reason you MUST use event structure? It is not as intuitive as the other, and might add unnecesary complications to your code.

0 Kudos
Message 4 of 4
(3,752 Views)