From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, 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: 

Event structure - new value or placing control inside the structure?

Hello everyone,

 

I have a question which I cannot figure out why is the case.

 

Function of the program: I am using a slide as a control in Labview, to control servo motors on Arduino. So write serial is sending the values from the slide from labview to arduino. 

 

1st attempt: The code is inside an event structure, which will run when the values of the slide are changing. 

First I had the slide in the event structure (as can be seen the picture, event structure slide control) but then it seemed like the slide freezed after sliding it the first time. Doesn't work!

 

2nd attempt: When I moved the slide outside the event structure and instead wired the new value to the serial write(can be seen in picture, event structure new value), then it worked perfectly. Works!

 

Q: But I cannot figure out why the first case doesn't work, and I am very curious about it. Does anyone know why my first attempt didn't work? For me the first and second one should have the same function. 

 

Grateful for some answers/speculations!

Download All
0 Kudos
Message 1 of 4
(3,371 Views)

If you attached your VI, we could play with it and help you figure it at.  You might have settings for that event case that we can't see because it is just a picture.

 

A couple of possibile things come into play here.

1.  Slide controls can queue up multiple value change events.

2.  The state of whether the event case locks the front panel or not.

3.  With newer versions of LabVIEW, you can set a limit on how many events get queued up.

Message 2 of 4
(3,357 Views)

Hi,

 

having a wait function in the event case doesn't help either…

 

You might also think about using a producer-consumer pattern for your VI: this would allow for very fast UI event handling and you could use a notifier to hold the current state of your slider…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 3 of 4
(3,348 Views)

Both cases are not ideal, but we cannot tell because you did not attach actual VIs. Pictures don't show the whole story.

 

Everything else being equal, the two codes you show should act the same. Was the instrument connected in both cases?

 

For slides, you need to limit the event queue to 1 item if there is any code that takes time, such as your communication. (see also this idea that is now implemented).

You should also configure it to not lock the front panel until the event completes.

(again, we cannot tell what your settings are from a picture!)

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