LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a simple control value comparison a user event?

Hey everyone,
 
I am trying (with no luck) to figure out how to make an event out of a simple control comparison without having to put the controls inside a while loop to be polled or in the event structure.
 
For example; how do I make an event when 'numerical control 1' equals 'numerical control 2'?
 
I know that I could have these inside a while loop with the event structure and then wire the comparison to a boolean, then reference the boolean's value change event.  But rather, I would like to create an event for the comparison without the boolean and outside the while loop such that the loop doesn't have to run through the comparison each time, and doesn't have to poll the controls and bool.
 
Thanks for the helpSmiley Very Happy
0 Kudos
Message 1 of 10
(3,307 Views)

You can create a user event which takes a cluster of 2 value events.  Register this event and fire it when ever needed.  Inside of the event handle put your equality test.  I have done something like this in the past, and user events are very useful.  Conversly you can handle both control value changes events and compare the values inside here, there is no poling and this can be dynamically unregistered if needed.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 2 of 10
(3,295 Views)

Hey falk,

I couldn't quite understand where to go with your suggestion.  Here is a pic of what I got, it isn't far.  I can't figure out how, after I cluster two sliders together, to specify that the event fires when slider 1 equals slider 2.

 

 

0 Kudos
Message 3 of 10
(3,254 Views)

Better yet, this is what I came up with... but is there any way to get away from the case statement and make the comparison (equal) an actual event?

Isn't there any way to create an event of a comparison?

 

Thanks

0 Kudos
Message 4 of 10
(3,245 Views)

Attached is a simple user event structure that I was thinking about.  Using this you can decouple the control from the comparison, it just works on valye comparisons.  Since it uses the event structure there is no polling and is very CPU friendly.  I have allowedfor the comparison to be linked to the "Value 1:value change event" and the compare button true event.  I hope this is what you were looking at.  Also since it is a user event which is dynamically registered you can register/unregister it at will durring execution making it a flexable event handler.  It might be alittle buggy because I have spent about 3 minutes developing it (particularry when passing values into the event structure there might be a state issue from the data flow so local variables are a better choice)

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 5 of 10
(3,241 Views)

Thanks for the reply falk,

Your method, though, isn't it just the same as the one I attached where the slider values are retrieved inside the event structure and compared there?  Or is there something fundamental I'm missing...

 

Thanks again,

Jonathan

0 Kudos
Message 6 of 10
(3,233 Views)

It might be I am working here with 7.0 so I cant open the code to check.  What I did is common in windows event handeling where you make a common method which is chainde from multiple different sources.  Like the OnPaint is a common place to call a render event function and can also be envoked from other places like a 30Hz timmer event.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 7 of 10
(3,228 Views)
Actually there is no compelling need to create a user event. A simpler method is to define a single event case handling both Control1 and Control2 Value Change and do the comparison into this case. No polling, no user events, no added controls.
Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 8 of 10
(3,226 Views)

So... you brought up something which I didn't think about that I know I will have to use.  The '30Hz timmer event' comment.

How do I make such a regularly timmed event? 

I will be using two CCD Cameras in my programming and it would be nice to setup such an event so that I can perform a frame grab at set intervals.

Thanks

Jonathan

I just tried making ref's to a timer but that didn't work

0 Kudos
Message 9 of 10
(3,220 Views)

To fire the event at 30 hz, you can create a separate loop which runs at 30Hz (wait /time elapsed function) then fire the user event to handle the capture, just have a timed toop and no events.  I disagree with the statement that there is no compelling reason to have a user event.  While just lumping value1 change and value 2 change together you have much less control over when this event fires.  By decoupling this comparison form the control you can fire it when more complex logic events happen.  I do agree that the simplist answer is to just lump both events together and call it one time, but thsi was not the original question as I interpreted it.

 

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
Message 10 of 10
(3,208 Views)