Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # #######################################
- #
- # HAL file for HostMot2 with 3 servos
- #
- # Derived from Ted Hyde's original hm2-servo config
- #
- # Based up work and discussion with Seb & Peter & Jeff
- # GNU license references - insert here. www.linuxcnc.org
- #
- #
- # ########################################
- # 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
- #
- # See also:
- # <http://www.linuxcnc.org/docs/devel/html/man/man9/hostmot2.9.html#config%20modparam>
- # and http://wiki.linuxcnc.org/cgi-bin/emcinfo.pl?HostMot2
- #
- # #####################################################################
- # ###################################
- # 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
- # standard components
- loadrt pid num_chan=4
- # only the 7i43 needs this, but it doesnt hurt the others
- # loadrt probe_parport Removed
- # 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 24000
- setp hm2_[HOSTMOT2](BOARD).0.watchdog.timeout_ns 10000000
- ###### ADDED
- # load real time components
- ##loadrt pid num_chan=2 #loaded line35
- loadrt classicladder_rt
- # numS32in=5 numS32out=5 numPhysInputs=35 numBits=30 numPhysOutputs=22
- loadrt weighted_sum wsum_sizes=4
- loadrt and2 count=6
- loadrt mux4 names=mpg-scale
- loadrt or2 count=6
- loadrt not count=2
- loadrt mult2 count=3
- loadrt mux16
- loadrt time
- loadrt toggle count=2
- loadrt toggle2nist count=2
- # load user space components
- loadusr halui
- loadusr classicladder --nogui hardinge.clp
- # Flood Toggle
- addf and2.5 servo-thread
- addf toggle.1 servo-thread
- addf toggle2nist.1 servo-thread
- # ################################################
- # 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 refers to Y axis
- addf pid.2.do-pid-calcs servo-thread
- #addf pid.3.do-pid-calcs servo-thread
- addf hm2_[HOSTMOT2](BOARD).0.write servo-thread
- # addf hm2_[HOSTMOT2](BOARD).0.pet_watchdog servo-thread Removed
- addf process_wsums servo-thread
- addf classicladder.0.refresh servo-thread
- # ######################################################
- # Axis-of-motion Specific Configs (not the GUI)
- # ######################################################
- #########
- #set scales
- ########
- loadrt scale count=2
- loadrt near
- addf near.0 servo-thread
- # ################
- # 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 => hm2_[HOSTMOT2](BOARD).0.pwmgen.00.enable
- net emcmot.00.enable <= axis.0.amp-enable-out
- setp hm2_[HOSTMOT2](BOARD).0.resolver.00.scale [AXIS_0]INPUT_SCALE
- net motor.00.pos-fb hm2_[HOSTMOT2](BOARD).0.resolver.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_5i23.0.pwmgen.00.output-type 2 #up on pin1, down on pin2
- setp hm2_5i23.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
- # ################
- # Z [2] Axis
- # ################
- # axis enable chain
- newsig emcmot.02.enable bit
- sets emcmot.02.enable FALSE
- net emcmot.02.enable => pid.2.enable
- net emcmot.02.enable => hm2_[HOSTMOT2](BOARD).0.pwmgen.02.enable
- net emcmot.02.enable <= axis.2.amp-enable-out
- setp hm2_[HOSTMOT2](BOARD).0.resolver.02.scale [AXIS_2]INPUT_SCALE
- net motor.02.pos-fb hm2_[HOSTMOT2](BOARD).0.resolver.02.position => pid.2.feedback
- net motor.02.pos-fb => axis.2.motor-pos-fb #push copy back to Axis GUI
- # set PID loop gains from inifile
- setp pid.2.Pgain [AXIS_2]P
- setp pid.2.Igain [AXIS_2]I
- setp pid.2.Dgain [AXIS_2]D
- setp pid.2.bias [AXIS_2]BIAS
- setp pid.2.FF0 [AXIS_2]FF0
- setp pid.2.FF1 [AXIS_2]FF1
- setp pid.2.FF2 [AXIS_2]FF2
- setp pid.2.deadband [AXIS_2]DEADBAND
- setp pid.2.maxoutput [AXIS_2]MAX_OUTPUT
- # position command signals
- setp hm2_[HOSTMOT2](BOARD).0.pwmgen.02.output-type 2 #up on pin1, down on pin2
- setp hm2_[HOSTMOT2](BOARD).0.pwmgen.02.scale [AXIS_2]OUTPUT_SCALE
- net emcmot.02.pos-cmd axis.2.motor-pos-cmd => pid.2.command
- net motor.02.command pid.2.output => hm2_[HOSTMOT2](BOARD).0.pwmgen.02.value
- net home-switch-X axis.0.home-sw-in <= hm2_[HOSTMOT2](BOARD).0.gpio.028.in
- net home-switch-Z axis.2.home-sw-in <= hm2_[HOSTMOT2](BOARD).0.gpio.029.in
- #
- # ##################################################
- # 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
- # set up outputs for 7i37
- setp hm2_5i23.0.gpio.040.is_output 1
- setp hm2_5i23.0.gpio.040.invert_output 1
- setp hm2_5i23.0.gpio.041.is_output 1
- setp hm2_5i23.0.gpio.041.invert_output 1
- setp hm2_5i23.0.gpio.042.is_output 1
- setp hm2_5i23.0.gpio.042.invert_output 1
- setp hm2_5i23.0.gpio.043.is_output 1
- setp hm2_5i23.0.gpio.043.invert_output 1
- setp hm2_5i23.0.gpio.044.is_output 1
- setp hm2_5i23.0.gpio.044.invert_output 1
- setp hm2_5i23.0.gpio.045.is_output 1
- setp hm2_5i23.0.gpio.045.invert_output 1
- setp hm2_5i23.0.gpio.046.is_output 1
- setp hm2_5i23.0.gpio.046.invert_output 1
- setp hm2_5i23.0.gpio.047.is_output 1
- setp hm2_5i23.0.gpio.047.invert_output 1
- setp hm2_5i23.0.gpio.064.is_output 1
- setp hm2_5i23.0.gpio.064.invert_output 1
- # End
- #
- # 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.
- #
- ##ADDED FILES
- # Turn Control On Added Files
- # setp hm2_[HOSTMOT2](BOARD).0.gpio.041.is_output 1
- # setp hm2_[HOSTMOT2](BOARD).0.gpio.041.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
- # net machine-power => hm2_5i23.0.gpio.041
- net machine-power <= motion.motion-enabled =>
- net machine-power => hm2_5i23.0.gpio.040.out
- net machine-power => hm2_5i23.0.gpio.041.out
- # End
- #net home-switch <= hm2_[HOSTMOT2](BOARD).0.gpio.024.in_not
- #net home-switch => axis.0.home-sw-in
- #net home-switch => axis.1.home-sw-in
- #net home-switch => axis.2.home-sw-in
- # only the Y servo has an index, X and Z home without using the index
- net x-index-enable hm2_[HOSTMOT2](BOARD).0.resolver.00.index-enable <=> axis.0.index-enable
- net z-index-enable hm2_[HOSTMOT2](BOARD).0.resolver.02.index-enable <=> axis.2.index-enable
- #net y-index-enable hm2_[HOSTMOT2](BOARD).0.resolver.01.index-enable <=> axis.1.index-enable
- # ---setup home / limit switch signals---
- net x-pos-ot <= hm2_5i23.0.gpio.024.in
- net x-pos-ot axis.0.pos-lim-sw-in
- net x-neg-ot <= hm2_5i23.0.gpio.025.in
- net x-neg-ot axis.0.neg-lim-sw-in
- net z-pos-ot <= hm2_5i23.0.gpio.026.in
- net z-pos-ot axis.2.pos-lim-sw-in
- net z-neg-ot <= hm2_5i23.0.gpio.027.in
- net z-neg-ot axis.2.neg-lim-sw-in
- # Tool Turret Encoder Setup
- #Leave cancelled til rest of info is in
- net turret-encoder1 wsum.0.bit.0.in <= hm2_5i23.0.gpio.030.in_not
- net turret-encoder2 wsum.0.bit.1.in <= hm2_5i23.0.gpio.031.in_not
- net turret-encoder4 wsum.0.bit.2.in <= hm2_5i23.0.gpio.032.in_not
- net turret-encoder8 wsum.0.bit.3.in <= hm2_5i23.0.gpio.033.in_not
- # create signals for tool loading loopback In original Mesa file
- #net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
- #net tool-change-loop iocontrol.0.tool-change => iocontrol.0.tool-changed
- # 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_5i23.0.gpio.046.out <= classicladder.0.out-02
- net tur-lift-spin hm2_5i23.0.gpio.047.out <= classicladder.0.out-03
- net tur-locked hm2_5i23.0.gpio.034.in => 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
- #######
- #Spindle uses resolver.03 and pwmgen.03
- #######
- #spindle scales
- addf scale.0 servo-thread
- addf scale.1 servo-thread
- #10v/6000rpm=0.001667
- #setp scale.0.gain -0.000201 above #/8
- #10v/3000rpm=0.003333 Leave as 1/1
- setp scale.0.gain 0.000275
- # offset for spindle next 2 lines were #
- #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 -2500
- setp limit1.0.max 2500
- #set scale and pwm
- setp hm2_5i23.0.resolver.03.scale 1
- setp hm2_[HOSTMOT2](BOARD).0.pwmgen.03.output-type 2
- 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_5i23.0.pwmgen.03.value
- net spindle-rpm => abs.1.in
- net spindle-speed-abs <= abs.1.out
- #Added from andy
- net spindle-tryout motion.spindle-on => hm2_5i23.0.pwmgen.03.enable
- #net spindle-index-enable <=> hm2_5i23.0.resolver.03.index-enable
- #Added for Meter
- #net spindle-rpm-filtered => pyvcp.spindle-speed
- #net spindle-rpm => pyvcp.spindle-speed
- #net spindle-at-speed => pyvcp.spindle-at-speed
- ## Next secions are brake related - DISABLE
- #spindle enable Next line cleared
- #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_5i23.0.pwmgen.03.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
- ## End of disabled area
- #spindle sync
- net spindle-index motion.spindle-index-enable <= hm2_5i23.0.resolver.03.index-enable
- net spindle-velocity motion.spindle-speed-in <= hm2_5i23.0.resolver.03.velocity
- net spindle-revs motion.spindle-revs <= hm2_5i23.0.resolver.03.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.0.difference 0.15
- net spindle-velocity near.0.in1
- net com-spindle-vel near.0.in2 <= motion.spindle-speed-out-rps
- net spindle-at-speed near.0.out <= motion.spindle-at-speed
- # trick Axis
- net trick-axis motion.spindle-reverse
- #Added Stuff
- #net spindle-index-enable <=> motion.spindle-index-enable -error-already linked
- #######
- #end of spindle
- ######
- # Coolant Pump
- net coolant-pump hm2_5i23.0.gpio.064.out <= iocontrol.0.coolant-flood
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement