04-27-2022 03:12 PM
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.
04-27-2022 03:42 PM
Well you probably need 3 things:
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.
04-27-2022 03:45 PM
Create some logic that determines what code to run based on what input is blank.
04-27-2022 04:00 PM
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.
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.
04-27-2022 04:07 PM
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.
04-27-2022 04:14 PM
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.
04-27-2022 05:25 PM
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.
04-27-2022 07:10 PM - edited 04-27-2022 07:12 PM
OK, as a first step we need to clarify the problem and define it exactly.
04-27-2022 07:48 PM
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.