Motion Control
Precision MicroControl Corp.
104
// Set the positive hard limit of axis 2 to stop by turning the motor
off.
// Because axis 2 uses normally closed limit switches we must also invert
the
// polarity of the limit switch. Soft limits are ignored.
MCSetLimits( hCtlr, 2, MC_LIMIT_PLUS | MC_LIMIT_OFF | MC_LIMIT_INVERT, 0,
0.0, 0.0 );
i
In Position and Velocity mode the response to an activated limit input is
direction sensitive, the axis will only be stopped if it is moving in the direction of
the activated limit switch. In Contour mode, the response to an activated limit
input is not direction sensitive, the axis will be stopped regardless of the
direction it is moving if either limit switch is activated. In Torque mode, the
controller will ignore the activation of a limit input, the axis will continue to move.
If the user does not want to use the Auto Axis Disable feature, the current state of the limit inputs can be
determined by polling the controller using the
MCGetStatus( )
,
MCDecodeStatus( )
functions. The flag
for testing the state of the Limit + input is
MC_STAT_INP_PLIM
. The flag for testing the state of the Limit
- input is
MC_STAT_INP_MLIM
.
Soft Limits
Soft motion limits allow the user to define an area of travel that will cause an error condition. When
enabled, if an axis is commanded to move to a position that is outside the range of motion defined by the
MCSetLimit( )
function, an error condition is indicated and the axis will stop. The
MCSetLimit( )
function
provides the following limit flags:
Table 3. Motion Control API Limit Mode Flags
Flag
Description
MC_LIMIT_PLUS
Enables the High/Positive soft limit
MC_LIMIT_MINUS Enables
the Low/Negative soft limit
MC_LIMIT_BOTH
Enables the High and Low soft limits
MC_LIMIT_OFF
Turn off the axis when the hard limit input ‘goes’ active
MC_LIMIT_ABRUPT
Stop the axis abruptly when the hard limit input goes active
MC_LIMIT_SMOOTH
Decelerate and stop the axis when the hard limit input goes active
When a soft limit error event occurs, the error flags (
MC_STAT_ERROR
and
MC_STAT_PSOFT
_
TRIP
or
MC_STAT_MSOFT_TRIP
) will remain set until the motor is turned back on by
MCEnable( )
. The axis
must then be moved back into the allowable motion region with a move command (
MCMoveAbsolute( )
,
MCMoveRelative( )
).
// Assume axis 3 is a linear motion with 500 units of travel. Set the
both
// hard limits of this axis to stop abruptly. Set up soft limits that
will
// stop the motor smoothly 10 units from the end of travel (i.e. at 10
// and 490).
MCSetLimits( hCtlr, 3, MC_LIMIT_BOTH | MC_LIMIT_ABRUPT, MC_LIMIT_BOTH |
MC_LIMIT_SMOOTH, 10.0, 490.0 );
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com