'***************************************************************************
'Galil Motion Control Sample DMC Code
'***************************************************************************
'Description:
'Cut To Length example code
'***************************************************************************
#AUTO                                 ;'label for autostart
IN "ENTER CUT LENGTH IN INCHES",l     ;'prompt for operator
IN "ENTER NUMBER OF CUTS",n           ;'prompt for operator

#wait                                 ;'label for wait
JP #wait, @IN[1] = 0                  ;'wait until input 1 is high

c = 0                                 ;'initialize cut counter

#loop                                 ;'label for loop
  MG "LOOP"
  PR l * 5000                         ;'convert inches to counts
  SP 60000                            ;'speed in counts/sec
  AC 1000000                          ;'acceleration in counts/sec2bg
  BG A                                ;'begin motion
  AM A                                ;'wait for motion complete
  SB 2                                ;'activate cutter, set output 2 high
  WT 200                              ;'wait 200 ms
  CB 2                                ;'deactivate cutter, clear output 2
  c = c + 1                           ;'increment cut counter
  JP #e, c >= n                       ;'exit if done
JP #loop, @IN[1] = 1                  ;'repeat if input 1 is still high

#e                                    ;'exit
EN                                    ;'end program