LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I set a TRUE value from the n iteration to FALSE in the n+1 iteration within a while loop?

Solved!
Go to solution

I would like to store a Voltage Value within a while loop (Shift register), where the Boolean operator should be TRUE in the current iteration and FALSE in the next iteration. Im using a Select-Function. How can I implement this?

0 Kudos
Message 1 of 9
(2,642 Views)

Hi Rashid,

 


@RashidHamid wrote:

where the Boolean operator should be TRUE in the current iteration and FALSE in the next iteration.


Use a shift register and a NOT to achieve your requirement...

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 9
(2,616 Views)

Unless you only have two iteration, your description is not clear at all.

 


@RashidHamid wrote:

How can I set a TRUE value from the n iteration to FALSE in the n+1 iteration within a while loop?


What is "n" and what should happen if the value is FALSE at "n"? What should the value be for iteration "n-1", n+2 or "n+3" etc. (It would help to use conventional names (such as "i" and "N" for loops) to avoid confusion.

 

If you want it to be true in the first iteration and false afterwards, you could use a [i=0?] on the iteration terminal.

 


@RashidHamid wrote:

 Im using a Select-Function. How can I implement this?


That does not really narrow it down. Please show us your code and explain exactly what it should do.

 

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

When I click a button, it outputs a TRUE value. Afterwards the voltage should be stored in a shift register. Unfortunately I do not get further.

0 Kudos
Message 4 of 9
(2,600 Views)

@RashidHamid wrote:

When I click a button, it outputs a TRUE value. Afterwards the voltage should be stored in a shift register. Unfortunately I do not get further.


A truncated image is not useful. We can't even see the button! Please attach your VI! (Do save for previous if you are using LabVIEW 2021).

 

What should be in the shift register before the button is pressed?

What is the mechanical action of the button?

 

(I would avoid the term "current" when talking about "voltage". Could be misinterpreted)

0 Kudos
Message 5 of 9
(2,589 Views)

The Shift register should be empty (0).

0 Kudos
Message 6 of 9
(2,577 Views)
  • A shift register is never empty (it can be zero or contain an empty array, but that's not the same!). If you want the initial value to be zero, you can initialize it with that. An uninitialized shift register contains whatever random value is left over from the previous run. probably not what you want.
  • I sitll don't see any button anywhere. Where is it? Did you attach the correct code? (EDIT: Ah, you are reading a physical button! Would have been more obvious without the right-to-left wire ...)
  • I think that you need your logic sorted out. The following is pure Rube Goldberg!

(A "=true" just returns the other input unchanged, for example)

 

 

altenbach_0-1646504825800.png

 

 

 

0 Kudos
Message 7 of 9
(2,569 Views)

OK, so your logic is apparently not what you want. Maybe you can give us a full description of the requirements.

 

What should the input to the select node be:

 

  1. At the start of the program if the button is not pressed
  2. At the start of the program if the button is already pressed
  3. Right after the button is pressed
  4. In the next iteration(s) while the button is still pressed
  5. Right after the button is released
  6. In the next iteration(s) after the button is released

 

 

0 Kudos
Message 8 of 9
(2,550 Views)
Solution
Accepted by RashidHamid

Here are two possible ways to get a TRUE only whenever a boolean input just changed from FALSE to TRUE. Is that what you want?

 

altenbach_0-1646507888767.png

 

0 Kudos
Message 9 of 9
(2,543 Views)