LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Shared Variables and Event Structure

Solved!
Go to solution

Hello, I'm new to Labview and I'm having some problems understanding how to use the Event Structure. Let's say I have a VI with a while loop updating at each iteration a variable X (which is shared because I will have to send it to another VI). I inserted an Event structure because I would like that when the user changes the value of the boolean 'Reset' in the front panel, then the variable X is set to zero and the while loop starts updating X from zero again, but this is not working, what am I doing wrong? I attach a snippet of the VI.

Thanks for any advice and/or correction of the code

0 Kudos
Message 1 of 3
(1,744 Views)
Solution
Accepted by topic author Alefbb

Hi Alef,

 


@Alefbb wrote:
I would like that when the user changes the value of the boolean 'Reset' in the front panel, then the variable X is set to zero and the while loop starts updating X from zero again, but this is not working, what am I doing wrong?

You are doing a lot of thing wrong:

  • there should be a timeout event case and no additional wait in the loop
  • when you want to write to the shared variable then that variable belongs into the loop
  • just overwriting that shared variable does NOT change the value in the shift register!
  • the wire holding your "X" value should be wired through the event structure: no need to write to the shared variable inside the event case when you can change the wire directly…
  • you might also add an event to handle the stop button…
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 3
(1,741 Views)

Thanks a lot, I managed to make the code work as expected!

0 Kudos
Message 3 of 3
(1,716 Views)