; This demonstrates doing T select tool command ; remapped to a named oword sub ; ; to activate, incantate as follows in the ini file: ; [RS274NGC] ; # remap T to a named oword subroutine. ; # The tool number will be passed as parameter #1 ; # The pocket number will be passed as parameter #2 ; ; T_COMMAND=ocall ; ; on success, return the pocket number to commit the prepare ; ;----------------- ; emulate the tool-number/tool-prepare/tool-prepared logic of the iocontrol- ; based toolchanger ; O sub (DEBUG,tdemo.ngc: #1 #2) ; O if ; trigger error to test error reporting ; test fail-change line from gladevcp M66 P2 L0 O if [#5399 EQ 1] (DEBUG, returning -1 to fail prepare) O return [-1] O endif ; ; number of seconds to wait for 'tool-prepared' equivalent ; if timing out, fail the prepare and stop the program # = 5 ; ; ; set analog output pin #0 to signal the tool number ; iocontrol.tool-prep-number becomes motion.analog-out-00 M68 E0 Q[#1] (DEBUG, set tool number on motion.analog-out-00: #1) ; ; set analog output pin #1 to signal the pocket number ; iocontrol.tool-prep-pocket becomes motion.analog-out-01 M68 E1 Q[#2] (DEBUG, set pocket number on motion.analog-out-01: #2) ; ; ; assert the equivalent of the iocontrol.tool-prepare pin ; which is now motion.digital-out-00 M64 P0 (DEBUG, motion.digital-out-00 set high, waiting for motion.digital-in-00) ; ; ; wait for the equivalent of the iocontrol.tool-prepared pin to go high ; we use motion.digital-in-00 ; M66 P0 L3 Q# ; O if [#5399 LT 0] (DEBUG, timeout waiting for 'prepared' to become true - failing prepare ) M65 P0 O return [-2] O endif ; test fail-change line from gladevcp once more in case it became active ; while waiting for prepared: M66 P2 L0 O if [#5399 EQ 1] (DEBUG, returning -1 to fail prepare) M65 P0 (debug, turned off prepare) O return [-3] O endif ; all went well (DEBUG, deasserting motion.digital-out-00) ; M65 P0 ; (DEBUG, done with prepare sub) ; succeed prepare by passing the pocket number as return value ; a negative return value leaves the interpreter state untouched ; and fail with an error message: ; "Tx prepare failed () ; O endsub [#2] m2