LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event Structure Affecting External Logic?

Solved!
Go to solution

Hi,

    I am currently a student working with LabVIEW for the first time this semester.  I am working on a program where we must require a password to arm a home security system.  Right or wrong I was attempting to do this with an event structure.  In the attached program I am triggering an event structure off of the Boolean arm/disarm button.  My intent is that when the button is on and the password that the user is prompted for is correct, the system is armed.  When the button is off and the password is correct, the system is disarmed.  If the password is incorrect, neither is true.  To test this out I have created the very basic program attached.  

 

The problem that is driving me crazy is the logic outside of my event structure.  When the password is true and the button is on (T/T) my first AND logic operator (top) is reporting F...  The exact opposite of what I would expect.  The same is true for my bottom logic operator when the button is off and the password is true. 

 

Am I missing something here?  Is the event somehow affecting the logic operators outside of the event structure?   

 

caklinedinst_0-1669922868459.png

 

 

0 Kudos
Message 1 of 5
(376 Views)

Hi cakline,

 


@caklinedinst wrote:

Am I missing something here? 


Yes: DATAFLOW (and race conditions)...

 

When is the button read and when is the event happening?

Did you try to debug your VI using probes and highlighting?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO
0 Kudos
Message 2 of 5
(340 Views)
Solution
Accepted by topic author caklinedinst

Try running your code with Highlight Execution enabled (or use single-stepping) and you should see that the AND gates are evaluating before the value of Arm/Disarm is updating to reflect the logic change.  The program is waiting in the Event Structure until an event occurs, and you'll notice that the value of Arm/Disarm does not end up updated when you might be expecting. 

 

The gates will evaluate because both of their inputs are are fulfilled once the Event Structure finishes, then after setting the indicators, you're getting stuck back in the Event Structure.  (Waiting for the event is also why the Stop button doesn't work as is).

 

Try to think of a way to guarantee that the gates see the updated status of Arm/Disarm at the same time as the password.  Also, try to think of a different approach for the Stop button.

 

I've attached the modifications I'd make to your approach to achieve the correct functionality (to my understanding of the problem).

 

Message 3 of 5
(333 Views)

Thanks for the detailed response.  I understand the issue now and have a more thorough understanding of the event structure itself.  Greatly appreciated.  

0 Kudos
Message 4 of 5
(261 Views)

Thanks for the detailed response.  I understand the issue now and have a more thorough understanding of the event structure itself.  Greatly appreciated.  

0 Kudos
Message 5 of 5
(259 Views)