LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

slider value change event

Solved!
Go to solution
I have a slide controlled by a value change event. This slide value remotely controls a motor transmitting the value by the serial port. I had a problem with this. I verified that when I click (one time) on the slide to change the value, the event occurs more than one time so, the value is send to the motor more than one time. If I change the value in the digital display of the slide, this problem doesn’t occur, the value is send only one time. It is as the mouse was bouncing. I´m using LabView 7.2. How to fix it?
0 Kudos
Message 1 of 7
(8,372 Views)

Hi,

 

When you click on slider and you start dragging it, for every increment on the changed value, LV generates an event.

 

So to fix it you can use the event mouse up for exemple. It will generate an event when you release the mouse. But il will not work with the digital display....

 

Hope it will help, 

 

 

Marc

Message 2 of 7
(8,366 Views)

Sliders and cursors are famous for generating large numbers of events.  You can reduce this to a reasonable number in a couple of ways.

  1. In the event case, compare the new value with a value you read from a local to the same control.  If they are the same, process the event.  If not, do not process the event.  To make this work reliably, you will also need to process the mouse leave event so you always get a last event (thanks to altenbach for this tip).
  2. In your case, you may be better off with a timer based approach, since you processing is probably quite fast.  Run a cluster through your event loop which contains a timeout time, the last time an event was processed, and a needs processing boolean.  In the data changed event case, process the data if the time since the last event is over the timeout time, then set the needs processing boolean to FALSE and update the last processed time.  If it is not, set the needs processing boolean to TRUE.  Create a timeout case in your event structure to check periodically if the data needs to be processed.  This works well, but is a lot more work than the previous method.
Message 3 of 7
(8,314 Views)

Hi there

 

2b: Set the timeout of your event structure to a value suitable for you (e.g. 100ms). Inside the TimOut - Event pass the current control value to a shift register and compare the current value with the last one written to the shift register. If they differ write to the HW, if they are the same do nothing. Remember not to define the Value changed event of the control in your event structure.

Best regards
chris

CL(A)Dly bending G-Force with LabVIEW

famous last words: "oh my god, it is full of stars!"
0 Kudos
Message 4 of 7
(8,304 Views)

LabVIEW 7.2 does not really exists.


Identcor wrote:
I verified that when I click (one time) on the slide to change the value, the event occurs more than one time so, the value is send to the motor more than one time.

 

I don't think this analysis is correct. Every time the event triggers, the value will be slightly different. 

 

You potentially have several problems to address:

 

  • dealing with a potentially slow transmission of commands to the device. (If you could send a command every nanosecond, we would not have a problem 🐵
  • preventing event accumulation
  • preventing too many value changes
  • ensuring that the last value "sticks" no matter how many events you throw away.
  • Allowing a satisfactory user experience (near immediate response to interactive control changes).

 

 All this can be done with code to filter out unneeded events. First, you need to make sure the event is set to NOT lock the front panel until it completes. This ensures that the user can always operate the control, even if the event is still executing. Nothing is more frustrating to the user than an interactive control that becomes unresponsive for short intervals. To see if an event is stale, easiest would be to compare the actual terminal with the "new value" event terminal. Just spin an empty case if this happens, draning the stale event. See also this old demo that shows some of the ideas.

 

A typical user will not "click" on the slide, but will drag the slider to the new locations, possibly interactively watching some other indicator for feedback. Same as you would ajdust the sound volume for example. You keep sliding up/down until you're satisfied with the volume and the only interesting value is the last setting. It would be very unintuitive if the volume would only change after you release the control.

 

 

0 Kudos
Message 5 of 7
(8,283 Views)

Thanks very much everyone. I am trying to implement the ideas you gave me.

And A : You're rigth I'm using LabView 7.2 and, the values are equal due to the slider property: data range, out of range Increment, Coerce to nearest.

Thanks again for your help. 

0 Kudos
Message 6 of 7
(8,258 Views)
Solution
Accepted by Identcor
Sorry I was wrong again: I'm using LabView 7.1.
0 Kudos
Message 7 of 7
(8,256 Views)