05-14-2012 08:28 AM
So I have two SilverPak 23CE stepper motors that I'm controlling with LabVIEW. The ultimate goal is to attach them to the x- and y-dimensions of a square plate and move it in a rastering motion - that is, across one line of specified length, down a tad, then back in the other direction and down again, etc. I've gotten to the point where I can give them each specifications as to how far to move and in which direction and have them both go at it simultaneously, but I need to have them wait turns so that only one motor is running at a time in order to get the type of motion I want. I figure that I can either work in a time delay for each motor determined by the specifications of the other (velocity, acceleration and distance, all of which I can set) or else work in a boolean that checks to see if motor #1 is running before starting motor #2, and vice versa.
I've been working with these motors for three days now, and just saw LabVIEW for the first time the day before that, so any kind words for a n00b are much appreciated.
Thank you!
-Nelly
Solved! Go to Solution.
05-16-2012 10:30 AM
Hi Nelly,
Welcome to the NI Discussion Forums! I took a brief look through the SilverPak manual for the device commands here: http://www.linengineering.com/LinE/contents/stepmotors/pdf/Silverpak23C-R356Commands.pdf. While it is possible to use the velocity and acceleration information, it looks like there may be a more direct way to wait for a move to be complete by using one of the query commands on page 10. I'm not too familiar with these motor/amplifier units, but you should be able to query the motor position with the /1?0 command. Thus, you can issue a command to the first motor and then continuously poll the motor until the desired position is reached, and then execute the next move.
To do this, you may benefit from a state machine architecture for your code: http://www.ni.com/white-paper/3024/en. Essentially, you can have a set of states for your system (e.g. move X, move Y) and you can transition from one state to another based on certain conditions (e.g. position of X has reached a threshold). While this may take a little more time to setup initially, it will make future additions to your code much simpler. Please take a look at the link and let me know if you have any more questions.
05-29-2012 01:04 PM
Thank you, Joseph! I ended up just writing strings containing the J and H commands, which, for these motors, control turning on or off the outputs and waiting to move until the output signal has been received from the other motor, respectively. I also pulled out the connecting cables I was using and just taped the correct input/output pins from either motor together. I didn't have to worry about making loops in LV at all, just sending the correct command strings to the port. Works like a charm now!