11-24-2006 11:01 AM
11-26-2006 11:25 AM - edited 11-26-2006 11:25 AM
I'm not sure I understand. The attachment does not have a for loop and it will run until the stop button is pressed. Are you saying that this example keeps generating a pulse unless you unplug the device? If you want to try a for loop, it should look something like the attached. Notice that the array input tunnel has indexing enabled so that the for loop runs for the length of the array. You should also clean up the wires and use a shift register for the error cluster.
Message Edited by Dennis Knutson on 11-26-2006 10:26 AM
11-27-2006 05:47 AM
Hi Dennis,
Thank you very much for your help. My problem was that i did not change the outputs of the loop to shift registers. Now i slightly modified the file so that i can determine the number of degrees by which the motor moves. 100 iterations is one degree so whatever number entered in the numeric contorl gets multiplied by that to move the motor to however many degrees i want. The problem is this idea works for only up to 10 degrees. Anything higher than that the motor moves 10 degrees and stops.
Is it anything in the code beacuse I can't figure it out?
Thank you in advnace for your help
Myriam
11-27-2006 05:49 AM
11-27-2006 08:43 AM - edited 11-27-2006 08:43 AM
Let me explain how a for loop works. There are two different ways to determine the number of iterations a for loop executes. One way is to wire in an array and autoindex the array into the for loop. You can see this in your posted example. The array changes to a thinner wire. The for loop's number of iterations will equal the size of the array. Wire in an array with 100 elements and the for loop executes 100 times. The other way is to wire a value to the count (N) terminal. Wire 100 to it and the for loop will iterate 100 times. Now, what happens when you do both is that the for loop's iteration count will equal the smaller of the two numbers. Wire a 10 to the count terminal and wire in a 100 element array, the for loop executes 10 times. Wire 100 to the count terminal and wire in a 10 element array, the for loop executes 10 times.
Since you have an array with 1000 elements, the for loop will never execute more than 1000 times. Depending on what your front panel numeric is, it could execute fewer times but never more. Your original VI with the while loop could have been modified to stop when the count was equal to some value. You could also use two loops. If the entire array is something that you want to repeat each time, put a second loop around the array and existing for loop. The outer loop could be a while or for loop. If a for loop, then you can wire the front panel numeric calculation to that. Personally, I think a while loop might be better. With each iteration, compare the i value to your desired count. If it's equal or greate than the desired count, stop the loop. The advantage of a while loop is that you can also or in a front panel stop button to the stop condition.
Message Edited by Dennis Knutson on 11-27-2006 07:44 AM
11-27-2006 09:49 AM
11-27-2006 11:47 AM
Hi Dennis,
Now that makes a lot more sense. Thanks for the explanation which helped me a lot as a beginner. NOw when i run the attached vi based on the advice you gave me i get an error saying:
Error 3 occurred at an unidentified location
Possible reason(s):
LabVIEW: Internal error. Wrong memory zone accessed.
Any ideas what in the attachement could cause that?
Thank you in advance for your help
Mira
11-27-2006 11:54 AM