From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to lock boolean data indicator

Solved!
Go to solution

Hello Guys,

Good night,

I have a problem with boolean indicator(lamp)

 

In my project,

When the value > 7 the lamp 1 turn on

When the value < 5 the lamp 2  turn on

 

i want, 

1. If the value > 7 lamps locked, so before the value < 5 the lamp 1 always on

2. if the value < 5 lamps locked, so before the value >7 the lamp 2 always on

 

Sorry 4 bad english,

 

Nb: vi on attach post

 

Thanks,

Stewkidz

0 Kudos
Message 1 of 9
(3,756 Views)

(you might want to add a small wait into your loop)

 

How does the value change over time. What is the initial value? All you probably need are two shift regsiters that keep history information.

0 Kudos
Message 2 of 9
(3,732 Views)

If I understand you correctly, all you need is a couple Shift Registers.  This will turn 1 high if the value exceeds 7, and it will not go low again until the program is restarted.  The same works for turning 2 low when the value goes below 5.

 

Ask Lock Boolean_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

0 Kudos
Message 3 of 9
(3,710 Views)

@jcarmody wrote:

If I understand you correctly, all you need is a couple Shift Registers.  This will turn 1 high if the value exceeds 7, and it will not go low again until the program is restarted.  The same works for turning 2 low when the value goes below 5.


The way I understood it was that the >7 LED should turn off once the value goes <5. In your code is stays on permanently.

(Granted, the problem description is not entire clear and leaves out some scenarios. That's why I asked for clarification)

0 Kudos
Message 4 of 9
(3,706 Views)
Solution
Accepted by topic author StewKidz

See if this works as you expect.

 

(Note that certains things could be improved by using compound nodes, but this code is more clear. There are many ways to do this. I would probably use an array of two booleans in the shift register and only one each for the boolean operations)

 

Download All
Message 5 of 9
(3,698 Views)

@altenbach wrote:

 

I would probably use an array of two booleans in the shift register and only one each for the boolean operations)


Here's one possible array solution.

 

 

0 Kudos
Message 6 of 9
(3,690 Views)

 

 

 

 

0 Kudos
Message 7 of 9
(3,668 Views)

Those are Shift Registers.  Right-click on the output tunnel and select:

 

sr.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

0 Kudos
Message 8 of 9
(3,656 Views)

@jcarmody wrote:

Those are Shift Registers.  Right-click on the output tunnel and select:


It works equally well with input tunnels. Many times there are no suitable tunnels yet, then you  just right-click on the loop frame and select "add shift register".

 

(Creating a new shift register is actually easier for the inexperienced programmer. If we convert an existing tunnel to a shift register, it is more complicated because we need to immediately decide to either pair it with another existing tunnel of opposite direction or  create a new other half).

0 Kudos
Message 9 of 9
(3,639 Views)