From: Southampton on
Hi all,
 
I am supposed to be using USB 6009 to control a stepper motor. I am using software timing. When i give it an array of 10 elements to produce a square pulse the motor moves in steps but it does not stop unless i unplug the USB from it. Is there any way of controlling when the motor should stop or how many degrees it should move before stopping?Whenever I increase the number of elements in the array, the signal becomes more continuous and smooth, so this does not affect when it should stop in any way. I  also tried using a for loop where the number of iterations  represetns the number of steps it should produce (the number of times it should repeat the elements in the array) but as you can see in the attachement this is not working. I saw a timed loop palette as well but i don't think i can use these as the USB does not have an onboard clock.
 
So how can I control the number of steps the motor should move so that I dont' have to unplug the USB from the motor everytime i want to stop; i would like to be able to control it by giving it the number of steps it should make and then stop after that.
 
I hope I made this as clear as possible. I am a complete beginner in labview so any help would b much appreciated.
 
Thank you in advance
 
Mira


Gen Mult Volt Updates-SW TimedTriangle1500ForLoop.vi:
http://forums.ni.com/attachments/ni/170/217050/1/Gen Mult Volt Updates-SW TimedTriangle1500ForLoop.vi
From: Dennis Knutson on
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.
<img src="http://forums.ni.com/attachments/ni/170/217117/1/Generate%20Pulse%20Train%20with%20For%20Loop.PNG"> Message Edited by Dennis Knutson on 11-26-2006 10:26 AM


Generate Pulse Train with For Loop.PNG:
http://forums.ni.com/attachments/ni/170/217117/1/Generate Pulse Train with For Loop.PNG
From: Southampton on
Hi Dennis,
&nbsp;
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?
&nbsp;
Thank you in advnace for your help
&nbsp;
Myriam


Gen Mult Volt Updates-SW TimedTriangle1500ForLoop.vi:
http://forums.ni.com/attachments/ni/170/217165/1/Gen Mult Volt Updates-SW TimedTriangle1500ForLoop.vi
From: Dennis Knutson on
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&nbsp;or in a front panel stop button to the stop condition.
<img src="http://forums.ni.com/attachments/ni/170/217214/1/Outer%20While%20Loop%20Version.PNG"> Message Edited by Dennis Knutson on 11-27-2006 07:44 AM


Outer While Loop Version.PNG:
http://forums.ni.com/attachments/ni/170/217214/1/Outer While Loop Version.PNG
From: Southampton on
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:&nbsp; Internal error. Wrong memory zone accessed.
&nbsp;
Any ideas what in the attachement could cause that?
&nbsp;
Thank you in advance for your help
&nbsp;
Mira


Gen Mult Volt Updates-SW TimedTriangle1500ForWhile.vi:
http://forums.ni.com/attachments/ni/170/217269/1/Gen Mult Volt Updates-SW TimedTriangle1500ForWhile.vi