'***************************************************************************
'Galil Motion Control Sample DMC Code
'Filename: LimitBounce.dmc
'***************************************************************************
'Description:
'This program bounces the X-axis back and forth between two limit switches
'
'***************************************************************************
'When Forward=1, motion is traveling in positive direction
'When Forward=-1, motion is traveling in negative direction
'Speed of move is determined by Speed variable
#a
  speed= 10000
  forward= 1
  AI 5; 'Wait for input 5 to trigger before starting motion
#move
  JGA= speed*forward
  BG A
  v1= TIME; 'Jog motor for 8 seconds, if limit isn't hit - Stop and End.
#loop
  WT 50
  delta= TIME-v1
  JP #loop,delta<8000
  ST A;AM A
EN
#LIMSWI
  ST A
  AM A
  'WAIT 2 seconds after hitting limit
  WT 2000
  IF forward=1
    forward= -1
  ELSE
    forward= 1
  ENDIF
  ZS;                   'Zero Subroutine Stack
  JP #move
EN