LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

do I use a FOR LOOP or WHILE LOOP for a program like this?

How do I write a progam in a way that in a certain expression 't+C', the variable t would decrease until the expression t+C will equal a certain expression .99x. Assuming .99x is a constant and C is a constant also. Also I would like to output the maximum value for the variable t (that satisfies the equation t+C=.99X) into a text box.

Thank You
0 Kudos
Message 1 of 8
(3,042 Views)
What makes the variable decrease?
 
If the starting value is known and the decrement per iteration is known, you can calculate the number of iteration needed and you can use a FOR loop.
 
Else you can use a while loop and monitor the condition to stop the loop. At this point, you can wire the final t and format it into a string as desired.
 
Since you know C and .99x, you can also solve for "t" in your last equation.
0 Kudos
Message 2 of 8
(3,041 Views)
Actually the number of iterations is not known...also I meant to say that the value t 'should' decrease until th eequation is satisfied..yes the starting value is know. The problem is I am a first time user and I odn't know how to write the while to perform such a function.
Thank you very much for your help...
0 Kudos
Message 3 of 8
(3,031 Views)

Well, you still did not define the problem.

  • Are we dealing with integers? It almost seems like it.
  • You are still not telling us how the value should decrease.
    • If it decreases randomly, there is no way to ever exactly match the desired equation. (We could for example stop once the values is less than C for the first time).
    • If it decreases regularly, e.g. "-1" at each iteration, we can exactly calculate the number of iteration needed. So the number of iterations IS known and we can use a FOR loop!

Is this homework for school? Have you tried to solve it? How far did you get? 🙂

0 Kudos
Message 4 of 8
(3,014 Views)
Simple,
You use while loop, and to the Stop condition you wire a comparsion that t+C=0.99X+-x% (use Range function) and you can also OR it with some out of control condition if the algorithm is not stable and divergence..
0 Kudos
Message 5 of 8
(2,998 Views)
Hey Altenbach..maybe I'm being a little vague
This is for my senior project and I am designing a software package that helps design/simulate the characteristics of a cpacitive pressure sensor.
If the membrane of the sensor contains a bimetal layer(polymer and metal)...well at some point the thickness 't' of the metal will affect the Young's modulus of the polymer.
So i have chosen the tolerance of the bimetal in such a way that the combined Young's modulus (of polymer and metal) is at least still 99% of the Young's modulus of the Polymer.

Now the thcikness t of the metal greatly affects the Young's moudulus of the bimetal...so if a user inputs a really high thickness t for his metal, the program will calculate the combined Young's Modulus and if it is lower than 99% of the Polymer then the program should spit out or suggest the maximum thickness t for which the combined Yung's modulus=99%of polymer.

So far.
The combined young's moudulus looks like this
Yc=(tp/tc)Yp+(tm/tc)Ym.....where tp is polymer thickness and tm is metal thickness, tc is total thickness, Ym is metal Young's modulus and Yp is polymer Young's modulus...
Now if Yc>.99Yp  and the user inputs a tm to be ridiculously high....then the program should output the maximum value of tm for which Yc=.99Yp. and also pop up an error message saying "your thcikness is too high" or summin like that. I don't know how to write for  or while loops...

I really hope this helps....thank you very much
0 Kudos
Message 6 of 8
(2,969 Views)
hello...i was just wondering if anyone got the last thread i sent...? I really need help..
0 Kudos
Message 7 of 8
(2,911 Views)

Hi maceman,

I personally would tackle this with a while loop.  If you dont know how to use them i suggest you go through the fundamentals tutorial.  Also of particular interest in solving that problem would be shift registers and case structures.  All of which should not take you too long to pick up; if you start at the fundamentals which covers most of those subjects (From what i remeber) all within a couple of hours.

Good Luck

Craig

LabVIEW 2012
0 Kudos
Message 8 of 8
(2,899 Views)