LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Increment and decrement with a Boolean input

Solved!
Go to solution

Hello Labview Experts (and life savers actually !!)

 

In my VI ,I have  a numerical controller (knob) feeding a numerical indicator ,in addition to a bolean input.

As an initial state the numerical indicator will contain a certain value (zero for example) and will only receive the variation in the knob input as long as the bolean input is true and then add it to this initial value.

 

what is the variation ? lets say that the knob was on 8 before i hit the boolean true ,the indicator's value is zero ,and then I hit the boolean true ,

Now ,when i move the knob from 8 to 18 (+10 variation) ,I want the indicator to receive +10 and add it to the zero ,now the result is 0+10=10.

 

Now the boolean is false ,I move the knob and nothing happens to the 10 in the indicator.

Now the boolean is true again ,let's to say the knob was on 4 at the time i hit the boolean true ,and I move it from 4 to 1 (-3 variation) ,the indicator's value now will be 10+ (-3) = 7

 

I hope I explained the idea in a clear way ,I would be very thankful if someone would help me with that.

 

P.S. I only attached the vi for illustrating the idea.

 

Thanks in advance

0 Kudos
Message 1 of 10
(4,118 Views)

@shadymohamed wrote:

 

P.S. I only attached the vi for illustrating the idea.


What have you tried?  I'd suggest an Event structure and, perhaps, a shift-register thrown in there.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

0 Kudos
Message 2 of 10
(4,113 Views)

I have tried a case structure ,but this only left me with the indicator either displaying the current knob value ,or not (in case of false for the structure)

and concerning shift register ,I'm actually not that clever with them Smiley Sad

 

can you please explain more with what you suggested ? 

 

thank you 

0 Kudos
Message 3 of 10
(4,108 Views)

Look at the example I made from your VI. It genereally does what you described, if I understood correctly.

 

You need to think about what to do if you changed the knob while Boolean was FALSE and then switch Boolean to TRUE. I hope this helps.

 

 

Message 4 of 10
(4,092 Views)

The event structure has a value-change event for Boolean, where it puts the new Knob value onto the shift-register if Boolean is True.

 

main%20components[1]_BD.png

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 5 of 10
(4,085 Views)

@jcarmody wrote:

The event structure has a value-change event for Boolean, where it puts the new Knob value onto the shift-register if Boolean is True.

 

main%20components[1]_BD.png


Just move that boolean terminal to inside of the event case.  That way you know you have the latest value of the switch.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 10
(4,079 Views)

Thanks for your suggestion

 

I tried implementing something as you described but i think im doing something wrong because all what im getting is decimals and are not accumulating as i want it to be.

 

what I'm looking for to do ,is a variable (indicator) which its value is accumulating based on the increase done in the knob right after the bolean is true and when i hit false the indicator's value does not change but rather start to increase again (or decrease) according to the delta change in the knob right after the next time the bolean is true.

0 Kudos
Message 7 of 10
(4,018 Views)

You missed the other Event case (and a few other things):

 

Untitled 1 Block Diagram _2014-09-06_19-02-18.png

 

The first image I posted is a VI Snippet.  You can drop it onto a Block Diagram and it'll be converted into LabVIEW code.

Jim
You're entirely bonkers. But I'll tell you a secret. All the best people are. ~ Alice
For he does not know what will happen; So who can tell him when it will occur? Eccl. 8:7

Message 8 of 10
(4,001 Views)
Solution
Accepted by topic author shadymohamed

You only care about how much the knob changed.  Therefore, you need to subtract the old value and the new value to get how much the knob changed.  Then inside the case structure, add that difference to your value that belongs in the shift register.

 


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 10
(3,995 Views)

Thank you ,it worked like magic 🙂 ,Thanks a lot

0 Kudos
Message 10 of 10
(3,905 Views)