rendered paste body# EMCOturn 120P Lathe Hal Configuration
#
loadrt trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
loadrt hostmot2
loadrt hm2_pci config=" num_encoders=1 num_pwmgens=0 num_stepgens=3 sserial_port_0=00xxxx"
setp hm2_5i25.0.watchdog.timeout_ns 5000000
loadrt comp count=2
loadrt timedelay count=2
loadrt and2 count=5
loadrt not count=5
loadrt xor2 count=5
loadrt or2 count=1
loadrt debounce cfg=1,2
# XXX reb
loadrt mux2 count=1
loadrt abs count=1
loadrt mult2 count=1
# XXX
loadusr -W toolerator3000
addf hm2_5i25.0.read servo-thread
# XXX reb
addf mux2.0 servo-thread
addf abs.0 servo-thread
addf mult2.0 servo-thread
# XXX
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf comp.0 servo-thread
addf comp.1 servo-thread
addf timedelay.0 servo-thread
addf timedelay.1 servo-thread
addf and2.0 servo-thread
addf and2.1 servo-thread
addf and2.2 servo-thread
addf and2.3 servo-thread
addf and2.4 servo-thread
addf not.0 servo-thread
addf not.1 servo-thread
addf not.2 servo-thread
addf not.3 servo-thread
addf not.4 servo-thread
addf xor2.0 servo-thread
addf xor2.1 servo-thread
addf xor2.2 servo-thread
addf xor2.3 servo-thread
addf xor2.4 servo-thread
addf or2.0 servo-thread
addf debounce.1 servo-thread
addf hm2_5i25.0.write servo-thread
# ---Chargepump StepGen: 0.25 velocity = 10Khz square wave output---
setp hm2_5i25.0.stepgen.02.dirsetup 100
setp hm2_5i25.0.stepgen.02.dirhold 100
setp hm2_5i25.0.stepgen.02.steplen 100
setp hm2_5i25.0.stepgen.02.stepspace 100
setp hm2_5i25.0.stepgen.02.position-scale 10000
setp hm2_5i25.0.stepgen.02.step_type 2
setp hm2_5i25.0.stepgen.02.control-type 1
setp hm2_5i25.0.stepgen.02.maxaccel 0
setp hm2_5i25.0.stepgen.02.maxvel 0
setp hm2_5i25.0.stepgen.02.velocity-cmd 0.25
net estop-ext hm2_5i25.0.stepgen.02.enable <= hm2_5i25.0.7i84.0.0.input-16
# --- End of Chargepump section----
# --- Pneumatic Control ----
# --- These are the Mesa outputs that drive solenoids for tailstock and collet ---
# --- These are defined/used in custom_postgui.hal with Classic Ladder ---
#net tailstock-rev hm2_5i25.0.7i84.0.0.output-09
#net tailstock-fwd hm2_5i25.0.7i84.0.0.output-10
#net collet-opening hm2_5i25.0.7i84.0.0.output-11
#net collet-close hm2_5i25.0.7i84.0.0.output-12
# --- These lines are setting up the lower pressure switch ---
# --- collet states xor'd to determine that the collet is being operated in order to read low press switch ---
net collet-opening xor2.0.in0
net collet-close xor2.0.in1
# --- "and" that with the pressure switch to signal if pressure is low ---
net colletinuse xor2.0.out and2.1.in0
net low-pressure hm2_5i25.0.7i84.0.0.input-18-not and2.1.in1
net lowairpressure and2.1.out not.1.in
# --- timedelay is a one-shot to draw out signal due to a race condition ---
setp timedelay.1.on-delay 0
setp timedelay.1.off-delay 0.5
net goodairpressure-fast not.1.out timedelay.1.in
net goodairpressure timedelay.1.out and2.2.in0
# This will abort motion if low air pressure during collet operation or spindle overtemp signal
net spindle-overtemp hm2_5i25.0.7i84.0.0.input-17 and2.2.in1
net allsafe and2.2.out motion.enable
# --- End of Pneumatic Control section----
#net gs2-run
#net collet-open-cmd and2.4.in0
#net gs2-run not.4.in
#net gs2-not-running and2.4.in1 not.4.out
#net collet-not-closed and2.3.in0
#net gs2-run and2.3.in1
#net spindle-unsafe or2.0.out not.3.in
#net spindle-safe not.3.out
#net spindle-safe and2.2.in1
#net allsafe and2.2.out motion.enable
#net spindle-danger or2.0.in1 and2.3.out
#net tooltouch hm2_5i25.0.7i84.0.0.input-02-not motion.probe-input
# --- Over Temperature Inputs ---
# --- ** added without testing amp-fault (should cause no X,Z motion if Vexta overheat)
#spindle-overtemp hm2_5i25.0.7i84.0.0.input-17 **see above
net z-axis-overtemp hm2_5i25.0.7i84.0.0.input-19 axis.2.amp-fault-in
net x-axis-overtemp hm2_5i25.0.7i84.0.0.input-20 axis.0.amp-fault-in
# --- End of Over Temperature section----
# --- Run oiler motor when either X or Z axis are moving ---
# --- comparator(s) output comp.N.equal will be 0 if velocity command is above 0 ---
setp comp.0.in0 0
setp comp.0.hyst 0.001
net x-vel-cmd comp.0.in1
#
setp comp.1.in0 0
setp comp.1.hyst 0.001
net z-vel-cmd comp.1.in1
# --- feed comparator output into an AND gate and then invert using NOT ---
# --- so either axis moving will output a logic 1 from NOT ---
net x-vel-actv comp.0.equal and2.0.in0
net z-vel-actv comp.1.equal and2.0.in1
net xorzvel and2.0.out not.0.in
# --- timedelay component keeps output signal high for 5s after at ---
# --- least 1s of movement ---
setp timedelay.0.on-delay 1
setp timedelay.0.off-delay 1
net xorzvel-hold not.0.out timedelay.0.in
# --- send the output to the pin that controls the oiler motor relay ---
net oiler hm2_5i25.0.7i84.0.0.output-08 timedelay.0.out
# --- End of oiler motor section ---
# --- Limit Switches ----
# --- First two switches are settable using the slide mechanism under tailstock ---
#net tail-left-lim hm2_5i25.0.7i84.0.0.input-29
#net tail-over-lim hm2_5i25.0.7i84.0.0.input-30
#net tail-right-lim hm2_5i25.0.7i84.0.0.input-31
# --- These are the hall sensors on the X and Z axes ---
# --- To be used for homing??? ---
#net indexZ hm2_5i25.0.7i84.0.0.input-24
#net indexX hm2_5i25.0.7i84.0.0.input-25
# --- End of Limit Switches section ---
#*******************
# AXIS X
#*******************
# Step Gen signals/setup
setp hm2_5i25.0.stepgen.01.dirsetup [AXIS_0]DIRSETUP
setp hm2_5i25.0.stepgen.01.dirhold [AXIS_0]DIRHOLD
setp hm2_5i25.0.stepgen.01.steplen [AXIS_0]STEPLEN
setp hm2_5i25.0.stepgen.01.stepspace [AXIS_0]STEPSPACE
setp hm2_5i25.0.stepgen.01.position-scale [AXIS_0]STEP_SCALE
setp hm2_5i25.0.stepgen.01.step_type 0
setp hm2_5i25.0.stepgen.01.control-type 1
setp hm2_5i25.0.stepgen.01.maxaccel [AXIS_0]STEPGEN_MAXACCEL
setp hm2_5i25.0.stepgen.01.maxvel [AXIS_0]STEPGEN_MAXVEL
# ---closedloop stepper signals---
net x-pos-cmd <= axis.0.motor-pos-cmd
net x-pos-cmd => hm2_5i25.0.stepgen.01.position-cmd
net x-vel-cmd <= axis.0.joint-vel-cmd
net x-vel-cmd => hm2_5i25.0.stepgen.01.velocity-cmd
net x-pos-fb <= axis.0.motor-pos-fb
net x-pos-fb => hm2_5i25.0.stepgen.01.position-fb
net x-enable <= axis.0.amp-enable-out
net x-enable => hm2_5i25.0.stepgen.01.enable
# ---setup home / limit switch signals---
#net x-home-sw => axis.0.home-sw-in hm2_5i25.0.7i84.0.0.input-25
#net x-neg-limit => axis.0.neg-lim-sw-in
#net x-pos-limit => axis.0.pos-lim-sw-in
#*******************
# AXIS Z
#*******************
# Step Gen signals/setup
setp hm2_5i25.0.stepgen.00.dirsetup [AXIS_2]DIRSETUP
setp hm2_5i25.0.stepgen.00.dirhold [AXIS_2]DIRHOLD
setp hm2_5i25.0.stepgen.00.steplen [AXIS_2]STEPLEN
setp hm2_5i25.0.stepgen.00.stepspace [AXIS_2]STEPSPACE
setp hm2_5i25.0.stepgen.00.position-scale [AXIS_2]STEP_SCALE
setp hm2_5i25.0.stepgen.00.step_type 0
setp hm2_5i25.0.stepgen.00.control-type 1
setp hm2_5i25.0.stepgen.00.maxaccel [AXIS_2]STEPGEN_MAXACCEL
setp hm2_5i25.0.stepgen.00.maxvel [AXIS_2]STEPGEN_MAXVEL
# ---closedloop stepper signals---
net z-pos-cmd <= axis.2.motor-pos-cmd
net z-pos-cmd => hm2_5i25.0.stepgen.00.position-cmd
net z-vel-cmd <= axis.2.joint-vel-cmd
net z-vel-cmd => hm2_5i25.0.stepgen.00.velocity-cmd
net z-pos-fb <= axis.2.motor-pos-fb
net z-pos-fb => hm2_5i25.0.stepgen.00.position-fb
net z-enable <= axis.2.amp-enable-out
net z-enable => hm2_5i25.0.stepgen.00.enable
# ---setup home / limit switch signals---
#net z-home-sw => axis.2.home-sw-in hm2_5i25.0.7i84.0.0.input-24
#net z-neg-limit => axis.2.neg-lim-sw-in
#net z-pos-limit => axis.2.pos-lim-sw-in
#*******************
# SPINDLE S
#*******************
# ---Encoder feedback signals/setup---
setp hm2_5i25.0.encoder.00.counter-mode 0
#setp hm2_5i25.0.encoder.00.filter 1
setp hm2_5i25.0.encoder.00.index-invert 0
setp hm2_5i25.0.encoder.00.index-mask 0
setp hm2_5i25.0.encoder.00.index-mask-invert 0
setp hm2_5i25.0.encoder.00.scale [SPINDLE_9]ENCODER_SCALE
# XXX reb
setp mux2.0.in0 1
setp mux2.0.in1 -1
# spindle rotating in reverse will pick -1, otherwise 1
net spindle-reversed <= motion.spindle-reverse => mux2.0.sel
# send mux output (1 or -1) to a multiplier
net spindle-revs-multiplier <= mux2.0.out => mult2.0.in0
# compute ABS(encoder position) in case it is negative
net spindle-revs-raw <= hm2_5i25.0.encoder.00.position => abs.0.in
# take ABS(encoder position) and multiply it by mux output above
# position is now negative for reverse, positive otherwise
net spindle-revs-abs <= abs.0.out => mult2.0.in1
# send recomputed position to motion component
net spindle-revs-signed <= mult2.0.out => motion.spindle-revs
#net spindle-revs <= hm2_5i25.0.encoder.00.position => motion.spindle-revs
# XXX
net spindle-vel-fb-rps <= hm2_5i25.0.encoder.00.velocity => motion.spindle-speed-in
net spindle-index-enable <=> hm2_5i25.0.encoder.00.index-enable <=> motion.spindle-index-enable
net spindle-index <= hm2_5i25.0.encoder.00.input-index
# ---setup spindle control signals---
#net spindle-vel-cmd-rps <= motion.spindle-speed-out-rps
#net spindle-vel-cmd-rps-abs <= motion.spindle-speed-out-rps-abs
#net spindle-vel-cmd-rpm <= motion.spindle-speed-out
#net spindle-vel-cmd-rpm-abs <= motion.spindle-speed-out-abs
#net spindle-enable <= motion.spindle-on
#net spindle-cw <= motion.spindle-forward
#net spindle-ccw <= motion.spindle-reverse
#net spindle-brake <= motion.spindle-brake
#net spindle-revs => motion.spindle-revs
#net spindle-at-speed => motion.spindle-at-speed
#net spindle-vel-fb-rps => motion.spindle-speed-in
#net spindle-index-enable <=> motion.spindle-index-enable
# ---Setup spindle at speed signals---
#sets spindle-at-speed true
# Use ACTUAL spindle velocity from spindle encoder
# spindle-velocity bounces around so we filter it with lowpass
# spindle-velocity is signed so we use absolute component to remove sign
# ACTUAL velocity is in RPS not RPM so we scale it.
#setp scale.spindle.gain 60
#setp lowpass.spindle.gain 1.000000
#net spindle-vel-fb-rps => scale.spindle.in
#net spindle-fb-rpm scale.spindle.out => abs.spindle.in
#et spindle-fb-rpm-abs abs.spindle.out => lowpass.spindle.in
#net spindle-fb-rpm-abs-filtered lowpass.spindle.out
#******************************
# connect miscellaneous signals
#******************************
# ---HALUI signals---
net joint-select-a halui.joint.0.select
net x-is-homed halui.joint.0.is-homed
net jog-x-pos halui.jog.0.plus
net jog-x-neg halui.jog.0.minus
net jog-x-analog halui.jog.0.analog
net joint-select-c halui.joint.2.select
net z-is-homed halui.joint.2.is-homed
net jog-z-pos halui.jog.2.plus
net jog-z-neg halui.jog.2.minus
net jog-z-analog halui.jog.2.analog
net jog-selected-pos halui.jog.selected.plus
net jog-selected-neg halui.jog.selected.minus
net spindle-manual-cw halui.spindle.forward
net spindle-manual-ccw halui.spindle.reverse
net spindle-manual-stop halui.spindle.stop
net machine-is-on halui.machine.is-on
net jog-speed halui.jog-speed
net MDI-mode halui.mode.is-mdi
# ---coolant signals---
net coolant-mist <= iocontrol.0.coolant-mist
net coolant-flood <= iocontrol.0.coolant-flood
# ---probe signal---
net probe-in hm2_5i25.0.7i84.0.0.input-02-not motion.probe-input
# ---motion control signals---
# see custom_postgui.hal
# ---digital in / out signals---
# ---estop signals---
net estop-out <= iocontrol.0.user-enable-out
net estop-ext => iocontrol.0.emc-enable-in
# ---tool change signals---
net tool-change iocontrol.0.tool-change => toolerator3000.toolchange
net tool-changed iocontrol.0.tool-changed <= toolerator3000.toolchanged
net tool-number iocontrol.0.tool-prep-number => toolerator3000.toolnumber
net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared