LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Toggling in while loop

Hey !

I want to fit the scale of a graph thru button and undo the fit(when button pressed again logic 0 is latched) so that i can adjust it manually.

But  in while loop i cant latch the button's logic ...Any idea how to do this...

Regards,

DeWalker

0 Kudos
Message 1 of 11
(3,803 Views)

Hi DeWalker,

to use the latch logic, you should use a shift register. Store the boolean value in it. Use the invert function inside the case structure to change the value and use the result to change the scale.

 

Mike

Message 2 of 11
(3,789 Views)

Your button probably has the wrong mechanical action. (right-click...mechanical action). Try "switch when pressed". Why do you want to use latch action if the result is better served with a switch action?

 

You should also familiarize yourself with some basic programming practices. You should only call the property node whenever the property should actually change. Currently you are writing to the property node millions of times/second with the same old value, consuming 100% of the CPU.. I would recommend an event structure tied to a value change of the button.

Message Edited by altenbach on 01-11-2009 11:15 PM
Message 3 of 11
(3,788 Views)

Hi!

Thanks for the replies.....

Actually i did try the event handler .....But the problem i face is that the property of FITscale is applied only when the button is pressed and then it reverts back.......... I want to design a mechanism in which i can use a button to control the scale just as we do it by Rght clckng. on chart and selecting -deselecting AUTOscale.....

 Help  me out in this regard...........

 DeWalker

0 Kudos
Message 4 of 11
(3,760 Views)

have you tried a value of 2 for the "scalefit" property?

 

What is the mechanical action of the button? Why don't you attach some code instead of an image to make things easier? We cannot really debug an image. 😉

Message Edited by altenbach on 01-12-2009 01:08 AM
0 Kudos
Message 5 of 11
(3,754 Views)

DeWalker,

 

try attached VI....

 

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 6 of 11
(3,744 Views)

You did not tell us your LabVIEW version, so chances are that you cannot open Nobert's example, whcih is in LabVIEW 8.6. There are also a few things that might confuse you, e.g. the iteration terminal of the outer loop is buried under the event structure for some reason

 

Here's a quick cleanup of Norbert's example (LabVIEW 8.5). I prefer a checkbox control for the scaling. Feels more natural. 😉

0 Kudos
Message 7 of 11
(3,738 Views)

Well, i asume that the iterator from the outer loop is overlapped due to autosizing of the event structure during programming... i haven't checked the vi before posting again... 😞

And using a checkbox for toggling is indeed more natural than the button.

 

Norbert 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 8 of 11
(3,735 Views)

Hi !

Thanks Nobert and Altenbach......

I tried the vi posted on my LV8.5 version(tnks altenbach  :smileywink:)

In case of event structure the scale fit is applied only once(when called) but i want it to remain fitted  .

I have posted the while loop way ,hope you people can provide good solution.....

Cheers 

0 Kudos
Message 9 of 11
(3,707 Views)

You sem to have some misconceptions about these properties. Did you actually try my VI? 😮

 

If you write a "2" to scalefit property, it will remain in effect until you change it again. It will autoscale whenever the graph receives new data until you change the property again with a new value. Only if you write a "1", it will scale only once. This is well documented in the LabVIEW help.

 

Your two-loop solution is silly. Your lower loop will consume 100% of the CPU, writing the same property over and over, millions of times more than the rate the graph is updated. All you do is waste electrons. 😉  I also have no idea why you write the same property twice per iteration. Is this a government requirement. :D.

Message 10 of 11
(3,680 Views)