From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

labview enter any three of the four items

front.JPG

block diagram.JPG

im a undergrad.  i need help with this...i posted the block diagram and the front panel for reference...using labview I made a program where you could enter 5 specific things.  it does the calculation using that information to give the answer (X,Y).  how do i make it so i can enter any of the information and it solves for whatever variable.

0 Kudos
Message 1 of 9
(1,162 Views)

Well you probably need 3 things:

 

  • A way to tell which of the items are filled out or not
  • Some logic to determine which one did not get filled out
  • Different code execution depending on the outcome of the logic

 

First, it can be tricky figuring out which one was filled out because the default entry of "zero" is a legal value.  You might want to change them to strings (which can then be blank) and then convert those values to floating points.  The string controls will allow you to input illegal values though (letters, punctuation, etc.) so you have to be sure you're OK with that.  If you go that route you can just check for empty strings to see which one is not filled out.  There's an empty string checker on the Comparison palette and in the String palette there are string to number conversion functions.

 

For the next part, you can probably use logic that counts exactly how many are filled out.  If all but one are filled out, then you look up which one was filled out.  If not, you might want to just do nothing and wait for the correct amount to be filled out, or you could output an error message.  You'll want the output from this logic to either be an integer index (possibly an enum) or a string, because...

 

...For the final part, you want to only run one calculation.  You will want to use a single case structure for this, with different math for each option.  This is why you want the logical test output from the middle step to be an integer or a string, because you can't use a case structure with a floating point, and if you use a Boolean then you only get two cases, which isn't enough.  You'll want to have all of the terminals outside of this case structure so that no matter which case you run, you can write the output to the terminal.  Don't fall into the trap of having each case have a dozen local variables in it.

 

You also might want to consider using an Event structure to only run your code when a button is pressed instead of running it constantly nonstop like you do now.  If you do keep it like it is now in the While loop, you might want to add a small delay (10-100 milliseconds) per loop so that running the program doesn't consume 100% of one of your CPU cores.

0 Kudos
Message 2 of 9
(1,151 Views)

Create some logic that determines what code to run based on what input is blank.

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 3 of 9
(1,146 Views)

Maybe I'm a bit confused on your terminology, but in the case of leaving one input blank and entering values for the other 4 items, do your 'Ans X' and 'Ans Y' have known values in that case?

 

Because if you, say, fill out all 5 items, the calculation will run and spit out Ans X and Ans Y. But if you hold one of the 5 as a variable, then without definite values for Ans X and Ans Y, you effectively have 2 equations in 3 unknowns which is unsolvable.

 

Beyond that, I echo the "create some logic" advice offered by others.

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 4 of 9
(1,137 Views)

you are absolutely correct, its two equations.  what my program does is solve specifically for x, y.  I want to make it so it solves for any pair of the other variables.

0 Kudos
Message 5 of 9
(1,134 Views)

thanks for the input. what you said makes all the sense in the world.  on paper i know how to solve for each but i dont know how to make labview do any of what you just said.

0 Kudos
Message 6 of 9
(1,129 Views)

We're not going to do your homework for you (which is what this looks like).  

 

My previous post contains several suggestions, sometimes specifically noting which palettes they are located on.  Go to those palettes and find something that looks like what I mentioned, and experiment with it.  If it's not working like you want, try another one.  Try googling the terms I mentioned along with the word "LabVIEW" to find help files or examples showing how to use them.

 

While some of us on this forum learned by going to classes for this, I think most people learned most of what they know about LabVIEW by just trying things that look right to see if they work, then trying again if they didn't.  You need to do that instead of just hoping we'll give out a miracle solution you can use.  If you try something and it doesn't work but you can't figure out why it doesn't work, you can post to ask for help with that one specific thing again.  

0 Kudos
Message 7 of 9
(1,115 Views)

OK, as a first step we need to clarify the problem and define it exactly.

 

  • You talk about entering "three of four" items, but you actually have five controls. How do these contradictory statements line up? What's missing or extra?
  • Since these are DBL, one possible special sentinel value to be ignored could be NaN.
  • Three out of four gives you exactly four possible choices (to leave one out) where you need to implement the math. Have you worked that out?
  • Your front panel is too scrambled for me. Can you show a link to a website that shows the math you are trying to implement. (Smells a bit like 2D rotations that would be much easier to implement using complex numbers. Right?)
  • Currently you have way too many controls/indicators with the same name.
  • We all know that you are a very fast thinker, but spinning the loop millions of times per seconds recalculating the same thing over and over is probably overkill. What would you think would be a reasonable loop rate? How fast can you possibly change entries?
  • Also simplify! For example if you need the sin and cos for the same input, this is better.

 

altenbach_1-1651104385831.png

 

Message 8 of 9
(1,088 Views)

altenbach

 

yes this is homework.  im trying to make it better.  i appreciate any help that i can get.  

 

"three of four" items ...that was a typo.  what i meant to say was that i made the program so it asks for 5 specific things out of the 7 pieces of info. so in this program i solve for the x,y on the right side of the equation.  i want to make it so it asks for any of the 5 things and it solves for the missing any two pieces.

 

once the code is setup i could make labview do the math.  i dont know how to put together the code.  i guess to make it do like an if ...then  that sort of thing

 

thanks for the compliment but its what we were instructed to use.  

0 Kudos
Message 9 of 9
(1,082 Views)