# 2.5 RIP test # Firmware files are in /lib/firmware/hm2/7i43/ # Must symlink the hostmot2 firmware directory of sanbox to # /lib/firmware before running EMC2... # sudo ln -s $HOME/emc2-sandbox/src/hal/drivers/mesa-hostmot2/firmware /lib/firmware/hm2 # ################################### # Core EMC/HAL Loads # ################################### # kinematics loadrt trivkins # motion controller, get name and thread periods from ini file loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES # hostmot2 driver # if you have any firmware trouble, enable the debug flags here and see what's going on in the syslog #loadrt hostmot2 debug_idrom=1 debug_module_descriptors=1 debug_pin_descriptors=1 debug_modules=1 loadrt hostmot2 # load low-level HosMot2 driver loadrt [HOSTMOT2](DRIVER) config=[HOSTMOT2](CONFIG) setp hm2_[HOSTMOT2](BOARD).0.pwmgen.pwm_frequency 40000 setp hm2_[HOSTMOT2](BOARD).0.watchdog.timeout_ns 10000000 # load real time components loadrt pid num_chan=2 loadrt classicladder_rt # numS32in=5 numS32out=5 numPhysInputs=35 numBits=30 numPhysOutputs=22 loadrt weighted_sum wsum_sizes=4 loadrt and2 count=5 loadrt mux4 names=mpg-scale loadrt or2 count=5 loadrt not count=1 loadrt mult2 count=3 loadrt mux16 # axis enable addf and2.0 servo-thread # spindle enable addf and2.1 servo-thread # remote program run/resume addf and2.2 servo-thread # remote program pause addf and2.3 servo-thread addf and2.4 servo-thread # MPG scale addf or2.0 servo-thread addf or2.1 servo-thread # Spindle Brake addf or2.2 servo-thread addf not.0 servo-thread # Spindle Speed addf mult2.0 servo-thread # MPG Jog Speeds addf mpg-scale servo-thread # Feed Override Knob addf mux16.0 servo-thread # Collet Closer addf or2.3 servo-thread addf or2.4 servo-thread # Way Oiler addf mult2.2 servo-thread # load user space components loadusr halui loadusr classicladder --nogui hardinge.clp # ################################################ # THREADS # ################################################ addf hm2_[HOSTMOT2](BOARD).0.read servo-thread addf motion-command-handler servo-thread addf motion-controller servo-thread addf pid.0.do-pid-calcs servo-thread addf pid.1.do-pid-calcs servo-thread addf hm2_[HOSTMOT2](BOARD).0.write servo-thread addf hm2_[HOSTMOT2](BOARD).0.pet_watchdog servo-thread addf process_wsums servo-thread addf classicladder.0.refresh servo-thread # ###################################################### # Axis-of-motion Specific Configs (not the GUI) # ###################################################### # Cycle Timer # This creates a 1Hz signal loadrt pwmgen output_type=0 # This will count the 1Hz signals loadrt encoder num_chan=1 # and this looks for a change in program.is-running to reset the timer loadrt edge count=1 addf pwmgen.make-pulses servo-thread addf encoder.update-counters servo-thread #addf stepgen.update-freq servo-thread addf pwmgen.update servo-thread addf encoder.capture-position servo-thread addf edge.0 servo-thread setp pwmgen.0.pwm-freq 1 setp pwmgen.0.scale 1 setp pwmgen.0.offset 0 setp pwmgen.0.value 0.5 setp encoder.0.counter-mode 1 setp edge.0.in-edge false net run-timer halui.program.is-running => pwmgen.0.enable edge.0.in net OneHzPulse pwmgen.0.pwm => encoder.0.phase-A net timer-reset edge.0.out => encoder.0.reset ######### #set scales ######## loadrt scale count=5 #servos velocity to mm/min addf scale.2 servo-thread addf scale.3 servo-thread addf scale.4 servo-thread setp scale.2.gain 60 setp scale.3.gain 60 setp scale.4.gain 60 loadrt near count=3 addf near.0 servo-thread addf near.1 servo-thread addf near.2 servo-thread # ################ # X [0] Axis uses encoder.00 and pwmgen.00 # ################ # axis enable chain newsig emcmot.00.enable bit sets emcmot.00.enable FALSE net emcmot.00.enable => pid.0.enable net emcmot.00.enable => hm2_[HOSTMOT2](BOARD).0.pwmgen.00.enable net emcmot.00.enable <= axis.0.amp-enable-out net emcmot.00.enable => and2.0.in0 # encoder feedback setp hm2_[HOSTMOT2](BOARD).0.encoder.00.counter-mode 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.00.filter 1 setp hm2_[HOSTMOT2](BOARD).0.encoder.00.index-invert 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.00.index-mask 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.00.index-mask-invert 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.00.scale [AXIS_0]INPUT_SCALE net motor.00.pos-fb hm2_[HOSTMOT2](BOARD).0.encoder.00.position => pid.0.feedback net motor.00.pos-fb => axis.0.motor-pos-fb #push copy back to Axis GUI # set PID loop gains from inifile setp pid.0.Pgain [AXIS_0]P setp pid.0.Igain [AXIS_0]I setp pid.0.Dgain [AXIS_0]D setp pid.0.bias [AXIS_0]BIAS setp pid.0.FF0 [AXIS_0]FF0 setp pid.0.FF1 [AXIS_0]FF1 setp pid.0.FF2 [AXIS_0]FF2 setp pid.0.deadband [AXIS_0]DEADBAND setp pid.0.maxoutput [AXIS_0]MAX_OUTPUT # position command signals setp hm2_[HOSTMOT2](BOARD).0.pwmgen.00.output-type 1 #pwm on pin1, dir on pin2 setp hm2_[HOSTMOT2](BOARD).0.pwmgen.00.scale [AXIS_0]OUTPUT_SCALE net emcmot.00.pos-cmd axis.0.motor-pos-cmd => pid.0.command net motor.00.command pid.0.output => hm2_[HOSTMOT2](BOARD).0.pwmgen.00.value # connect the X home switch net home-switch-X axis.0.home-sw-in <= hm2_[HOSTMOT2](BOARD).0.gpio.038.in_not net X-index axis.0.index-enable hm2_[HOSTMOT2](BOARD).0.encoder.00.index-enable # ################ # Z [2] Axis uses encoder.01 and pwmgen.01 # ################ # axis enable chain newsig emcmot.01.enable bit sets emcmot.01.enable FALSE net emcmot.01.enable => pid.1.enable net emcmot.01.enable => hm2_[HOSTMOT2](BOARD).0.pwmgen.01.enable net emcmot.01.enable <= axis.1.amp-enable-out net emcmot.01.enable => and2.0.in1 # encoder feedback setp hm2_[HOSTMOT2](BOARD).0.encoder.01.counter-mode 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.01.filter 1 setp hm2_[HOSTMOT2](BOARD).0.encoder.01.index-invert 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.01.index-mask 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.01.index-mask-invert 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.01.scale [AXIS_2]INPUT_SCALE net motor.01.pos-fb hm2_[HOSTMOT2](BOARD).0.encoder.01.position => pid.1.feedback net motor.01.pos-fb => axis.2.motor-pos-fb #push copy back to Axis GUI # set PID loop gains from inifile setp pid.1.Pgain [AXIS_2]P setp pid.1.Igain [AXIS_2]I setp pid.1.Dgain [AXIS_2]D setp pid.1.bias [AXIS_2]BIAS setp pid.1.FF0 [AXIS_2]FF0 setp pid.1.FF1 [AXIS_2]FF1 setp pid.1.FF2 [AXIS_2]FF2 setp pid.1.deadband [AXIS_2]DEADBAND setp pid.1.maxoutput [AXIS_2]MAX_OUTPUT # position command signals setp hm2_[HOSTMOT2](BOARD).0.pwmgen.01.output-type 1 #pwm on pin1, dir on pin2 setp hm2_[HOSTMOT2](BOARD).0.pwmgen.01.scale [AXIS_2]OUTPUT_SCALE net emcmot.02.pos-cmd axis.2.motor-pos-cmd => pid.1.command net motor.02.command pid.1.output => hm2_[HOSTMOT2](BOARD).0.pwmgen.01.value net axis-drive-enable and2.0.out => hm2_[HOSTMOT2](BOARD).0.gpio.068.out # connect the Z home switch net home-switch-Z axis.2.home-sw-in <= hm2_[HOSTMOT2](BOARD).0.gpio.034.in_not net Z-index axis.2.index-enable hm2_5i20.0.encoder.01.index-enable ####### #Spindle uses encoder.02 and pwmgen.02 ####### #spindle scales addf scale.0 servo-thread addf scale.1 servo-thread #10v/6000rpm=0.001667 setp scale.0.gain -0.0002 # offset for spindle #setp scale.0.offset 0.0001loadrt pwmgen output_type=0 # This creates a 1Hz signal setp scale.1.gain 60 #load abs comp make spindle RPM pos loadrt abs count=3 addf abs.0 servo-thread addf abs.1 servo-thread addf abs.2 servo-thread #spindle speed out limits loadrt limit1 count=1 addf limit1.0 servo-thread setp limit1.0.min -6000 setp limit1.0.max 6000 #set scale and pwm setp hm2_5i20.0.encoder.02.scale -4096 setp hm2_[HOSTMOT2](BOARD).0.pwmgen.02.output-type 1 net spindle-speed-limit motion.spindle-speed-out => limit1.0.in net spindle-speed-limit-out limit1.0.out => scale.0.in net spindle-speed-DAC scale.0.out => hm2_5i20.0.pwmgen.02.value net spindle-rpm => abs.1.in net spindle-speed-abs <= abs.1.out #spindle enable net spindle-enable-req motion.spindle-on => and2.1.in0 net spindle-brake-sensor hm2_5i20.0.gpio.051.in_not => and2.1.in1 net spindle-enable and2.1.out => hm2_5i20.0.pwmgen.02.enable # enable spindle drive net spindle-enable => hm2_5i20.0.gpio.065.out # force spindle lock pin out net spindle-enable => hm2_5i20.0.gpio.042.out # release spindle brake net spindle-brake-prg not.0.out => or2.2.in0 net spindle-brake-logic motion.spindle-brake => not.0.in net spindle-brake hm2_5i20.0.gpio.040.out <= or2.2.out #spindle sync net spindle-index motion.spindle-index-enable <= hm2_5i20.0.encoder.02.index-enable net spindle-velocity motion.spindle-speed-in <= hm2_5i20.0.encoder.02.velocity net spindle-revs motion.spindle-revs <= hm2_5i20.0.encoder.02.position net spindle-velocity => abs.0.in net spindle-v-abs abs.0.out => scale.1.in net spindle-v-abs-out <= scale.1.out # spindle speed net spindle-velocity mult2.0.in0 setp mult2.0.in1 60 net spindle-abs abs.2.in mult2.0.out net spindle-rpm abs.2.out # spindle at speed setp near.2.difference 0.1 net spindle-velocity near.2.in1 net com-spindle-vel near.2.in2 <= motion.spindle-speed-out-rps net spindle-at-speed near.2.out <= motion.spindle-at-speed ####### #end of spindle ###### # ################################################## # Standard I/O Block - EStop, Etc # ################################################## # create a signal for the estop loopback net estop-loop iocontrol.0.user-enable-out <= iocontrol.0.emc-enable-in # net estop-external iocontrol.0.emc-enable-in <= hm2_5i20.0.gpio.055.in_not # set up outputs for 7i37 cards JT setp hm2_5i20.0.gpio.040.is_output 1 setp hm2_5i20.0.gpio.040.invert_output 1 setp hm2_5i20.0.gpio.041.is_output 1 setp hm2_5i20.0.gpio.041.invert_output 1 setp hm2_5i20.0.gpio.042.is_output 1 setp hm2_5i20.0.gpio.042.invert_output 1 setp hm2_5i20.0.gpio.043.is_output 1 setp hm2_5i20.0.gpio.043.invert_output 1 setp hm2_5i20.0.gpio.044.is_output 1 setp hm2_5i20.0.gpio.044.invert_output 1 setp hm2_5i20.0.gpio.045.is_output 1 setp hm2_5i20.0.gpio.045.invert_output 1 setp hm2_5i20.0.gpio.046.is_output 1 setp hm2_5i20.0.gpio.046.invert_output 1 setp hm2_5i20.0.gpio.047.is_output 1 setp hm2_5i20.0.gpio.047.invert_output 1 setp hm2_5i20.0.gpio.064.is_output 1 setp hm2_5i20.0.gpio.064.invert_output 1 setp hm2_5i20.0.gpio.065.is_output 1 setp hm2_5i20.0.gpio.065.invert_output 1 setp hm2_5i20.0.gpio.066.is_output 1 setp hm2_5i20.0.gpio.066.invert_output 1 setp hm2_5i20.0.gpio.067.is_output 1 setp hm2_5i20.0.gpio.067.invert_output 1 setp hm2_5i20.0.gpio.068.is_output 1 setp hm2_5i20.0.gpio.068.invert_output 1 setp hm2_5i20.0.gpio.069.is_output 1 setp hm2_5i20.0.gpio.069.invert_output 1 setp hm2_5i20.0.gpio.070.is_output 1 setp hm2_5i20.0.gpio.070.invert_output 1 setp hm2_5i20.0.gpio.071.is_output 1 setp hm2_5i20.0.gpio.071.invert_output 1 # pull the CR-1 relay in when the Power Button is on JT net machine-power <= motion.motion-enabled => # CR-1 Control Power net machine-power => hm2_5i20.0.gpio.046.out # Spindle E-Stop In net machine-power => hm2_5i20.0.gpio.067.out # Axis Drive Enable net machine-power => hm2_5i20.0.gpio.071.out # Tool Turret Encoder Setup net turret-encoder1 wsum.0.bit.0.in <= hm2_5i20.0.gpio.063.in_not net turret-encoder2 wsum.0.bit.1.in <= hm2_5i20.0.gpio.061.in_not net turret-encoder4 wsum.0.bit.2.in <= hm2_5i20.0.gpio.059.in_not net turret-encoder8 wsum.0.bit.3.in <= hm2_5i20.0.gpio.057.in_not # Tool Turret tool change, leave the tool prep loop in as there is no prep needed net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared #net tool-change-loop iocontrol.0.tool-change => iocontrol.0.tool-changed net tool-cng-req iocontrol.0.tool-change => classicladder.0.in-01 net tool-cn-done iocontrol.0.tool-changed <= classicladder.0.out-01 net tool-number iocontrol.0.tool-number => classicladder.0.s32in-00 net tool-prep-number iocontrol.0.tool-prep-number => classicladder.0.s32in-01 net tur-stop hm2_5i20.0.gpio.069.out <= classicladder.0.out-02 net tur-lift-spin hm2_5i20.0.gpio.066.out <= classicladder.0.out-03 net tur-locked hm2_5i20.0.gpio.033.in_not => classicladder.0.in-02 net enc-tool-number wsum.0.sum => classicladder.0.s32in-02 net tool-cng-timeout classicladder.0.out-04 => halui.program.stop # Limit Switches net z-pos-ot axis.2.pos-lim-sw-in <= hm2_[HOSTMOT2](BOARD).0.gpio.024.in_not net z-neg-ot axis.2.neg-lim-sw-in <= hm2_[HOSTMOT2](BOARD).0.gpio.026.in_not net x-pos-ot axis.0.pos-lim-sw-in <= hm2_[HOSTMOT2](BOARD).0.gpio.028.in_not net x-neg-ot axis.0.neg-lim-sw-in <= hm2_[HOSTMOT2](BOARD).0.gpio.030.in_not # MPG encoder feedback setp hm2_[HOSTMOT2](BOARD).0.encoder.03.counter-mode 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.03.filter 1 setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-invert 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-mask 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-mask-invert 0 net mpg-count hm2_5i20.0.encoder.03.count net mpg-count => axis.0.jog-counts net mpg-count => axis.2.jog-counts setp mpg-scale.in0 .000025 setp mpg-scale.in1 .00025 setp mpg-scale.in2 .0025 net mpg-x axis.0.jog-enable <= hm2_[HOSTMOT2](BOARD).0.gpio.054.in_not net mpg-z axis.2.jog-enable <= hm2_[HOSTMOT2](BOARD).0.gpio.052.in_not # MPG Scale # set the MPG scale based on the inputs from the selector switch net pos2 mpg-scale.sel0 <= hm2_[HOSTMOT2](BOARD).0.gpio.037.in_not net pos3 mpg-scale.sel1 <= hm2_[HOSTMOT2](BOARD).0.gpio.035.in_not net axis-mpg-jog-scale axis.0.jog-scale <= mpg-scale.out net axis-mpg-jog-scale axis.2.jog-scale <= mpg-scale.out # Feed Override setp mux16.0.suppress-no-input true setp halui.feed-override.count-enable true setp halui.feed-override.direct-value true setp halui.feed-override.scale 0.01 setp mux16.0.in00 0 setp mux16.0.in01 0 setp mux16.0.in02 10 setp mux16.0.in03 20 setp mux16.0.in04 30 setp mux16.0.in05 40 setp mux16.0.in06 50 setp mux16.0.in07 60 setp mux16.0.in08 70 setp mux16.0.in09 80 setp mux16.0.in10 90 setp mux16.0.in11 100 setp mux16.0.in12 110 setp mux16.0.in13 120 net ext-fork0 mux16.0.sel0 <= hm2_5i20.0.gpio.062.in_not net ext-fork1 mux16.0.sel1 <= hm2_5i20.0.gpio.060.in_not net ext-fork2 mux16.0.sel2 <= hm2_5i20.0.gpio.058.in_not net ext-fork3 mux16.0.sel3 <= hm2_5i20.0.gpio.056.in_not net ext-fork halui.feed-override.counts <= mux16.0.out-s # External Program Run Button net program-run-btn halui.mode.auto <= hm2_5i20.0.gpio.031.in_not net program-run-btn and2.2.in0 net program-is-auto and2.2.in1 <= halui.mode.is-auto net remote-prg-run halui.program.run <= and2.2.out # External Program Pause Button #net program-pause-btn and2.3.in0 and2.3.in0 <= hm2_5i20.0.gpio.029.in_not #net program-is-running and2.3.in1 halui.program.is-running #net pause-program halui.program.pause <= and2.3.out #net program-is-paused and2.4.in1 halui.program.is-paused #net resume-program halui.program.resume <= and2.4.out net feed-hold-btn motion.feed-hold <= hm2_5i20.0.gpio.029.in_not # External Collet Open/Close Buttons net collet-open-btn or2.3.in0 <= hm2_5i20.0.gpio.027.in_not net collet-close-btn or2.4.in0 <= hm2_5i20.0.gpio.025.in_not net collet-open hm2_5i20.0.gpio.043.out <= or2.3.out net collet-close hm2_5i20.0.gpio.041.out <= or2.4.out # Way Oiler setp mult2.2.in0 1000 net mult-vel mult2.2.in1 <= motion.current-vel net in-motion classicladder.0.floatin-00 <= mult2.2.out net oil-on hm2_5i20.0.gpio.045.out <= classicladder.0.out-07 # Coolant Pump net coolant-pump hm2_5i20.0.gpio.047.out <= iocontrol.0.coolant-flood