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
- loadrt and2 count=2
- # motion controller, get name and thread periods from ini file
- loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
- #thread for classicladder ~10ms
- #thread for gui display stuff ~60ms
- loadrt threads name1=classicladder-thread period1=2000000 name2=gui-thread period2=20000000
- # standard components
- loadrt pid num_chan=3
- #setup classic ladder stuff
- #set in and out values
- loadrt classicladder_rt numS32in=7 numS32out=7 numPhysInputs=35 numBits=30 numPhysOutputs=22
- #set classic ladder refresh
- addf classicladder.0.refresh classicladder-thread
- loadusr -w classicladder --nogui hnc.clp
- # 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.watchdog.timeout_ns 10000000
- _____________________________________________________________________________________________________
- ini file
- _____________________________________________________________________________________________________
- [HOSTMOT2]
- DRIVER=hm2_pci
- BOARD=5i20
- CONFIG="firmware=hm2/5i20/SVST8_4.BIT num_encoders=3 num_pwmgens=3 num_stepgens=0"
- [EMC]
- # Name of machine, for use with display, etc.
- MACHINE = HM2-Servo
- # Name of NML file to use, default is emc.nml
- #NML_FILE = emc.nml
- # Debug level, 0 means no messages. See src/emc/nml_int/emcglb.h for others
- #DEBUG = 0x00000003
- #DEBUG = 0x00000007
- DEBUG = 0
- [DISPLAY]
- # Name of display program, e.g., tkemc
- DISPLAY = axis
- LATHE = 1
- PYVCP = hm2-servo.xml
- #PYVCP = spindle-spd.xml
- #PYVCP = hm2-servo.xml
- # Cycle time, in seconds, that display will sleep between polls
- CYCLE_TIME = 0.0500
- # Path to help file
- HELP_FILE = tkemc.txt
- # Initial display setting for position, RELATIVE or MACHINE
- POSITION_OFFSET = RELATIVE
- # Initial display setting for position, COMMANDED or ACTUAL
- POSITION_FEEDBACK = ACTUAL
- # Highest value that will be allowed for feed override, 1.0 = 100%
- MAX_FEED_OVERRIDE = 1.5
- # Prefix to be used
- PROGRAM_PREFIX = /home/daniel/linuxcnc/nc_files
- EDITOR = gedit
- # Introductory graphic
- INTRO_GRAPHIC = emc2.gif
- INTRO_TIME = 1
- [TASK]
- # Name of task controller program, e.g., milltask
- TASK = milltask
- # Cycle time, in seconds, that task controller will sleep between polls
- CYCLE_TIME = 0.010
- [RS274NGC]
- # File containing interpreter variables
- PARAMETER_FILE = hm2-servo.var
- RS274NGC_STARTUP_CODE = G18 G7
- [EMCMOT]
- EMCMOT = motmod
- # Timeout for comm to emcmot, in seconds
- COMM_TIMEOUT = 1.0
- # Interval between tries to emcmot, in seconds
- COMM_WAIT = 0.010
- # Servo task period, in nanoseconds
- SERVO_PERIOD = 1000000
- [HAL]
- # The run script first uses halcmd to execute any HALFILE
- # files, and then to execute any individual HALCMD commands.
- # list of hal config files to run through halcmd
- # files are executed in the order in which they appear
- HALFILE = hm2-servo.hal
- HALUI= halui
- POSTGUI_HALFILE = gearchanger_to_pyvcp.hal
- # list of halcmd commands to execute
- # commands are executed in the order in which they appear
- #HALCMD = save neta
- [TRAJ]
- AXES = 3
- # COORDINATES = X Y Z R P W
- COORDINATES = X Z
- HOME = 0 0 0 0
- LINEAR_UNITS = inch
- ANGULAR_UNITS = degree
- CYCLE_TIME = 0.010
- DEFAULT_VELOCITY = 2.0
- MAX_VELOCITY = 3.3333334
- DEFAULT_ACCELERATION = 20.0
- MAX_ACCELERATION = 20.0
- [AXIS_0]
- TYPE = LINEAR
- MAX_VELOCITY = 3.3333334
- MAX_ACCELERATION = 20.0
- BACKLASH = 0.000
- FERROR = 0.0012
- MIN_FERROR = 0.002
- INPUT_SCALE = -204800
- OUTPUT_SCALE = -10.000
- OUTPUT_OFFSET = 0
- MAX_OUTPUT = 8.5
- MIN_LIMIT = -5.0
- MAX_LIMIT = 0.05
- HOME = 0.000
- HOME_OFFSET = -0.25
- HOME_SEARCH_VEL = 0.15
- HOME_LATCH_VEL = 0.05
- # the X axis servo's encoder does not have an index channel, so we have to home without index
- HOME_USE_INDEX = YES
- HOME_IGNORE_LIMITS = YES
- # PID tuning params
- DEADBAND = 0.000015
- P = 350.
- I = 0.000
- D = 0.5
- FF0 = 0.000
- FF1 = 1.7
- FF2 = 0.0
- BIAS = 0.000
- [AXIS_2]
- TYPE = LINEAR
- MAX_VELOCITY = 3.3333334
- MAX_ACCELERATION = 20.0
- BACKLASH = 0.0019
- FERROR = 0.001
- MIN_FERROR = 0.002
- INPUT_SCALE = -204800
- OUTPUT_SCALE = -10.000
- OUTPUT_OFFSET = 0
- MAX_OUTPUT = 8.5
- MIN_LIMIT = -12.8
- MAX_LIMIT = 0.05
- HOME = 0.0
- HOME_OFFSET = -2.8
- HOME_SEARCH_VEL = 0.15
- HOME_LATCH_VEL = 0.05
- # the Z axis servo's encoder does not have an index channel, so we have to home without index
- HOME_USE_INDEX = YES
- HOME_IGNORE_LIMITS = YES
- # PID tuning params
- DEADBAND = 0.000015
- P = 400.
- I = 0.000
- D = 0.5
- FF0 = 0.000
- FF1 = 2.1
- FF2 = 0.0
- BIAS = 0.000
- [EMCIO]
- # Name of IO controller program, e.g., io
- EMCIO = io
- # cycle time, in seconds
- CYCLE_TIME = 0.100
- # tool table file
- TOOL_TABLE = tool.tbl
- TOOL_CHANGE_POSITION = 0 0 0
- # ################################################
- # 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 hm2_[HOSTMOT2](BOARD).0.pet_watchdog servo-thread
- addf and2.0 servo-thread
- addf and2.1 servo-thread
- #load weighted sum for turret decodes
- loadrt weighted_sum wsum_sizes=4
- addf process_wsums servo-thread
- setp wsum.0.offset 0
- # ######################################################
- # 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 => hm2_[HOSTMOT2](BOARD).0.pwmgen.00.enable hm2_[HOSTMOT2](BOARD).0.gpio.064.out
- net emcmot.00.enable <= axis.0.amp-enable-out
- # 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
- # ################
- # 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
- # encoder feedback
- 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 [AXIS_2]INPUT_SCALE
- net motor.02.pos-fb hm2_[HOSTMOT2](BOARD).0.encoder.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 1 #pwm on pin1, dir 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
- # ##################################################
- # 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
- # create signals for tool loading loopback
- setp hm2_[HOSTMOT2](BOARD).0.gpio.048.is_output 0
- setp hm2_[HOSTMOT2](BOARD).0.gpio.050.is_output 0
- setp hm2_[HOSTMOT2](BOARD).0.gpio.052.is_output 0
- setp hm2_[HOSTMOT2](BOARD).0.gpio.054.is_output 0
- setp hm2_[HOSTMOT2](BOARD).0.gpio.056.is_output 0
- setp hm2_[HOSTMOT2](BOARD).0.gpio.022.is_opendrain 0
- setp hm2_[HOSTMOT2](BOARD).0.gpio.064.is_output 1
- setp hm2_[HOSTMOT2](BOARD).0.gpio.064.invert_output true
- setp hm2_[HOSTMOT2](BOARD).0.gpio.065.is_output 1
- setp hm2_[HOSTMOT2](BOARD).0.gpio.065.invert_output true
- setp hm2_[HOSTMOT2](BOARD).0.gpio.066.is_output 1
- setp hm2_[HOSTMOT2](BOARD).0.gpio.066.invert_output true
- setp hm2_[HOSTMOT2](BOARD).0.gpio.067.is_output 1
- setp hm2_[HOSTMOT2](BOARD).0.gpio.067.invert_output true
- setp hm2_[HOSTMOT2](BOARD).0.gpio.068.is_output 1
- setp hm2_[HOSTMOT2](BOARD).0.gpio.068.invert_output true
- setp hm2_[HOSTMOT2](BOARD).0.gpio.069.is_output 1
- setp hm2_[HOSTMOT2](BOARD).0.gpio.069.invert_output true
- setp hm2_[HOSTMOT2](BOARD).0.gpio.070.is_output 1
- setp hm2_[HOSTMOT2](BOARD).0.gpio.070.invert_output true
- setp hm2_[HOSTMOT2](BOARD).0.gpio.071.is_output 1
- setp hm2_[HOSTMOT2](BOARD).0.gpio.071.invert_output true
- setp hm2_[HOSTMOT2](BOARD).0.gpio.024.is_output 0
- setp hm2_[HOSTMOT2](BOARD).0.gpio.026.is_output 0
- setp hm2_[HOSTMOT2](BOARD).0.gpio.028.is_output 0
- setp hm2_[HOSTMOT2](BOARD).0.gpio.030.is_output 0
- setp hm2_[HOSTMOT2](BOARD).0.gpio.032.is_output 0
- #spindle control section############################################################################################
- net Spindlefwd motion.spindle-forward => hm2_[HOSTMOT2](BOARD).0.gpio.065.out
- # motion.spindle-at-speed
- #net Spindlerev motion.spindle-reverse => hm2_[HOSTMOT2](BOARD).0.gpio.065.out
- #net Spindlebrake motion.spindle-brake => hm2_[HOSTMOT2](BOARD).0.gpio.067.out
- net flood-control iocontrol.0.coolant-flood => hm2_[HOSTMOT2](BOARD).0.gpio.067.out
- setp hm2_[HOSTMOT2](BOARD).0.pwmgen.01.scale 750
- setp hm2_[HOSTMOT2](BOARD).0.pwmgen.01.output-type 1
- # Spindle gear selection code.
- loadrt toggle count=2
- loadrt not count=2
- loadrt gearchange count=1
- addf toggle.0 servo-thread
- addf toggle.1 servo-thread
- addf not.0 servo-thread
- addf not.1 servo-thread
- addf gearchange.0 servo-thread
- setp toggle.0.debounce 0
- setp gearchange.0.min1 150
- setp gearchange.0.max1 600
- setp gearchange.0.min2 575
- setp gearchange.0.max2 3000
- setp gearchange.0.scale2 3.85
- loadrt near
- addf near.0 servo-thread
- net spindle-cmd motion.spindle-speed-out-rps near.0.in1
- net spindle-velocity near.0.in2
- net spindle-at-speed motion.spindle-at-speed <= near.0.out
- setp near.0.scale 10
- # we're not controlling the direction with the gearchanger, so reverse isn't set
- # and the dir-in and dir-out pins aren't linked
- net spindle-speed-raw motion.spindle-speed-out gearchange.0.speed-in
- net spindle-speed gearchange.0.speed-out hm2_[HOSTMOT2](BOARD).0.pwmgen.01.value
- #net spindle-speed-link motion.spindle-speed-out-rps motion.spindle-speed-in
- setp hm2_[HOSTMOT2](BOARD).0.encoder.01.counter-mode 1
- 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 1000
- net spindle-position hm2_[HOSTMOT2](BOARD).0.encoder.01.position => motion.spindle-revs
- net spindle-velocity hm2_[HOSTMOT2](BOARD).0.encoder.01.velocity => motion.spindle-speed-in
- net spindle-index-enable hm2_[HOSTMOT2](BOARD).0.encoder.01.index-enable <=> motion.spindle-index-enable
- net spindle-on motion.spindle-on hm2_[HOSTMOT2](BOARD).0.pwmgen.01.enable
- #####
- #turrets
- #####
- ################
- # Decode for turrets
- ################
- # Tool 1 2 3 4 5 6 7 8
- # BitD 0 0 0 0 0 0 0 1
- # BitC 0 0 0 1 1 1 1 0
- # BitB 0 1 1 0 0 1 1 0
- # BitA 1 0 1 0 1 0 1 0
- ################
- #turret bit ins
- #t1
- net t1-bit0 wsum.0.bit.0.in <= hm2_[HOSTMOT2](BOARD).0.gpio.056.in
- net t1-bit1 wsum.0.bit.1.in <= hm2_[HOSTMOT2](BOARD).0.gpio.050.in
- net t1-bit2 wsum.0.bit.2.in <= hm2_[HOSTMOT2](BOARD).0.gpio.052.in
- net t1-bit3 wsum.0.bit.3.in <= hm2_[HOSTMOT2](BOARD).0.gpio.054.in
- net turret1-num wsum.0.sum => classicladder.0.s32in-00
- #TURRET UP SWITCH INPUT
- net turret1-down classicladder.0.in-20 <= hm2_[HOSTMOT2](BOARD).0.gpio.032.in_not
- #turret relays
- #turret1
- net raise-t1 classicladder.0.out-09 <= hm2_[HOSTMOT2](BOARD).0.gpio.071.out
- net stop-t1 classicladder.0.out-11 <= hm2_[HOSTMOT2](BOARD).0.gpio.070.out
- #called number output
- net prep-num classicladder.0.s32in-01 <= iocontrol.0.tool-prep-number
- #TRUE when a tool change is requested
- net tool_change classicladder.0.in-22 <= iocontrol.0.tool-change
- #TRUE when a tool change is completed
- net tool_changed iocontrol.0.tool-changed <= classicladder.0.out-07
- #TRUE when a tool prepare is requested
- net tool_prep classicladder.0.in-23 <= iocontrol.0.tool-prepare
- #TRUE when a tool prepare is completed
- net tool_preped iocontrol.0.tool-prepared <= classicladder.0.out-08
- net program-running halui.program.is-running classicladder.0.in-07
- net program-is-auto halui.mode.is-auto classicladder.0.in-08
- #####
- #end turrets
- #####
- #
- # homing
- #
- net X-home and2.1.out axis.0.home-sw-in
- net x-fine hm2_[HOSTMOT2](BOARD).0.gpio.028.in_not => and2.1.in1
- net x-course hm2_[HOSTMOT2](BOARD).0.gpio.030.in_not => and2.1.in0
- net z-fine hm2_[HOSTMOT2](BOARD).0.gpio.024.in_not => and2.0.in1
- net z-course hm2_[HOSTMOT2](BOARD).0.gpio.026.in_not => and2.0.in0
- net z-home and2.0.out 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.encoder.00.index-enable <=> axis.0.index-enable
- net z-index-enable hm2_[HOSTMOT2](BOARD).0.encoder.02.index-enable <=> axis.2.index-enable
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement