LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

loop for a changing value

Hello,

 

I would like to create a loop function with a changing value. I want to create a binary image with the IMAQ threshold. Now I want to change the lower value in the front panel and I want that the new binary image appears on the screen.

 

So far I tried it with a case structure but I do not know how to compare the old value of the lower value with the new value from the front panel.

 

Can someone help me with this?

 

Thanks a lot!

0 Kudos
Message 1 of 7
(3,179 Views)

comparing values from one iteration to the next is mostly done via shift registers

temp1.png


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 2 of 7
(3,173 Views)

Christina,

 

     This is not the first time you've heard this advice, but when you have a question like this, post the code that you tried to use.  It is much easier to make a correction ("put the lower value in a Shift Register of a While Loop") than try (without knowing the structure of what you currently have) to describe how we might approach this problem ("Use a Producer/Consumer Pattern driven by a Lower Value Changed Event").

 

Bob Schor

0 Kudos
Message 3 of 7
(3,134 Views)

@jwscs wrote:

temp1.png


While the shift registers piece here is a good example of what you'd want to do.  I'd remove the Sequence Structure.  On a non-deterministic OS relying on user input, you aren't gaining value looking at 200ms.  If you remove the structure, you still slow the loop down giving the cpu free time.  You also read the user input at essentially the same time.  As the free time is purely for the sake of free time and not an attempt to time the loop, any value forcing the read to happen later is lost.  We've just added complexity to the code, taken options away from the compiler, and gained nothing for our trouble.

0 Kudos
Message 4 of 7
(3,104 Views)

i agree with you.


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 5 of 7
(3,098 Views)

This is my code. I do understand your example, but I am not sure how to adapt it to my code. If I change the lower value of the range I want the whole process to start again.

 

Therefore, I do not know how to connect N, because it is not a constant and I do not know what my output of the shift register on the right side would be.

 

 

Creating binary images.png

0 Kudos
Message 6 of 7
(3,083 Views)

Christina,

     The combination of your original Post that says what you want to do (but not in a way that I, for one, really understood what you meant) and the picture of your Block Diagram that you just posted have given me a better guess at what you want to do.  See if I'm right:

  • You start with an Image, and a Histogram range.  You want to process this Image in some fashion based on this Histogram range, saving the data to a file.
  • If you change the Histogram range, you want to "do it again".  You may want to repeat this step (change range, compute and save new Histogram) multiple times.
  • At some (not yet specified) point, you will want to stop.

     You do not need a For loop, since (as you noted) there is nothing saying how many times you want to do something (maybe only once, maybe dozens of times).  What you do need is a way to detect if the Threshold Range has been changed.  Does the phrase "Value Changed?" mean anything to you?  Do you know what an Event Structure is and does?

 

     It seems to me that you want something like a Queued Message Handler driven by an Event Loop.  The Initialize Message would take the initial Threshold Range and compute/save a Threshold.  If Threshold Range changed, a "Range Changed" Message would do the same thing.  You would also have a Front Panel Control called "Done" (you could use the Stop Button and change the Text to say "Done") that lets you exit from the Message Loop.  This would do precisely what I think it is you want to do, namely process an Image as many times as you choose (by changing the Range), with the added proviso that you have to add a control to say when to stop.

 

     There are numerous examples of the Queued Message Handler on the Web and in LabVIEW Examples.

 

Bob Schor

0 Kudos
Message 7 of 7
(3,077 Views)