LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Coupling front-panel controls

Solved!
Go to solution
Highlighted

Hi,

 

I am making a control for a multichannel pump. It has the capability of controlling each channel independently, but coupling them (pos. and neg.) as well. F.e., by selecting A+ for both channel 1 and 2, by raising channel 1 I can raise channel 2 without actively touching it, etc. Now, I have a working solution as posted below, but it annoys me that I need to add an event case for each channel change, as scaling the device is annoying. Also, I'm using loads of local variables and it seems the regulars here don't like that 🙂 I'd be grateful if anybody gave me a tip towards a simpler solution.

 

Thanks for your help!

 

 

0 Kudos
Message 1 of 6
(1,014 Views)
Highlighted

Actually, it doesn't seem like you are using loads of local variables.  And it doesn't seem like you are using them wrong.  The "regulars" dislike them when they are used unnecessarily and used it ways that they shouldn't be that causes unexpected execution in the code.

 

One thing you can do is combine all 4 event cases together.  You can use the CtlRef input node in the event case to detemine which of the controls triggered the event.  With that, an array of references to all your related controls, you can iterate though your array and determine which control is your "master" control, and which of the remaining ones are linked to it.

 

One event case, slightly smarter code, and it would be more easily expandable if you added more of the controls.

 

PS:  You don't need the constants 0 1 2 and 3 for your index array on the right.  Without them, the Index Array by default will give you elements 0 through however far down you have expanded the node.

0 Kudos
Message 2 of 6
(982 Views)
Highlighted
Solution
Accepted by topic author ChristophF

If each of your cluster sliders use the same scale you can put them in an array and determine which element has changed in your event case.

 

Download All
Message 3 of 6
(964 Views)
Highlighted

Thanks to both of you, that was simpler than I thought. I have another question out of interest, I solved the problem as IanW suggested and noticed an interesting thing: If I update the cluster values using the property node, everything works as expected. However, if instead I use a local variable, the coupled channel seems to lag and the values are not the same anymore after a while - this only happens when I use the slider with the mouse, it works if I type in the value. Is there any reason for this?

Download All
0 Kudos
Message 4 of 6
(952 Views)
Highlighted

When you have an event case for a Value Changed event on a slider, you get multiple events every time you move the slider. If you wiggle it back and forth rapidly and have Lock Panel turned off, you can easily get thousnads of events queued up.  Search the Forum for slider events or something similar to see how others have handled this situation.

 

Lynn

0 Kudos
Message 5 of 6
(936 Views)
Highlighted

@johnsold wrote:

When you have an event case for a Value Changed event on a slider, you get multiple events every time you move the slider. If you wiggle it back and forth rapidly and have Lock Panel turned off, you can easily get thousnads of events queued up.  Search the Forum for slider events or something similar to see how others have handled this situation.


In newer LabVIEW version (2013) you can configure the event queue size to eliminate the problem. This is not a solution ofr the OP here, because he is using LabVIEW 2010. Time to upgrade. 😉

 

See this idea with discussions, links, and workarounds.


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 6 of 6
(929 Views)