01-12-2009 12:02 AM
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
01-12-2009 01:11 AM
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
01-12-2009 01:13 AM - edited 01-12-2009 01:15 AM
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.
01-12-2009 02:50 AM
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
01-12-2009 03:06 AM - edited 01-12-2009 03:08 AM
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. 😉
01-12-2009 03:30 AM
DeWalker,
try attached VI....
Norbert
01-12-2009 03:54 AM
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. 😉
01-12-2009 04:03 AM
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
01-12-2009 07:22 AM
01-12-2009 10:36 AM
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.