LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

combo box, ring and event to modify them runtime

Hi,
I attached a picture of the block diagram. Using LV 8.2.1, win XP.
 
What I want : User should select from Main Selection, and that brings up new values for strings in the other menus (tried both combo box and menu ring items).
 
Teh problem : This block doesn't do that. Why? Looking with probe, I see the event captured and data are ok until the property node. They are not writed and on the front panel I see no difference.
 
Thanx
Download All
0 Kudos
Message 1 of 8
(2,785 Views)
Please see modified example and its comments ! Feel free to post back if you have any questions...
0 Kudos
Message 2 of 8
(2,772 Views)
Just a slightly modified example that shows a different way to initialize the ring and the combo box by generating a Value Change event. See the context help of the Val(Sgnl) property for more details.
Message 3 of 8
(2,768 Views)

Thank you very much! now I understand better the situation

I thought that the code inside the while loop but outside the event structure wasn't care.

So if I want to do something continuosly (for example continuosly comparing two integer values to have a real-time boolean led indicator on front panel), do I put the code in the middle? This is a bit confusing thinking about the "timeout event"....
Use the timeout event or put in the middle (=outside event structure but inside while loop.... at which CPU rate is executed?? too fast?) ??

thanks

0 Kudos
Message 4 of 8
(2,744 Views)


@Slyfer wrote:

I thought that the code inside the while loop but outside the event structure wasn't care.

So if I want to do something continuosly (for example continuosly comparing two integer values to have a real-time boolean led indicator on front panel), do I put the code in the middle? This is a bit confusing thinking about the "timeout event"....
Use the timeout event or put in the middle (=outside event structure but inside while loop.... at which CPU rate is executed?? too fast?) ??


Just a suggestion. The timeout event for the Event Structure [ES] is equivalent to that of providing a small delay inside the while loop.

But it is not mandatory. If you dont wire some value to the timeout terminal, but still want to something, like comparison, you can very well put that code outside the ES but inside the while loop. It ll execute.

Else you can wire a value like 50 or 100 to the timeout terminal [ this gives enough time for the execution of the various codes inside the various events configured for the ES], so that the ES times out for every 50 or 100 ms when none of the other events occurs. If you put your comparison code here, it ll be doing the comparison all the time or whenever the ES waits and crosses the specified ms after an event has happened.

I hope this gives you a clear idea about eventstructures.

See the below links for more details on Event Structures.

http://zone.ni.com/devzone/cda/tut/p/id/3331

http://zone.ni.com:80/reference/en-XX/help/371361B-01/lvconcepts/using_events_in_labview/

http://zone.ni.com/reference/en-XX/help/371361B-01/lvhowto/caveatsrecmndtnsevnts/

- Partha ( CLD until Oct 2024 🙂 )
Message 5 of 8
(2,735 Views)
The code inside the event structure will be executed only for a given event. In opposite, the code outside the event structure will be executed for every iteration of the while loop --> for any event.

If you want to do something periodically, the best way is in fact to add an Application>>Timeout event and to put the code inside it. The delay that is set by the hourglass input of the event structure will only be used in case of a timeout.

By putting a wait outside the event structure, the specified delay will be used for any events and not only in case of a timeout. With a short delay, you may not see a difference but with a long delay (e.g. 500ms), the program will react only slowly to the events (e.g. user actions).
Message 6 of 8
(2,728 Views)
Great, it works fine with the timeout evet (100ms attached to the hourglass) 🙂
 
Another little "misunderstanding" is this:
How do you use to close panel with events?
I attached a file that shows an exit button which is polled outside the event case, and when pressed, the window will close.
This works, but I think there are more "consistent" solutions.
Generally I like to let the user have the "X" button to close/exit the program, because it's very intuitive.
But sometimes there is also a specific "exit" or "stop" button.
 
When I exit, I want to use that vi_close routine, so that the vi is really closed AND unloaded from memory
0 Kudos
Message 7 of 8
(2,704 Views)

Hi Slyfer,

About closing a vi, my personal idea is that there are some different "philosophies" or "strategies" some of which belong to personal attitude.

About the way you used in your vi and showed into the  "the_way_I_use_with_a_button.jpg" I think it is ok but, I would suggest you to make a little change: try creating a specific "stop event" into the Event Structure instead of doing the polling into the While Loop as you do. I attached a screenshot that should be helpful about that.

However your solution is right, so the change I've suggested is only the approach I would use if I was in your situation.

Have a nice day!

carlo>

0 Kudos
Message 8 of 8
(2,682 Views)