05-20-2009 05:25 PM
Hi,
I would like to give multiple steps to a motor/controller to exectue, but I keep getting a "command overflow" error. Therefore, I am trying to tell the for loop only to execute when the VISA Read receives an output. I have included the .vi I have written so far. For example, the code /1P1000p66R tells the controller to move motor "1" forward 1000 steps and then to output the number "66" when the motor has moved 1000 steps. My input to the "table control" is, e.g., 3 commands:
/1P1000p66R
/1D1000p66R
/1D5000p66R
How do I get the code to send each of those commands only when the number "66" is sent back to the program so that I don't get the command overflow error? Also, if anyone has a better way to control the motor to do multiple steps, let me know. I'm pretty new to all of this.
Thanks.
05-20-2009 08:29 PM - edited 05-20-2009 08:31 PM
Rather than using a table control, I would just use a string array.
Set your serial port parameters before the loop. Close the serial port after the loop.
Your controls don't have any real data in them saved as default, so I'm confused a bit as to what your are trying to do. Why do you have a numeric control with the number 0 establishing the loop iterations?
Instead of a For Loop, use a while loop. Set the 1-D array of strings to be autoindexing at the input tunnel. Write the command (why you have everything wrapped in a case statement with a true constant makes no sense. Do a VISA read. If the response has the 66 (you'll have to figure out how to parse it out), all is good. If it does not have the 66, or the number of loop iterations equals the number of commands in the array -1 , then end the loop.
05-21-2009 11:17 AM
Hi Ravens Fan,
Thanks for the response. Sorry for the confusion. I had the numeric control in the vi because I am planning to use this as a sub vi, and I was going to use a property node to pass to the numeric control the number of rows in the table control. Also, I used to have those case structures wired with a boolean control, not a true constant. I just forgot to change them back. Although, I think I do always want them true so you're right, I can take out the case structures.
So the vi you attached helped, but the program is still coming back with an error. My problem is that I cannot send another command to the controller until the motor is done moving (executing one command). If I send the command too early, the controller responds with an "command overflow" error and only executes the first command in the array. The commands list for the controller says that a "p" command will send out any number placed after "p" when the motor has moved the secified number of steps. e.g. /1P1000p66R will send out a 66 when the motor has moved 1000 steps. Therefore, I need the loop to wait for a "p" response from the controller before moving onto the next iteration.
Thanks.