11-24-2013 09:02 AM
Hello, I'm trying to create a switch mechanism which involves 4 or 5 buttons on the front panel and depending on which one is active, a numerical input is multiplied by a constant. So, for example I have a numerical input of 10 and I have the button labelled "x10" active, so my output is 100. If I have the "x1" button active instead, my output is the same as the input (or input multiplied by 1, if that's easier to implement). I tried using the select function, but that one by itself is only good for a single button. I must add that I'm not just new to Labview, but also very new to programming, so clear and simple answers would be much appreciated. Thanks in advance.
11-24-2013 10:37 AM
JoKer,
When learning programming, regardless of the language, you need to organize your thinking about what your program will do before you start producing code. This can be done with flow charts, descriptions in words, or whatever works for you. Then you need to learn enough about the language you will be using to know what functions, tools, and program structures are available. Besides the formal training courses there are on-line tutorials for LabVIEW which are good palces to start.
Now to specific suggestions regarding your program. Since you can only have one multiplier selection active at any one time, use one of LabVIEW's built-in exclusive mechanisms. If you want a button look, use the Radio Buttons control from the boolean palette. Its output is an unsigned integer representing the button which is pressed. When you drop the radio button control on the front panel it has 2 buttons labeled Radio Selection 1 and Radio Selection 2. You can add as many more buttons as you like (until you run out of room on the panel or exceed 4.2+ billion). You can edit the labels to read "x1" or whatever you want. You can remove or edit the Boolean text (default = OFF/ON).
Other options for the control include Rings and enumerated controls. These are not buttons but look more like menus. The text is editable. Read the help files for more information.
With any of these controls the output will be wired to the selection terminal of a case structure. With radio buttons or enums the selector label on each case conveniently and automatically changes to match the item labels on the controls. So the "x10" case will be labelled "x10" making the block diagram self-documenting. Inside the case place a numeric constant with the multiplier value. Wire it to a Multiply primitive outside the case structure - outside so that you do not duplicate code. Yes, for this situation you would have a multiply by 1 option.
Lynn