'***************************************************************************
'Galil Motion Control Sample DMC Code
'***************************************************************************
'Description:
'Record & Playback example.  Move motors while in a motor off state
'then playback the motion using Contour Mode
'***************************************************************************
#record                         ;'begin program to record
DM xpos[501], ypos[501]         ;'dimension array
RA xpos[], ypos[]               ;'automatic data record
RD _TPA, _TPB                   ;'specify X actual position for capture
MO                              ;'turn motor off for teach
RC 2                            ;'begin recording every 4 ms
MG "RECORDING..."
#a;JP #a, _RC = 1               ;'wait until done recording
MG "DONE"

#playbk                           ;'playback program
  MG "PLAYING..."
  SH                              ;'turn motor on
  CM AB                            ;'contour mode on X
  DT 2                            ;'time interval of 4 ms for all segments
  i = 0                           ;'initialize array counter

  #b                              ;'loop label
    CD xpos[i + 1] - xpos[i], ypos[i + 1] - ypos[i] ;'specify contour distance
    WC                            ;'wait until this contour segment is done
    i = i + 1                     ;'increment counter
  JP #b, i < 500                  ;'loop until done with all segments

  DT 0;CD 0                         ;'turn contour mode off
  MG "DONE"
EN                                ;'end program