Motion Control
Precision MicroControl Corp.
118
The
MC_STAT_TRAJ
status flag is the conditional component of the
MCIsStopped( )
and
MCWaitForStop( )
functions. As shown by the trajectory graph above, the typical lag or following error
during a servo move can cause the
MC_STAT_TRAJ
flag to be set
before the axis has reached its
target
. Issuing
MCIsStopped( )
with a timeout value specified or
MCWaitForStop( )
with a
Dwell
time
specified allows the user to delay execution move has been completed (following error = 0). In the
example below, the
MCIsStopped( )
function (with a 2 second timeout) is used to poll the axis for
MC_STAT_TRAJ = true. The Windows SLEEP function is used to allow the axis to stop and settle for 100
milliseconds. command includes a Dwell of 5 msec’s, allowing the axis to stop and settle.
MCMoveRelative( hCtlr, 2, 500.0 );
// move 500 counts
MCIsStopped( hCtlr, 1, 2.0 );
if (!MCIsStopped( hCtlr, 1, 2.0 )) {
// Motor failed to stop within time limit (2 seconds),
// error handling code goes here
}
Sleep( 100 );
Another method of indicating the end of a move of a servo is to use
MCIsAtTarget( )
or
MCWaitForTarget( )
functions. To satisfy the conditions of
MCIsAtTarget( )
and
MCWaitForTarget( )
,
the axis must be within the
Deadband
range (encoder /- or stepper /-) for the time period
specified by
DeadbandDelay
, both of which are defined within the
MCMotion
data structure.
The
MC_STAT_AT_TARGET
flag will be set when the conditions for both Deadband and Deadbanddelay
have been met.
MCMoveRelative( hCtlr, 1, 1250.0 );
// move 1250 counts
MCWaitForTarget( hCtlr, 1, 0.005 );
// wait till MC_STAT_TRAJ set
plus
//
msec’s
MCIsAtTarget( hCtlr, 1, 2.0 );
if (!MCIsStopped( hCtlr, 1, 2.0 )) {
// Motor failed to reach the target within time limit (2 seconds),
// error handling code goes here
}
Sleep( 100 );
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com