LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading boolean indicator in separate loop to stop and prevent tasks running

Solved!
Go to solution

I'm writing some code to monitor and control some lab equipment, and part of that is requiring the software to automatically register if something is wrong and act accordingly. The code will be continuously reading the status of the equipment via a DAQ card, with an overarching "Boolean Out" boolean will indicate whether the system is running as intended. So, I've written this as two separate loops, one to monitor the device status and another to control the equipment (with a state machine).

 

In terms of communicating between these two loops, I need to ensure that:

  • a task cannot start running if the "Boolean Out" boolean is false
  • a task will abort if the "Boolean Out" boolean changes to false while it is running

At the moment, I have got this working as intended with local variables in the "Task" case in the Timeout event, and the ""Task": Value Change" event to cover these two cases (see attached code). However, I'm not sure this is the best implementation as I don't want to overuse local variables. There would be a similar implementation in several different tasks, so it would be reading that "Boolean Out" boolean frequently.

Another method I've seen is using a single-element queue, but I don't know whether that would be overkill because you only need the current value of "Boolean Out".

Sorry, I suppose there isn't really a particular question here. I'm just wondering whether this is a suitable solution, if there's anything problematic about it, or an easy alternative which would work better?

0 Kudos
Message 1 of 6
(2,172 Views)

Hello,

As I can see You tried to make it work in FPGA target, and used structures that not even exist in the pallet, I guess You copied it from somewhere. It is really interesting , how You make it work, it shouldn't even compile. Try to use correct tools for FPGA.  And try to formulate Your question, You want a proper error handler?   

Regards.

 

0 Kudos
Message 2 of 6
(2,118 Views)

Hi IDASYAN,
I'm afraid I'm not aware of what FPGA target is and if I've used some functionality of it, it was completely unintentional. I'm trying to figure out whether it's okay to read "Boolean Out" with a local variable in the second loop, or whether there's a better and/or safer way to stop and prevent a task from running.

0 Kudos
Message 3 of 6
(2,106 Views)

Hi, 

Okay if so, could You please explain what exactly You want to do , and what is the hard You are using. 

FPGA target tools can't be used accidentally, You need to open a special project for it, with special hard. They are really complex circuits, working on high speeds. Be sure You need it, there are special rules for them in LabVIEW programming. 

It is okay to use that local variable, but I'm afraid Your application won't work at all. 

If You would share the information I asked , we will be able to figure out the best option for You.

Regards.

     

0 Kudos
Message 4 of 6
(2,100 Views)

I don't understand what I was unclear about in my first post. What I shared wasn't the full application, but a mock-up to demonstrate the functionality I was aiming for.
My application is working fine at the moment. I've tested it with the hardware (USB-6363 - NI) and there have been no problems interfacing with it. Where is the indication that I've been using FPGA target tools? I have no idea what they are and, if I understand you correctly, I couldn't have used them unintentionally. Everything I have used in the code I shared was from the basic functionality of LabVIEW 2018.

0 Kudos
Message 5 of 6
(2,095 Views)
Solution
Accepted by topic author ReklawLeinad

Okay, if everything is that simple, than the answer is Yes , it would work with local variables , but I'll recommend You use channel handlers for transfer data between loops , here is link , if You need more examples  You will find them in LabVIEW help window.

Regards  .

Message 6 of 6
(2,091 Views)