## Shortest Distance Home Routine

om_tech_support_JT
Posts: 1058
Joined: Fri Mar 12, 2010 2:59 pm
Location: Torrance, CA
Contact:

### Shortest Distance Home Routine

Q: I am currently using the NX series servo motor and SCX11 controller for an index table application. I will be indexing 45 degree per step so my labeler can put the label on all four sides of the container. I will also have a camera to examine if the label is good or not. If the label is good, it will index to next position, if not, it will return to the original position to be fixed. Now, I want to optimize my throughput so I will need to find the shortest distance to return to home position. How do I implement that on the SCX11 controller?

A: The SCX11 has a built-in counter function that keeps track of the total number of pulses sent. And the command to look up this value is PC. This PC counter value is not stored in ROM, meaning that once the power is recycled, it will start at 0. Now, depending on your motor resolution, we can find out where the motor is in reference to a full rotation. For example, if your motor has a 500 P/R resolution, the motor will be at 180 degrees from the original position at 250 pulses. We can use the PC counter to detect motor position and program it to go to Home position in either the negative or positive position, thus choosing the shortest home routine distance. In the program, at the end of the 45 degree index move, you can check the counter value and compare it to 250. If the PC is greater than 250 pulses (more than 180 degrees from the position 0), you can home in the positive direction. If it is less than 250 pulses, it will return to home in the negative direction. So you will have sequence Home:

IF (PC<250)
MGHN *Home in the negative direction
END IF
IF (PC>250)
MGHP *Home in the positive direction
END IF
END

We can use this as a subroutine for the homing operation depends on the current position. Then in the main program, you can use your camera output signal to determine whether it will index to the next position or return to home. So in the main program:

IF IN1=1 *camera output GOOD
VS= *Starting Speed
VR= *Running Speed
VA= *Acceleration
INC *Index
ELSE
CALL Home *Call the subroutine for Home