LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Bi-directional drop down menu

I am new to LabVIEW and I was given the code to control a 16X16 mux for one of our devices.  The customer wants us to read back the settings that is present on our device. I was wondering if I can just turn our drop-down menu from a controller to an indicator. In other words, make it bi-directional?

 

Jim Crocker

0 Kudos
Message 1 of 12
(3,580 Views)

I don't have LabVIEW here to look at your VI, but you cannot change a control to an indicator or vice-versa. However, you may be able to accomplish the same using Property nodes. For example when you want it to be an indicator, disable it via property nodes and update its value via a local variable. When it needs to be a control, enable it again.

 

mcduff

0 Kudos
Message 2 of 12
(3,559 Views)

I assume that you are talking about the "channel x" rings. To create an indicator, you could just ctrl-drag one out of the cluster to the front panel and "right-click...change to indicator". Of course that assumes that the values match the response from the instrument, else you would need to create a lookup table to translate.

 

Even with your code structure, terminals probably belong inside the loop. In fact, you probably could replace most of your front panel with a 2D array of clusters (add a string element for the labeling and "disable" the ones used as indicators. Keep the entire structure in a shift register and update the entire thing via a local variable if one of the indicators changes. You could even write back the actual ring value if the instrument response differs from the setting. You need some code to see which element got the mouse-down, but it's not hard (see e.g. my 4x4 tic-tac-toe code). The code would probably shrink to the size of a postcard with little performance impact!

0 Kudos
Message 3 of 12
(3,508 Views)

If you use a little more imagination, you can do a lot more with this design.  First, ask yourself what a 4x4 Multiplexer looks like, or, alternatively, what your Front Panel looks like -- it's a 4x4 Array of "Things" (let's call them "Clusters", consisting of an Input Control (a Ring), an ACK Control, and a NAK Control).  Let's build such a Cluster, just for fun.  We are also going to "do the right thing" and create a TypeDef for the Cluster so we can refer to it by name if we ever need to do so.

 

Start with the Ring.  I modified your Ring Constant -- you assigned the Ring Elements, named Channel 1 .. Channel 16 and Invalid Channel, and gave them values of 48..57, 65..72, and 90 (Ascii for 0..9, A..F, and Z) -- I changed the values to 1..16 and 100.  I also make the ACK and NAK controls disabled (so if you click them by mistake, nothing happens).  Here is my Cluster, TypeDef'ed as Output Channel, with the internal Ring Control also TypeDef'ed as Input Channel.

Multiplexer Controls.png

My Output Cluster is on the left, next to one of your 16 "combinations of controls".

 

So what?  Let's define a Control, "Multiplexer", as a 2D Array of Output Channel.  I'll show you what this looks like after we examine some code to initialize this.  Look at this little VI --

Build Multiplexer.png'

We want to create 16 Multiplexer "Output Controls", so we use a For loop.  Each Control is a Cluster, so we use Bundle by Name (using the saved TypeDef, to which I gave an Icon, as shown, to remind me that this is an Output Channel with a TypeDef).  The first Input Channel takes the value of the TypeDef'ed Input Channel (shown as "Channel 1" feeding into the For Loop -- the little triangle in the upper left hand corner means that this comes from a TypeDef).  I feed it into a Shift Register, and increment it after using it.  When I used your values of 48-57 and then a gap, I could see "Channel 1" through "Channel 10", but then gibberish (because it was incrementing the values, and there was nothing assigned to the value "58", which is why I changed the Values to 1-16).  I also, just for fun, set every fourth ACK to ON, and the first four NAKs to On.

 

So I now have an array of 16 Controls.  I reformat it into a 4x4 Array and run the program, which gives me this Front Panel:

Multiplexer.pngAs you can see, the Input Channels are set to 1..16, the first Column has ACK set, and the first Row has NAK set.  The Output Channels, here, are not named, but it would be easy to modify the Output Channel Cluster to include a Name (similar to your "Output Channel 1" label) -- just add a Name String Control to the Output Channel Cluster, set it as Disabled, and initialize it as "Output Channel N" in the For Loop.  [I recommend using Format Into String, incrementing the index "i" to give you 1, 2, ... and using a Format String of "Output Channel %d".  You may want to set the String Property in the Cluster to Bold.]

 

So now you have a really elegant Front Panel, and can work with a single Multiplexer Control (instead of 16 Input Channels, 16 NAKs, and 16 ACKs).  There is a little more work to be done to figure out which Control was changed, but do a little experimentation and I think you'll figure it out.

 

I'm attaching DEMO Build Multiplexer, the above code, and the two TypeDefs.  They are written in LabVIEW 2018, which I think is what you are using.  I hope that the explanations and pictures posted here will be clear enough that users with older versions of LabVIEW will be able to recreate this demo without difficulty.

 

Bob Schor

Message 4 of 12
(3,506 Views)

Wow thank you for all your help. This will take me a few days to understand and implement it. I have a limit to the output of the software. The part that it communicates with is already gone and we won’t be changing its software. But a simple case statement before it’s sent will be good enough to change it to the proper ascii #.

 

I like how McDUff said it can’t be done… Here is how you do it. You all are genius.

 

The project has been given to my collogue. I have sent him this page and I will tell you how it turns out.

Jim

0 Kudos
Message 5 of 12
(3,469 Views)

I like how McDUff said it can’t be done… Here is how you do it. (Where?)

 

Easy there. Smiley Wink

 

I said you cannot change an indicator into a control while the program is running. Bob S did what I suggested, he used property nodes to change values, you can also use property nodes to disable controls, so they are visible, you update with values via property nodes, local variables, but when you click on it nothing happens, like an indicator.

 

mcduff

0 Kudos
Message 6 of 12
(3,465 Views)

@mcduff wrote:

I like how McDUff said it can’t be done… Here is how you do it. (Where?)

 

Easy there. Smiley Wink

 

I said you cannot change an indicator into a control while the program is running. Bob S did what I suggested, he used property nodes to change values, you can also use property nodes to disable controls, so they are visible, you update with values via property nodes, local variables, but when you click on it nothing happens, like an indicator.

 

mcduff


Be careful with disabling a control and NOT graying it out. See here.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 7 of 12
(3,456 Views)

@Ben wrote:

@mcduffNOT graying it out. See here.

 Ben


That link comes up with an unexpected error.

0 Kudos
Message 8 of 12
(3,444 Views)

@RavensFan wrote:

@Ben wrote:

@mcduffNOT graying it out. See here.

 Ben


That link comes up with an unexpected error.


Yes, for me as well.  I'm disappointed because I always enjoy learning from a fellow P'burgher (though it's been a few years since I lived there) ...

 

Bob Schor

0 Kudos
Message 9 of 12
(3,436 Views)

@Ben wrote:
Be careful with disabling a control and NOT graying it out. See here.

As others have already said, that link is a no-go (points to some nonexistent VI with a path pointing to this thread).

 

A disabled control (functionally an "indicator") is very different to a grayed out control (functionally something that is not relevant for the current state, but might be operable under other circumstances).

 

A cluster (and thus all it's elements) share one mode (control or indicator), so if some elements need to be operable as controls, the cluster needs to be a control. If other elements are used as "indicators", they need to be disabled, but not grayed out. See also my very old example here.

0 Kudos
Message 10 of 12
(3,429 Views)