# ####################################### # # HAL file for HostMot2 with 2 servos # # # ######################################## # Firmware files are in /lib/firmware/hm2/ # # ##################################################################### # ################################### # Core EMC/HAL Loads # ################################### # kinematics loadrt [KINS]KINEMATICS # motion controller, get name and thread periods from ini file loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS # standard components loadrt pid num_chan=3 # 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 driver loadrt [HOSTMOT2](DRIVER) config=[HOSTMOT2](CONFIG) # setp hm2_[HOSTMOT2](BOARD).0.pwmgen.pwm_frequency 40000 # setp hm2_[HOSTMOT2](BOARD).0.pwmgen.0.scale 3500 loadrt classicladder_rt numPhysInputs=15 numPhysOutputs=15 numS32in=10 numS32out=10 numFloatIn=10 numFloatOut=10 # turret shenanigans loadrt tristate_bit # spindle speed - near AND ABS loadrt near loadrt abs count=1 # thangs for pause/resume button loadrt and2 count=3 loadrt or2 count=6 loadrt toggle count=1 loadrt toggle2nist count=1 # mpg loadrt mux4 names=mpg-scale # handwheel loadrt mux16 count=1 # feed overide loadrt ilowpass # handwheel loadrt orient # bldc setup loadrt bldc cfg=iq,iq # incremental enc and quadrature encoder setp bldc.0.initvalue 20.0 # 1/2 full scale current during alignment setp bldc.0.scale -4096 # counts per turn setp bldc.0.poles 8 setp bldc.0.init 1 setp bldc.0.lead-angle 0 setp bldc.0.encoder-offset -1877 # this value returned by +u, -vw 1877 setp bldc.1.initvalue 20.0 # 1/2 full scale current during alignment setp bldc.1.scale -4096 # counts per turn setp bldc.1.poles 8 setp bldc.1.init 1 setp bldc.1.lead-angle 0 setp bldc.1.encoder-offset 781 # this value returned by +u, -vw 781 # ################################################ # 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 pid.2.do-pid-calcs servo-thread addf hm2_[HOSTMOT2](BOARD).0.write servo-thread addf bldc.0 servo-thread addf bldc.1 servo-thread addf classicladder.0.refresh servo-thread addf tristate-bit.0 servo-thread addf near.0 servo-thread addf abs.0 servo-thread addf and2.0 servo-thread addf and2.1 servo-thread addf and2.2 servo-thread # SPINDLE BRAKE INTERLOCK addf or2.0 servo-thread addf toggle.0 servo-thread addf toggle2nist.0 servo-thread addf mpg-scale servo-thread addf ilowpass.0 servo-thread addf or2.1 servo-thread addf or2.2 servo-thread addf or2.3 servo-thread addf or2.4 servo-thread addf or2.5 servo-thread addf mux16.0 servo-thread addf orient.0 servo-thread #spindle orientation # ###################################################### # Axis-of-motion Specific Configs (not the GUI) # ###################################################### # ################ # X [0] Axis # ################ # axis enable chain newsig emcmot.00.enable bit sets emcmot.00.enable FALSE net emcmot.00.enable => pid.0.enable net emcmot.00.enable <= joint.0.amp-enable-out # bldc stuff #pos command stuff net emcmot.00.pos-cmd joint.0.motor-pos-cmd => pid.0.command net motor.00.command pid.0.output => bldc.0.value net motor.00.current bldc.0.out => hm2_5i22.0.8i20.0.4.current # commutation angle signals net motor.00.rawcounts hm2_[HOSTMOT2](BOARD).0.encoder.00.rawcounts => bldc.0.rawcounts net motor.00.index-enable hm2_[HOSTMOT2](BOARD).0.encoder.00.index-enable => bldc.0.index-enable net motor.00.index-enable joint.0.index-enable net motor.00.angle bldc.0.rotor-angle => hm2_5i22.0.8i20.0.4.angle net motor.00.pos-fb hm2_[HOSTMOT2](BOARD).0.encoder.00.position => pid.0.feedback net motor.00.pos-fb => joint.0.motor-pos-fb #push copy back to Axis GUI # 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 [JOINT_0]INPUT_SCALE # 7i37 boards -3rd and 4th header initialization setp hm2_5i22.0.gpio.040.is_output 1 setp hm2_5i22.0.gpio.040.invert_output 1 setp hm2_5i22.0.gpio.041.is_output 1 setp hm2_5i22.0.gpio.041.invert_output 1 setp hm2_5i22.0.gpio.042.is_output 1 setp hm2_5i22.0.gpio.042.invert_output 1 setp hm2_5i22.0.gpio.043.is_output 1 setp hm2_5i22.0.gpio.043.invert_output 1 setp hm2_5i22.0.gpio.044.is_output 1 setp hm2_5i22.0.gpio.044.invert_output 1 setp hm2_5i22.0.gpio.045.is_output 1 setp hm2_5i22.0.gpio.045.invert_output 1 setp hm2_5i22.0.gpio.046.is_output 1 setp hm2_5i22.0.gpio.046.invert_output 1 setp hm2_5i22.0.gpio.047.is_output 1 setp hm2_5i22.0.gpio.047.invert_output 1 setp hm2_5i22.0.gpio.064.is_output 1 setp hm2_5i22.0.gpio.064.invert_output 1 setp hm2_5i22.0.gpio.065.is_output 1 setp hm2_5i22.0.gpio.065.invert_output 1 setp hm2_5i22.0.gpio.066.is_output 1 setp hm2_5i22.0.gpio.066.invert_output 1 setp hm2_5i22.0.gpio.067.is_output 1 setp hm2_5i22.0.gpio.067.invert_output 1 setp hm2_5i22.0.gpio.068.is_output 1 setp hm2_5i22.0.gpio.068.invert_output 1 setp hm2_5i22.0.gpio.069.is_output 1 setp hm2_5i22.0.gpio.069.invert_output 1 setp hm2_5i22.0.gpio.070.is_output 1 setp hm2_5i22.0.gpio.070.invert_output 1 setp hm2_5i22.0.gpio.071.is_output 1 setp hm2_5i22.0.gpio.071.invert_output 1 # net air1 => hm2_5i22.0.gpio.064.out # set PID loop gains from inifile setp pid.0.Pgain [JOINT_0]P setp pid.0.Igain [JOINT_0]I setp pid.0.Dgain [JOINT_0]D setp pid.0.bias [JOINT_0]BIAS setp pid.0.FF0 [JOINT_0]FF0 setp pid.0.FF1 [JOINT_0]FF1 setp pid.0.FF2 [JOINT_0]FF2 setp pid.0.deadband [JOINT_0]DEADBAND setp pid.0.maxoutput [JOINT_0]MAX_OUTPUT # ################ # Z [1] Axis # ################ # axis enable chain newsig emcmot.01.enable bit sets emcmot.01.enable FALSE net emcmot.01.enable => pid.1.enable net emcmot.01.enable <= joint.1.amp-enable-out # bldc stuff #pos command stuff net emcmot.01.pos-cmd joint.1.motor-pos-cmd => pid.1.command net motor.01.command pid.1.output => bldc.1.value net motor.01.current bldc.1.out => hm2_5i22.0.8i20.0.5.current net motor.01.pos-fb hm2_[HOSTMOT2](BOARD).0.encoder.01.position => pid.1.feedback net motor.01.pos-fb => joint.1.motor-pos-fb #push copy back to Axis GUI # commutation angle signals net motor.01.rawcounts hm2_[HOSTMOT2](BOARD).0.encoder.01.rawcounts => bldc.1.rawcounts net motor.01.index-enable hm2_[HOSTMOT2](BOARD).0.encoder.01.index-enable => bldc.1.index-enable net motor.01.index-enable joint.1.index-enable net motor.01.angle bldc.1.rotor-angle => hm2_5i22.0.8i20.0.5.angle # 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 [JOINT_1]INPUT_SCALE # set PID loop gains from inifile setp pid.1.Pgain [JOINT_1]P setp pid.1.Igain [JOINT_1]I setp pid.1.Dgain [JOINT_1]D setp pid.1.bias [JOINT_1]BIAS setp pid.1.FF0 [JOINT_1]FF0 setp pid.1.FF1 [JOINT_1]FF1 setp pid.1.FF2 [JOINT_1]FF2 setp pid.1.deadband [JOINT_1]DEADBAND setp pid.1.maxoutput [JOINT_1]MAX_OUTPUT # ################ # C [2] Axis # ################ # axis enable chain newsig emcmot.02.enable bit sets emcmot.02.enable FALSE # STEPPER stuff #pos command stuff # net motor.02.pos-fb => joint.2.motor-pos-fb #push copy back to Axis GUI net emcmot.02.pos-fb hm2_5i22.0.stepgen.00.position-fb => pid.2.feedback net emcmot.02.pos-cmd hm2_5i22.0.stepgen.00.position-cmd => pid.2.command net emcmot.02.pos-fb => joint.2.motor-pos-fb #push copy back to Axis GUI # set PID loop gains from inifile setp pid.2.Pgain [JOINT_2]P setp pid.2.Igain [JOINT_2]I setp pid.2.Dgain [JOINT_2]D setp pid.2.bias [JOINT_2]BIAS setp pid.2.FF0 [JOINT_2]FF0 setp pid.2.FF1 [JOINT_2]FF1 setp pid.2.FF2 [JOINT_2]FF2 setp pid.2.deadband [JOINT_2]DEADBAND setp pid.2.maxoutput [JOINT_2]MAX_OUTPUT setp pid.2.error-previous-target true # limit bogus stepgen velocity corrections setp pid.2.maxerror 0.02 # net joint.2.index-enable <=> pid.2.index-enable net emcmot.02.enable => pid.2.enable net emcmot.02.enable <= joint.2.amp-enable-out # net joint.2.pos-cmd => pid.2.command # net joint.2.pos-fb => pid.2.feedback net joint.2.output <= pid.2.output # stepgen signals setp hm2_5i22.0.stepgen.00.control-type 1 #################################################### # SPINDLE #################################################### setp hm2_[HOSTMOT2](BOARD).0.encoder.02.counter-mode 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.02.filter 1 setp hm2_[HOSTMOT2](BOARD).0.encoder.02.index-invert 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.02.index-mask 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.02.index-mask-invert 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.02.scale 4096 net spindle-position hm2_5i22.0.encoder.02.position => spindle.0.revs net spindle-velocity hm2_5i22.0.encoder.02.velocity => spindle.0.speed-in net spindle-index-enable hm2_5i22.0.encoder.02.index-enable <=> spindle.0.index-enable net spindle-enable spindle.0.on => hm2_5i22.0.7i72.0.1.output-14 net spindle-reverse spindle.0.reverse => hm2_5i22.0.7i72.0.1.output-20 net sp-speed-value spindle.0.speed-out => classicladder.0.floatin-03 net spindle-faster hm2_5i22.0.7i72.0.1.output-19 <= classicladder.0.out-01 net spindle-slower hm2_5i22.0.7i72.0.1.output-18 <= classicladder.0.out-14 net spindle-encoder-speed hm2_5i22.0.encoder.02.velocity-rpm => classicladder.0.floatin-04 net sp-rvs spindle.0.speed-out-abs => near.0.in1 net spindle-encoder-speed => abs.0.in net unsigned-spindle near.0.in2 <= abs.0.out net spindle-at-speed spindle.0.at-speed <= near.0.out # set the spindle speed tolerance -percentage setp near.0.scale 1.10 # SPINDLE BRAKE LINKED TO AN AND2.2 WITH SPINDLE ENABLE net spbrake spindle.0.brake => hm2_5i22.0.gpio.069.out net spindle-position => orient.0.position net fan-ctrl halui.spindle.0.is-on => classicladder.0.in-07 net motor-fan classicladder.0.out-00 => hm2_5i22.0.7i72.0.1.output-15 #################################################### # tool turret encoder setup #################################################### 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 setp hm2_[HOSTMOT2](BOARD).0.encoder.03.scale 4 # ################################################## # Contactors/relays # ################################################## # conveyor # net conv-rev <= hm2_5i22.0.7i72.0.1.output-02 # net conv-fwd <= hm2_5i22.0.7i72.0.1.output-03 # turret index net index-fwd <= hm2_5i22.0.7i72.0.1.output-04 net index-rev <= hm2_5i22.0.7i72.0.1.output-05 # other contactors/relays #net lube-pump <= hm2_5i22.0.7i72.0.1.output-09 #net hydraulic-pump <= hm2_5i22.0.7i72.0.1.output-07 #net oil-seperator <= hm2_5i22.0.7i72.0.1.output-06 net coolant iocontrol.0.coolant-flood <= hm2_5i22.0.7i72.0.1.output-08 net turret-lock-pin <= hm2_5i22.0.7i72.0.1.output-17 net turret-motor-lock <= hm2_5i22.0.7i72.0.1.output-16 #################################################### ## Input signals/pushbuttons # tailstock buttons or m code m102/m103 net tstock-out or2.4.in0 <= hm2_5i22.0.7i73.0.3.input-11-not # tailstock out net tailstock-out => or2.4.in1 net tailstock-out1 or2.4.out => hm2_5i22.0.7i72.0.1.output-27 net tailstock-out1 => hm2_5i22.0.7i72.0.1.output-28 net tstock-in or2.5.in0 <= hm2_5i22.0.7i73.0.3.input-10-not # tailstock retract net tailstock-in => or2.5.in1 net tailstock-in1 or2.5.out => hm2_5i22.0.7i72.0.1.output-26 net tailstock-in1 => hm2_5i22.0.7i72.0.1.output-24 # chuck-pedal or m100/m101 net man-chk or2.3.in0 <= hm2_5i22.0.7i84.0.0.input-06 # left foot pedal net chuck-pedal => or2.3.in1 net chk-out or2.3.out => hm2_5i22.0.7i72.0.1.output-25 # chuck solenoid # net Foot-pedal-RHS <= hm2_5i22.0.7i84.0.0.input-07 #THIS NEEDS TO BE A TOGGLE FOR SPINDLE BRAKE RELEASE net hyd-pump-on <= hm2_5i22.0.7i84.0.0.input-01 net oil-low <= hm2_5i22.0.7i84.0.0.input-02 net turret-temp <= hm2_5i22.0.7i84.0.0.input-16-not net turret-lock <= hm2_5i22.0.7i84.0.0.input-17 # create a signal for the estop loopback net estop-out <= iocontrol.0.user-enable-out net E-stop-active halui.machine.off <= hm2_5i22.0.7i84.0.0.input-03 net estop-out => iocontrol.0.emc-enable-in net estop-out <= hm2_5i22.0.7i72.0.1.output-00 # Slideway oil pump # net iocontrol.0.lube # net slide-oil halui.lube.on <= hm2_5i22.0.7i72.0.1.output-09 net pwr-on halui.machine.on <= hm2_5i22.0.7i84.0.0.input-00 net pwr-on => hm2_5i22.0.7i72.0.1.output-01 # pgm run/pause buttons net start_button halui.program.run <= hm2_5i22.0.7i73.0.3.input-15-not net stop_button halui.program.stop <= hm2_5i22.0.7i73.0.3.input-14-not net pause-resume-btn and2.0.in0 and2.1.in0 <= hm2_5i22.0.7i73.0.3.input-13-not net pause-on toggle2nist.0.is-on and2.0.in1 <= halui.program.is-paused net run-on and2.1.in1 <= halui.program.is-running net pause-sig or2.0.in0 <= and2.0.out net resume-sig or2.0.in1 <= and2.1.out net toggle-ok toggle.0.in <= or2.0.out net togglesig toggle2nist.0.in <= toggle.0.out net toggleon halui.program.pause <= toggle2nist.0.on net toggleoff halui.program.resume <= toggle2nist.0.off # mpg setp ilowpass.0.gain 0.02 setp ilowpass.0.scale 1 setp mpg-scale.in0 -0.0001 setp mpg-scale.in1 -0.001 setp mpg-scale.in2 -0.01 setp mpg-scale.in3 -0.1 net jog-smoothing ilowpass.0.in <= hm2_5i22.0.7i73.0.3.enc0.count net jog-position <= ilowpass.0.out net jog-position => axis.x.jog-counts net jog-position => axis.z.jog-counts # net scale1 or2.1.in0 <= hm2_5i22.0.7i73.0.3.input-05-not # net scale2 or2.2.in0 <= hm2_5i22.0.7i73.0.3.input-06-not # net scale3 or2.1.in1 or2.2.in1 <= hm2_5i22.0.7i73.0.3.input-07-not net pos0 mpg-scale.sel0 <= or2.1.out net pos1 mpg-scale.sel1 <= or2.2.out # net pos2 mpg-scale.sel2 <= or2.1.out # net pos3 mpg-scale.sel3 <= or2.2.out net axis-mpg-jog-scale axis.x.jog-scale <= mpg-scale.out net axis-mpg-jog-scale axis.z.jog-scale <= mpg-scale.out # feedrate overide # 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 10 setp mux16.0.in02 20 setp mux16.0.in03 30 setp mux16.0.in04 40 setp mux16.0.in05 50 setp mux16.0.in06 60 setp mux16.0.in07 70 setp mux16.0.in08 80 setp mux16.0.in09 90 setp mux16.0.in10 100 setp mux16.0.in11 110 setp mux16.0.in12 120 setp mux16.0.in13 130 setp mux16.0.in14 140 setp mux16.0.in15 150 net bin-switch0 mux16.0.sel0 <= hm2_5i22.0.7i73.0.3.input-00-not net bin-switch1 mux16.0.sel1 <= hm2_5i22.0.7i73.0.3.input-01-not net bin-switch2 mux16.0.sel2 <= hm2_5i22.0.7i73.0.3.input-02-not net bin-switch3 mux16.0.sel3 <= hm2_5i22.0.7i73.0.3.input-03-not net bin-switch-result halui.feed-override.counts <= mux16.0.out-s net main-enable <= halui.machine.is-on net main-enable => hm2_5i22.0.7i72.0.1.output-13 # servo power net main-enable => hm2_5i22.0.7i72.0.1.output-11 # x-enable net main-enable => hm2_5i22.0.7i72.0.1.output-12 # z-enable net main-enable => hm2_5i22.0.7i72.0.1.output-07 # hyd-enable net switchx axis.x.jog-enable <= hm2_5i22.0.7i73.0.3.input-12-not net switchz axis.z.jog-enable <= hm2_5i22.0.7i73.0.3.input-12 ################################################################# # **** Setup for ladder program -START **** net indexT tristate-bit.0.out => hm2_5i22.0.encoder.03.index-enable net indexIn tristate-bit.0.in <= classicladder.0.out-05 net indexE tristate-bit.0.enable <= classicladder.0.out-06 net indexT classicladder.0.in-04 net turret-pos-count hm2_5i22.0.encoder.03.position => classicladder.0.floatin-00 net turret-lock-pin <= classicladder.0.out-07 net turret-motor-lock <= classicladder.0.out-08 net turret-temp classicladder.0.in-05 net turret-lock classicladder.0.in-06 net index-fwd <= classicladder.0.out-03 net index-rev <= classicladder.0.out-04 # **** Setup for ladder program -END **** # create signals for tool loading loopback net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared net tool-change-start iocontrol.0.tool-change => classicladder.0.in-03 net tool-change-done classicladder.0.out-10 iocontrol.0.tool-changed net tool-num-next iocontrol.0.tool-prep-number => classicladder.0.s32in-01 net tool-num-current iocontrol.0.tool-number => classicladder.0.s32in-02 # # homing # # # In this example, each of the three axes have their own home switch. All # home switches are connected to GPIO 25, though hostmot2 boards generally # have enough GPIO pins to put each axis' home switch on its own pin # Each switch is normally open, momentarily closed. When the switch is open, # GPIO 25 floats high (because that is the hostmot2 way). When the switch is # closed, it shorts GPIO 25 to ground. # # EMC expects the value on the .home-sw-in HAL pin to be active high, ie # True when the switch is closed and False when the switch is open. # We get this behavior by linking the GPIO .in_not pin instead of the .in # pin. # net home-switch-x <= hm2_5i22.0.7i84.0.0.input-05-not net home-switch-z <= hm2_5i22.0.7i84.0.0.input-04-not net home-switch-x => joint.0.home-sw-in net home-switch-z => joint.1.home-sw-in # keypad matrix loadrt matrix_kb config=8x8 addf matrix_kb.0 servo-thread -2 net key-input hm2_5i22.0.7i73.0.3.keycode => matrix_kb.0.keycode # Load Classicladder without GUI (can reload LADDER GUI in AXIS GUI loadusr classicladder --modmaster shenyang.clp