LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem with one loop in another one

When I drag and move cursor, X scale position will be show below. And then I click “add data in array”, the data should be put into array. I can move cursor again to add the second , the third ….into array.

My problem is:

In block diagram, once loop2 is outside of loop 1, it works. But I really want loop2 is in loop1 regarding to the rest part of the program. However, we I move loop2 into loop1, when I move cursor, nothing happens.

Please help to make it work or you have different way to do this job.

Thank you very much

Liming

0 Kudos
Message 1 of 17
(2,977 Views)
Rather than bother with a separate loop and a local variable, I would add a case for "cursor move" on the graph, take the CursoLoc.X from the event variables, stick it in a shift register, and then insert that register value into the array under the  "add data in array": Value Change case.

Also, there has to be an easier way to clear your array than the one you are currently using.

Message Edited by jasonhill on 04-07-2006 10:16 AM

0 Kudos
Message 2 of 17
(2,969 Views)

Thank you for help. Your suggestion is very good for me, But I can not make it work. I may not understand you very well. Could you please do it in my VI? Thanks

 

0 Kudos
Message 3 of 17
(2,958 Views)
I did a couple things.  I implemented the cursor move, I wiped the second loop, I added a stop button (important!), I changed the clear behavior, I ditched the bizzare invisible Array1 2, and cleaned up a bit.  Unless I misunderstand what you are trying to do, this should work nicely.
0 Kudos
Message 4 of 17
(2,956 Views)

Thank you very much. I learn something new from it.

I am trying to modify it to fit my application.

I add a coursor position indicator, when I move cursor I want indicator show its value.

I add an out loop, I will add other stuff in this loop. Now My problem is:

1) When I move cursor, indicator does not react.

2) Stop button (stop 2)  is not working for out loop.

Please see what I did wrong

 

0 Kudos
Message 5 of 17
(2,950 Views)
Hey, no need to make it so complicated.  Just add an indicator on the CursLoc.X wire in the  "0 To 5 MHz": Cursor Move  case.

To answer your questions:

1) The indicator does not react because you are still within the inner while loop.  It will not change until that loop completes. I.e. the stop button is pressed.

2) Similarly, the stop 2 button will press, but nothing will happen until the inner loop is done.

Generally, when I am using an event structure, I try to keep all the changing UI inputs and outputs in the same while loop with the event structure, if not in the event structure itself.  Local variables and property nodes can get the job done, but they are inefficient and can be difficult to debug.  As I am sure you are discovering Robot wink


Message Edited by jasonhill on 04-07-2006 12:40 PM

0 Kudos
Message 6 of 17
(2,945 Views)

Thank you. I did some change based on what your suggested and my need.

Now The problem is "STOP", the stop event seems do not do anything, which makes STOP 2 does not react.

Please take a look.

0 Kudos
Message 7 of 17
(2,936 Views)
You do not need the outer while loop.  This is what is happening: Clicking STOP tells the event structure to send a stop signal to the inner while loop.  The outerloop then imediately restarts the inner loop unless the STOP 2 button is already pressed.  The inner loop will loop until the STOP is pressed.  The outer loop restarts the inner loop unless STOP 2 is pressed.  And so on. 

Every time STOP is pressed, X and Array 1 are reinitialized which is confusing.  The only way to stop the program is to press STOP 2 and then press STOP.  STOP 2 will stay "pressed" until STOP one is pressed, which is confusing.

You could wire the stop case to the outer loop's stop, but then what is the point of the outer loop?
Message 8 of 17
(2,927 Views)

Yes. I understand your points.

However, I really want this outer loop, since I will have  alot other stuff running in this outer loop. I can move innner loop outside outer loop, and make it work.  But I have problem to do other things.

Here I post my problem see if it work when two loops nest together. If you see there is no posibility, I may give it up.

Thanks

 

0 Kudos
Message 9 of 17
(2,911 Views)
I am certain that together we can get your program up and running.  Robot Very Happy

How about we do this: create a new case for "stop 2".  This case will stop the case structure loop and the outer loop.  Now, when "stop" is pressed, the innerloop stops, the outer loop does its thing until it encounters the inner loop again.  At which point, the case structure waits for input again.  When you are really done, press stop 2 and it terminates both the inner loop and the outer loop.


Message Edited by jasonhill on 04-10-2006 10:29 AM

Message 10 of 17
(2,908 Views)