'Stop Ethernet port section
WA(5000) ' 5 sec delay-warm up
ETHERCAT(0,0) 'ethercat running command

RUN "CLEAR_UNIT_ALARM" 'calling sub routine
RUN "AXISALARM", 9 'calling sub routine
RUN "COMMAND", 8 'calling sub routine

DIM i AS INTEGER
FOR i = 0 TO 0
    BASE(i)
    'to reverse motor direction (CCW)
    'ENCODER_RATIO(-1,1) 'This command allows the incoming encoder count to be scaled by a non integer ratio
    'STEP_RATIO(-1,1) 'This command sets up an integer ratio for the axis’ demanded positon

    UNITS = 2 ^ 20
    SPEED = 10 '600RPM
    JOGSPEED = 5 '300RPM
    ACCEL = 100
    DECEL = ACCEL
    CREEP = 0.1
    'REP_DIST = 360
    'REP_OPTION = 0
    DRIVE_FE_LIMIT = 100 '100turn - per revolution
    FE_LIMIT = 100 'the maximum following error
    FE_RANGE = 70 ' following error report range - shows in status
    FS_LIMIT = 400000000000
    RS_LIMIT = -400000000000
    AXIS_ENABLE = ON ' enable the axis in controller
    SERVO AXIS(i) = ON 'run the axis in controller
    'DEFPOS(0) ' get zero value
NEXT i

IF ETHERCAT($22,0,-1) THEN 'Get EtherCAT State
    TABLE(100,1) ' make success initial flage for EtherCAT Operational state
ENDIF

WAIT UNTIL PROC_STATUS PROC(8) = 1
PRINT "Axis Added & Command Ready!"
