LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Prolem with While Loop

Solved!
Go to solution

Hey

 

I am a newbie to LabVIEW, I had an assignment and worked very diligently for it. I have achieved what it required but I am not happy with the result. the problem is my while loop is only taking in one input from the thermistor and once a value is being run, I want it to change it to 2nd input from thermistor. I can do it right now by stopping the code and then changing the input but I want it to do it programmatically. I have attached the vi file for your kind consideration.

 

Regards

0 Kudos
Message 1 of 15
(2,187 Views)

Hi Wasiq,

 


@WasiqSaleem1122 wrote:

I have attached the vi file for your kind consideration.


No, you did not attach the VI…

 


@WasiqSaleem1122 wrote:

the problem is my while loop is only taking in one input from the thermistor and once a value is being run, I want it to change it to 2nd input from thermistor. I can do it right now by stopping the code and then changing the input but I want it to do it programmatically.


Sounds like you missed to THINK DATAFLOW!

Place the thermistor reading inside your loop to have it "take the next input" in each iteration…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 15
(2,186 Views)

okay i ll try that

Here's the VI file, i missed it first time.

0 Kudos
Message 3 of 15
(2,176 Views)

Attached is your file converted to LabVIEW 2018 (so more people can look at it).

 

I'm old and crotchety and I disdain people who don't even try.  I would give you an F on your wiring layout because you didn't even try to do it well.

Other than that, your code doesn't make much sense.  It seems like you want to poll a thermistor input and get a waveform, but you've got no polling loop.

You've got 2 other loops accomplish nothing other than spinning at max speed, gobbling up CPU usage.

Note that the output of a tunnel that feeds into a loop will yield the same value on every iteration.

 

You need an outer polling loop (and no other loops).  Use the "Wait Until Next ms Multiple" function to set the polling rate.

It seems like you want data collection to continue until both an upper and lower limit have been hit (really?).

If so, I would use shift registers or feedback nodes to hold booleans that indicate that a limit has been hi.

0 Kudos
Message 4 of 15
(2,151 Views)

It seems you are using continuous run, because there is no toplevel loop, so you only read the thermistor value once per run (Yes, "continuous run" is a debugging tool, not a way to run a VI!) and the code cannot complete until both while loops have completed, which is either never or immediately unless you touch the limit controls. Dataflow!!!!

 

As has been said, all you need is a toplevel loop paced at a reasonable rate continuously reading the thermistor and doing the range checks. Properly done, the code would fit on a quarter postcard.

 

I recommend to go back to the basic tutorials. Also never maximize the front panel and diagram. That's super annoying because you cannot look at the help while editing!

 

Your waveform scale properties belong after the case structure. No need to duplicate it in every case!

 

See if you can create the following (You can guess what's in the TRUE case, of course):

 

altenbach_0-1702489591730.png

 

 

 

Also make sure that all inputs have reasonable default values before saving. A range min&max of zero is not reasonable! If the four min/max never change, use diagram constants.

 

Also mind your labels. For example "C or F" is a bad label for a boolean control, because we cannot immediately tell what TRUE means. A label of "C?" would be much more intuitive!

 

0 Kudos
Message 5 of 15
(2,133 Views)

@altenbach wrote:

It seems you are using continuous run, because there is no toplevel loop, so you only read the thermistor value once per run (Yes, "continuous run" is a debugging tool, not a way to run a VI!) and the code cannot complete until both while loops have completed, which is either never or immediately unless you touch the limit controls. Dataflow!!!!

 

As has been said, all you need is a toplevel loop paced at a reasonable rate continuously reading the thermistor and doing the range checks. Properly done, the code would fit on a quarter postcard.

 

I recommend to go back to the basic tutorials. Also never maximize the front panel and diagram. That's super annoying because you cannot look at the help while editing!

 

Your waveform scale properties belong after the case structure. No need to duplicate it in every case!

 

See if you can create the following (You can guess what's in the TRUE case, of course):

 

altenbach_0-1702489591730.png

 

 

 

Also make sure that all inputs have reasonable default values before saving. A range min&max of zero is not reasonable! If the four min/max never change, use diagram constants.

 

Also mind your labels. For example "C or F" is a bad label for a boolean control, because we cannot immediately tell what TRUE means. A label of "C?" would be much more intuitive!

 


Oh No, .. Ahem, Christian, you really meant for the boolean control to be before the loop right?  It would be extremely confusing to have the chart history containing temperature elements with mixed scales (f and C scaled scalar values in the same Chart History array)

 

Of course, simply migrating the boolean without migrating the M and B scale compontnts and the Chart min max would get that example sent to the Rube-Goldburg thread 😄


"Should be" isn't "Is" -Jay
0 Kudos
Message 6 of 15
(2,095 Views)

We can always clear the chart when the boolean changes. We could also always chart C, then just change the offset/multiplier for the Y axis to adapt the scale for all points, old and new, to show in the new units, right?

0 Kudos
Message 7 of 15
(2,084 Views)

@altenbach wrote:

We can always clear the chart when the boolean changes. We could also always chart C, then just change the offset/multiplier for the Y axis to adapt the scale for all points, old and new, to show in the new units, right?


Exactly,  or scale the chart history array on boolean value change. Lots of options.   I was just wondering if you were having a bad day.  2 mistakes in only 50k posts seams slightly below your standards.

 


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 15
(2,075 Views)

I don't make mistakes (famous last words 😄 ) , but sometimes I don't provide a turnkey commercial grade solution to a simple "while loop" (sic) problem, which I solved. It is up to the user to sand the edges and polish things up as needed. I intentionally did not even attach a VI.

 

Messing with the chart history seems like pure Rube Goldberg compared to just change the Y scaling. 😄

 

Message 9 of 15
(2,049 Views)

I'm the kind of guy who likes to do stuff like this:

paul_a_cardinale_0-1702512238879.png

 

paul_a_cardinale_1-1702512249724.png

 

paul_a_cardinale_2-1702512260816.png

 

Message 10 of 15
(2,037 Views)