LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Resetting a for loop shift register

Highlighted

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
(328 Views)
Highlighted

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 LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
0 Kudos
Message 2 of 9
(317 Views)
Highlighted

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
(311 Views)
Highlighted

Hi Ignocia,

 

sure I can:

Best regards,
GerdW

using LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
Message 4 of 9
(291 Views)
Highlighted

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
(270 Views)
Highlighted

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! ADDQ VIPM Now on GitHub
"Only dead fish swim downstream" - "My life for Kudos!" - "Dumb people repeat old mistakes - smart ones create new ones."
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 9
(254 Views)
Highlighted

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 LV2011SP1 + LV2017 (+LV2020 sometimes) on Win10+cRIO
Message 7 of 9
(248 Views)
Highlighted

@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
(234 Views)
Highlighted

@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.).


LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 9 of 9
(186 Views)