LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Resetting a for loop shift register

Hi Labview experts

 

I am making an automated test where i am sequentially testing currents and voltages of a circuit. In one of the tests, i have to decrease voltage slowly untill an LED in the tested circuit starts blinking. 

 

Now my problem is - i use 2 for loop shift registers to start at 21 and count down by 0.1 untill it reaches the desired value, this works totally fine. But when i run the test again and it reaches the case where this function is placed, it starts at the value from the previous test. How do i make sure that the for loop always starts at 21 and counts down whenever i reach this case?

 

I posted a screenshot of how i made the shift registers

 

 

0 Kudos
Message 1 of 9
(1,612 Views)

Hi Ignocia,

 

it's easier to use only one shift register instead of two.

The formula node can be replaced by a simple Select node.

 

You really don't need 3 shift registers (including that feedback node) for such a feature!

You only need to store the information about the "up" or "down" cycle…

Best regards,
GerdW


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

Thanks for the response GerdW

 

I dont think i understand your solution, do you mind illustrating it for me and maybe elaborating more? 

 

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

Hi Ignocia,

 

sure I can:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 9
(1,575 Views)

Thanks again Gerd, the select tool makes sense to me now.

 

But i dont see this working in my program, the count down function is inside a case structure as it is the 3rd test in a sequential line of tests. I cannot put a while loop inside the case structure.

 

Do you have an example using a for loop? Or something else than a while loop atleast?

0 Kudos
Message 5 of 9
(1,554 Views)

You can Place a while loop in a case structure. It means, ofc, that the program will wait there until the loop is finished.

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 9
(1,538 Views)

Hi Ignocia,

 


@Ignocia wrote:

But i dont see this working in my program, the count down function is inside a case structure as it is the 3rd test in a sequential line of tests. I cannot put a while loop inside the case structure.


You already have a while loop around your case structure: you can use this one to hold the shift registers!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 9
(1,532 Views)

@Ignocia wrote:

Thanks again Gerd, the select tool makes sense to me now.

 

But i dont see this working in my program, the count down function is inside a case structure as it is the 3rd test in a sequential line of tests. I cannot put a while loop inside the case structure.

 

Do you have an example using a for loop? Or something else than a while loop atleast?


I don't think that you need either loop inside your case structure. You could get a lot better help if you supplied your code (or a minimal working example of your code) rather than just a picture of a small portion of your code. What you've got written is pure Rube-Goldberg.

0 Kudos
Message 8 of 9
(1,518 Views)

@Ignocia wrote:

I posted a screenshot of how i made the shift registers

 


I agree with others that you are overcomplicating things, not just in general but also for us by showing a truncated picture instead of actual code. We can offer much more targeted help if we see some code, have instructions on how you operate it, know exactly what you observe and what you would like to see instead.

 

The magic word here is "state machine". All you need is exactly one top-level while loop containing one case structure. All data and state information is maintained in shift registers of the while loop.

 

So please construct a minimal working demo (no hardware IO, just FP indicators) and we will help you make a great scalable solution (no inner loops, no coercion dots, no formula node, flat and simple code, etc.).

0 Kudos
Message 9 of 9
(1,470 Views)