LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop a while loop with array outside

Solved!
Go to solution
Your modification makes better the vi but I have still some trouble to understand why when you fixed the number of trials more than 4 the vi fails to work well. If you put for example the number of trials at 5, the last number selected in array 3 is 0 and the subvi S+ presentations is never presented. How to do to avoid this problem ? Thank you in advance.
0 Kudos
Message 31 of 57
(1,847 Views)
There was a problem in the calculation of the random numbers.  Eliminate the -1 decrement function.  Change the Rounding  to Down towards - Infinity, rather than up to + infinity.
Message 32 of 57
(1,840 Views)
Okay thanks I will try your solution tomorrow.
0 Kudos
Message 33 of 57
(1,832 Views)

Hi,

 

Thank you very much for the solution, it works well. Now I would like something a little bit more complicated. Actually at the beginning you have a choice between 2 buttons. One click to it makes it disappear. One click at left activates the timer and if it is at right you have a chnage in the font 2 sec before the presentation of a picture. 1 sec after, a next trial begins. At left, it is the same thing except that therer is no change in the font.

What I can't do is to return to the choice phase after the first trial because the while loop continues to run. I don't know how to fix it. Do you know how to fiw it? Thank you in advance 
Download All
0 Kudos
Message 34 of 57
(1,817 Views)

In order for that event structure to execute more than once, you will have to get it placed in a while loop so that it can execute again.  I think you need to step back and rethink your architecture.  From solving the original problem as you had posed it, you have now added about 3 layers of complication.  You've duplicated all the code.  That is now a candidate to be made into a subVI.  The 2nd set of code is now dependent on the completion of the first set based on the blue wire you have running between them.  I don't think that is what you want.

 

You've wrapped up each set of code in a case structure with a single other case that is empty.  And for many of your cases, you have tunnels set to their default values.  I don't think that is always what you want either.  I would think the # to create is just as valid for the second set of code as the first, but whenever the second set runs, the first set hasn't run, thus the value of that wire will be zero because that is the default value of the tunnel coming out of the upper case structure.

 

And third, you've added the complication of the event structure.

 

I suggest you look at the design templates.  The event structure should probably be a part of the producer loop in a producer/consumer design architecture.  Beyond that.  You should look at the state machine architecture which is often built within a consumer loop.  Any time you have something where you are dealing with multiple steps, but need to return to an earlier step, but also need the flexibility to change the order of the steps, a state machine is usually at the heart of it.

 

I would also recommend cleaning up the front panel.  Now that you've added some new controls, they are getting scattered all over the place on the front panel.

 

Looking closer at the event structure, it should execute twice because it is within a For loop that has a 2 wired to N.  But it will not get past the event structure again until either button press happens.  You are doing some odd things with hiding the buttons, and even odder things by changing their position.  You may be setting yourself up for a case where you can't execute the event structure because the controls that have events attached to them are either missing or misplaced.

 

As for your comments about different fonts, I don't see in your code where you are doing anything with fonts.

Message Edited by Ravens Fan on 12-04-2008 09:36 AM
Message 35 of 57
(1,810 Views)
Okay thanks I will take a look of that.
0 Kudos
Message 36 of 57
(1,800 Views)
I am not familiar with producer/ consumer design patterns and the functions used. The event structure could be in the producer loop and the array of values for timing in the consumer loop? I can't see an example of this pattern could you send me please an example of design. Thank you very much for your help. 
0 Kudos
Message 37 of 57
(1,794 Views)

Go to File then New ....

 

You want Producer/Consumer design pattern with Events.  See attached.

 

PS:  Why is it with your messages the Re:  gets added on with every reply.  The only thing I can see is that your reply gets added on as Re space colon, while mine is Re colon which matches all other replies I see on the forums.  Puzzling.

Message 38 of 57
(1,789 Views)

Yes puzzling.

 

Otherwise thank you but I did see the example in the templates but I have difficulties to see the link with my program and how to arrange element I have in this architecture. I have difficulties to see how it works except for the state machine that I know a little bit more.

0 Kudos
Message 39 of 57
(1,783 Views)
And in which loops I have to arrange the elements I have. Thank you in advance for your help.
0 Kudos
Message 40 of 57
(1,774 Views)