05-22-2025 08:49 AM
I am writing a program that uses a DQMH module to control motors, and there are 4 motors with identical controllers, each with a clone of the same module. There's a front panel in an overarching program with a cluster for each motor [see screenshot].
In the app's event loop, there's a data cluster that stores the DQMH module IDs. The only way I can really think of to handle all of these controls is to add to the event structure an individual case for each button, "Source 1 motor.Forward", "Source 1 motor.Reverse", Source 1 motor.Stop", etc x 4. That's 12 nearly identical cases being added to the event handler. Can anyone think of a cleaner way to do this? I want the clusters to all be individually visible. Otherwise, I would only have one of these control clusters and a selector for which motor.
Labview 2025, latest DQMH
05-22-2025 09:04 AM
You can make the control a 2D (2x2) array of clusters, have a value change event for it, then see which one changed (by comparing new and old value from the event data node).
(It is difficult to give specific advice without seeing the code details)
05-22-2025 10:08 AM
@Nokaroa wrote:
I am writing a program that uses a DQMH module to control motors, and there are 4 motors with identical controllers, each with a clone of the same module. There's a front panel in an overarching program with a cluster for each motor [see screenshot].
![]()
In the app's event loop, there's a data cluster that stores the DQMH module IDs. The only way I can really think of to handle all of these controls is to add to the event structure an individual case for each button, "Source 1 motor.Forward", "Source 1 motor.Reverse", Source 1 motor.Stop", etc x 4. That's 12 nearly identical cases being added to the event handler. Can anyone think of a cleaner way to do this? I want the clusters to all be individually visible. Otherwise, I would only have one of these control clusters and a selector for which motor.
Labview 2025, latest DQMH
Use the name of the button as a tag, like "STOP:: source 1 motor" then make a vi that extracts the name of the motor and the function from the button name. Place all the fp controls into a cluster, make one user event case for the cluster value change. Place the name/function extraction vi in the event case that then calls the appropriate code depending on the name and function of the button that was pressed. Now you have a single event case that handles any button push.
05-22-2025 10:29 AM
Huh, interesting. I wouldn't think of parsing the string tag. I think I'll try this
05-22-2025 11:04 AM - edited 05-22-2025 11:06 AM
Here's a quick example how to use a 2D array of clusters and find which one has changed. (To be used for further decisions! You can easily reduce the 2D indices to a single index if needed)
05-22-2025 01:35 PM
@Jay14159265 wrote:
Use the name of the button as a tag, like "STOP:: source 1 motor" then make a vi that extracts the name of the motor and the function from the button name. Place all the fp controls into a cluster, make one user event case for the cluster value change. Place the name/function extraction vi in the event case that then calls the appropriate code depending on the name and function of the button that was pressed.
Since the controls are identical, you don't need to have all the controls in a cluster. Have the same event case handle the Value Change for all those motor controls. Then use the property reference Control Label to determine which control was pressed.