LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Increment from block diagram

Hi, I'm using numeric control on the front panel with increment buttons. What I would like to do is have a true condition on the block diagram automatically increment the numeric control on the front panel (no mouse click). Is this possible? Does anyone have an example. Thanks.
0 Kudos
Message 1 of 12
(4,323 Views)
You can use either a local variable or a property node. This shows the action performed from a Boolean control, but the Boolean value can come from anywhere:




To learn more about LabVIEW it is recommended that you go through the tutorial(s) and look over the material in the NI Developer Zone's Learning Center which provides links to other materials and other tutorials. You can also take the online courses for free.


Message Edited by smercurio_fc on 06-21-2008 08:37 AM
0 Kudos
Message 2 of 12
(4,315 Views)
I would definitely advise against the use of locals and/or value property nodes for such a simple problem.
 
A better way is to use a shift register as in the following example:
 


Message Edited by altenbach on 06-21-2008 09:05 AM
Download All
Message 3 of 12
(4,303 Views)
Also don't forget that you can do a completely code-free version by customizing a numeric and resizing the built-in inc/dec buttons (or even importing custom graphics into them!) .
 
Here's a quick example, (just resizing and rearranging the buttons).  Try to import custom graphics for full customization.
 
 
 
This has the advantage that the buttons even work if the VI is not running (like in an xcontrol).


Message Edited by altenbach on 06-21-2008 09:15 AM
Download All
Message 4 of 12
(4,300 Views)


altenbach wrote:
I would definitely advise against the use of locals and/or value property nodes for such a simple problem.
 
A better way is to use a shift register as in the following example:
 

I totally agree with you Altenbach.
 
However, in smercurio's defence, I believe he did that because the question mentions a control instead of an indicator..  So maybe the operator can also input a number..    At least that was my interpretation.
 

 
Message 5 of 12
(4,294 Views)


JoeLabView wrote:
However, in smercurio's defence, I believe he did that because the question mentions a control instead of an indicator..  So maybe the operator can also input a number..    At least that was my interpretation.

Yes, you are right. I should not reply before my morning coffee. 😄
 
It seems like not such a good idea to programmatically increment a control, because the code will potentially fight with the operator actions. What if the operator tried to decrement the value and the code constantly does the opposite? This often leads to poor UI mechanics. (programmatic settings of controls should be limited to e.g. reset ir initialize functions or similar).
 
I would use an indicator unless there is a very good reason not to.
 
Sorry, I did not see the "programmatic" word. Here's a quick example that increments a "control" 😉 whenever a random variable is >0.9.
(A local variable is very strongly preferred over a value property node!)
Again, an indicator would be more natural, because the operator should typically not be able to change the count randomly.
 




Message Edited by altenbach on 06-21-2008 10:14 AM
Download All
Message 6 of 12
(4,288 Views)
Thanks everyone for all the help. I used some of the suggestions from everyone. It is a control that the user will input values initially, then the program will take over and monitor an output and depending on that value the program will increment or decrement the control. The user will not need to input to the control while the program is in control. I almost have it. I'm currently trying to figure out how to start, stop, and restart an event structure or a while loop without stopping a parallel loop. I'm a rookie with labview and all suggestions and examples are greatly appreciated, thanks again for all the help.
0 Kudos
Message 7 of 12
(4,269 Views)

Altenbach made very good recommendations.

Here's what I had done this morning but didn't post it because it was similar to smercurio.

It's good to know there are alternatives..  😉

RayR



Message Edited by JoeLabView on 06-21-2008 02:12 PM
Download All
0 Kudos
Message 8 of 12
(4,264 Views)

@JoeLabView wrote:


@altenbach wrote:
I would definitely advise against the use of locals and/or value property nodes for such a simple problem.
 
A better way is to use a shift register as in the following example:
 

I totally agree with you Altenbach.
 
However, in smercurio's defence, I believe he did that because the question mentions a control instead of an indicator..  So maybe the operator can also input a number..    At least that was my interpretation.

Thanks, Ray. That was precisely why I had done it that way. I had thought about a shift register as well, but decided not to provide it as a suggestion because there frankly wasn't enough to go on to determine what the poster was trying to do. My interpretation when I provided the suggestion was that the poster wanted to still be able to use the control from the front panel and have some sort of process or flag that would automatically increment the control.
Message 9 of 12
(4,255 Views)


uddy wrote:
I'm currently trying to figure out how to start, stop, and restart an event structure or a while loop without stopping a parallel loop.

Make sure to disable the control while its values are under programmatic control.
 
Your event structure should be inside a while loop that always runs. Make it so it just waits or discards events when in "stop mode". You should not start|stop|restart any loops.
 
If you don't mind, attach your code and we might be able to offer improvements.
Message 10 of 12
(4,245 Views)