Example: Error Correction
The following code demonstrates what is necessary to set up SPM mode for the X axis, detect error, stop the
motor, correct the error, and return to the main code. The drive is a full step drive, with a 1.8
o
step motor and
4000 count/rev encoder.
#setup
OE 1;'
Set the profiler to stop axis upon error
KS 16;'
Set step smoothing
MT -2,-2,-2,-2;'
Motor type set to stepper
YA 2;'
Step resolution of the drive
YB 200;'
Motor resolution (full steps per revolution)
YC 4000;'
Encoder resolution (counts per revolution)
SH A;'
Enable axis
WT 100;'
Allow slight settle time
#motion;'
Perform motion
SP 512;'
Set the speed
PR 1000;'
Prepare mode of motion
BG A;'
Begin motion
EN
End of program subroutine
REM When error occurs, the axis will stop due to OE1. In
REM #POSERR, query the status YS and the error QS, correct,
REM and return to the main code.
#POSERR;'
Automatic subroutine is called when _YS=2
WT 100;'
Wait helps user see the correction
spsave=_SPA;'
Save current speed setting
JP #return,_YSA<>2;'
Return to thread zero if invalid error
SP64;
Set slow speed setting for correction
MG "ERROR= ",_QSA
YRA=_QSA;'
Else, error is valid, use QS for correction
MC A;
Wait for motion to complete
MG "CORRECTED, ERROR NOW= ",_QSX
WT 100;'
Wait helps user see the correction
#return
SPA=spsave;'
Return the speed to previous setting
RE 0;'
Return from #POSERR
Example: Friction Correction
The following example illustrates how the SPM mode can be useful in correcting for X axis friction after each move
when conducting a reciprocating motion. The drive is a 1/64th microstepping drive with a 1.8
o
step motor and
4000 count/rev encoder.
#SETUP;
Set the profiler to continue upon error
KS16;
Set step smoothing
MT-2,-2,-2,-2;
Motor type set to stepper
YA64;
Step resolution of the microstepping drive
YB200;
Motor resolution (full steps per revolution)
YC4000;
Encoder resolution (counts per revolution)
SHX;
Enable axis
WT50;
Allow slight settle time
YS1;
Enable SPM mode
Chapter 6 Programming Motion ▫ 94 DMC-41x3 User Manual