Import LinuxCNC source tree

This commit is contained in:
Wang Dequan
2026-08-20 06:17:39 +08:00
commit 2c814634c3
9429 changed files with 10556013 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
net jogA parport.0.pin-10-in => encoder.1.phase-A
net jogB parport.0.pin-11-in => encoder.1.phase-B
net jogX axisui.jog.x => joint.0.jog-enable
net jogY axisui.jog.y => joint.1.jog-enable
net jogZ axisui.jog.z => joint.2.jog-enable
net jogcounts encoder.1.counts => joint.0.jog-counts joint.1.jog-counts joint.2.jog-counts
sets jogscale .00002
net jogscale joint.0.jog-scale
net jogscale joint.1.jog-scale
net jogscale joint.2.jog-scale

View File

@@ -0,0 +1,224 @@
# HAL config file for MAX NC test machine
#######################################################
# first load all the HAL modules we're going to need
#######################################################
# kinematics
loadrt [KINS]KINEMATICS
# main motion controller module
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
# using steppers....
loadrt stepgen step_type=0,0,0,0
# I/O thru the parport
loadrt hal_parport cfg="0x0378"
# counting the spindle encoder in software
loadrt encoder num_chan=2
# simulate the encoder
loadrt sim_encoder num_chan=1
# misc blocks needed to do fun things
loadrt ddt count=8
#######################################################
# add realtime functions to the threads
# first the high speed thread
#######################################################
# first we read parport inputs
addf parport.0.read base-thread
addf sim-encoder.make-pulses base-thread
# update encoder counter
addf encoder.update-counters base-thread
# generate step and dir signals
addf stepgen.make-pulses base-thread
# write to outputs
addf parport.0.write base-thread
# now the servo thread
########################################################
# capture axis and spindle positions
addf stepgen.capture-position servo-thread
addf encoder.capture-position servo-thread
# process motion commands coming from user space
addf motion-command-handler servo-thread
# run main motion controller
addf motion-controller servo-thread
# differentiators to make vel and acc signals
addf ddt.0 servo-thread
addf ddt.1 servo-thread
addf ddt.2 servo-thread
addf ddt.3 servo-thread
addf ddt.4 servo-thread
addf ddt.5 servo-thread
addf ddt.6 servo-thread
addf ddt.7 servo-thread
# update output info, axis and spindle
addf stepgen.update-freq servo-thread
addf sim-encoder.update-speed servo-thread
#######################################################
# interconnections
#
# first, the basic stepper machine connections
#######################################################
# connect position commands from motion module to step generator
net Xpos-cmd <= joint.0.motor-pos-cmd
net Xpos-cmd => stepgen.0.position-cmd
net Ypos-cmd <= joint.1.motor-pos-cmd
net Ypos-cmd => stepgen.1.position-cmd
net Zpos-cmd <= joint.2.motor-pos-cmd
net Zpos-cmd => stepgen.2.position-cmd
net Apos-cmd <= joint.3.motor-pos-cmd
net Apos-cmd => stepgen.3.position-cmd
# connect position feedback from step generators
# to motion module
net Xpos-fb <= stepgen.0.position-fb
net Xpos-fb => joint.0.motor-pos-fb
net Ypos-fb <= stepgen.1.position-fb
net Ypos-fb => joint.1.motor-pos-fb
net Zpos-fb <= stepgen.2.position-fb
net Zpos-fb => joint.2.motor-pos-fb
net Apos-fb <= stepgen.3.position-fb
net Apos-fb => joint.3.motor-pos-fb
# connect enable signals for step generators
net Xen <= joint.0.amp-enable-out
net Xen => stepgen.0.enable
net Yen <= joint.1.amp-enable-out
net Yen => stepgen.1.enable
net Zen <= joint.2.amp-enable-out
net Zen => stepgen.2.enable
net Aen <= joint.3.amp-enable-out
net Aen => stepgen.3.enable
# connect signals to step pulse generator outputs
net Xstep <= stepgen.0.step
net Xdir <= stepgen.0.dir
net Ystep <= stepgen.1.step
net Ydir <= stepgen.1.dir
net Zstep <= stepgen.2.step
net Zdir <= stepgen.2.dir
net Astep <= stepgen.3.step
net Adir <= stepgen.3.dir
# 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
net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed
# create a signal for "spindle on"
net spindle_on <= motion.spindle-on
# connect physical pins to the signals
net Xstep => parport.0.pin-03-out
net Xdir => parport.0.pin-02-out
net Ystep => parport.0.pin-05-out
net Ydir => parport.0.pin-04-out
net Zstep => parport.0.pin-07-out
net Zdir => parport.0.pin-06-out
net Astep => parport.0.pin-09-out
net Adir => parport.0.pin-08-out
# amp enable (active lo)
net Xen => parport.0.pin-01-out
setp parport.0.pin-01-out-invert 1
# spindle enable (active lo)
net spindle_on => parport.0.pin-14-out
setp parport.0.pin-14-out-invert 1
#######################################################
# set scaling and other parameters of the basic machine
# set stepgen module scaling - get values from ini file
setp stepgen.0.position-scale [AXIS_0]SCALE
setp stepgen.1.position-scale [AXIS_1]SCALE
setp stepgen.2.position-scale [AXIS_2]SCALE
setp stepgen.3.position-scale [AXIS_3]SCALE
# set stepgen module accel limits - get values from ini file
# jmk said to set these to ini value + 5% to avoid stepgen bug
setp stepgen.0.maxaccel [AXIS_0]HAL_MAXACCEL
setp stepgen.1.maxaccel [AXIS_1]HAL_MAXACCEL
setp stepgen.2.maxaccel [AXIS_2]HAL_MAXACCEL
setp stepgen.3.maxaccel [AXIS_3]HAL_MAXACCEL
# end of basic machine
#######################################################
# Beginning of threading related stuff
#######################################################
# spindle speed control
net spindle-speed-cmd <= motion.spindle-speed-out
net spindle-speed-cmd => sim-encoder.0.speed
# spindle encoder
# connect encoder signals to encoder counter
net spindle-phase-A => encoder.0.phase-A
net spindle-phase-B => encoder.0.phase-B
net spindle-phase-Z => encoder.0.phase-Z
net spindle-phase-A <= sim-encoder.0.phase-A
net spindle-phase-B <= sim-encoder.0.phase-B
net spindle-phase-Z <= sim-encoder.0.phase-Z
# assume 120 ppr = 480 counts/rev for the spindle
setp sim-encoder.0.ppr 120
# iocontrol output is in rpm, but sim-encoder speed is rps
setp sim-encoder.0.scale 60
# scale encoder output to read in revolutions
# (that way thread pitches can be straightforward,
# a 20 tpi thread would multiply the encoder output
# by 1/20, etc)
setp encoder.0.position-scale 480
# encoder reset control
net spindle-index-enable <= motion.spindle-index-enable
net spindle-index-enable <=> encoder.0.index-enable
# report our revolution count to the motion controller
net spindle-pos <= encoder.0.position
net spindle-pos => motion.spindle-revs
#######################################################
# make vel and accel sigs for testing
#######################################################
# send the position commands thru differentiators to
# generate velocity and accel signals (for testing)
# define the signals, and hook them up
net Xpos-cmd => ddt.0.in
net Xvel <= ddt.0.out
net Xvel => ddt.1.in
net Xacc <= ddt.1.out
net Ypos-cmd => ddt.2.in
net Yvel <= ddt.2.out
net Yvel => ddt.3.in
net Yacc <= ddt.3.out
net Zpos-cmd => ddt.4.in
net Zvel <= ddt.4.out
net Zvel => ddt.5.in
net Zacc <= ddt.5.out
net Apos-cmd => ddt.6.in
net Avel <= ddt.6.out
net Avel => ddt.7.in
net Aacc <= ddt.7.out
# for spindle velocity estimate
loadrt lowpass count=1
net spindle-rpm-raw encoder.0.velocity
net spindle-rpm-raw lowpass.0.in
net spindle-rpm-filtered lowpass.0.out
setp lowpass.0.gain .03
addf lowpass.0 servo-thread

View File

@@ -0,0 +1,190 @@
###################### Torch Height Control ##########################
# Load realtime hal components for THC
loadrt and2 count=9
loadrt comp count=3
loadrt updown
loadrt flipflop count=3
loadrt hypot
loadrt logic personality=0x203
loadrt minmax
loadrt mult2 count=2
loadrt mux2 count=7
loadrt not count=3
loadrt oneshot count=4
loadrt or2 count=9
loadrt scale
loadrt sum2 count=5
loadrt xor2 count=4
loadrt conv_s32_float
loadrt edge count=2
# Attach realtime hal components to a realtime 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 and2.5 servo-thread
addf and2.6 servo-thread
addf and2.7 servo-thread
addf and2.8 servo-thread
addf comp.0 servo-thread
addf comp.1 servo-thread
addf comp.2 servo-thread
addf conv-s32-float.0 servo-thread
addf edge.0 servo-thread
addf edge.1 servo-thread
addf flipflop.0 servo-thread
addf flipflop.1 servo-thread
addf flipflop.2 servo-thread
addf hypot.0 servo-thread
addf logic.0 servo-thread
addf minmax.0 servo-thread
addf mult2.0 servo-thread
addf mult2.1 servo-thread
addf mux2.0 servo-thread
addf mux2.1 servo-thread
addf mux2.2 servo-thread
addf mux2.3 servo-thread
addf mux2.4 servo-thread
addf mux2.5 servo-thread
addf mux2.6 servo-thread
addf not.0 servo-thread
addf not.1 servo-thread
addf not.2 servo-thread
addf oneshot.0 servo-thread
addf oneshot.1 servo-thread
addf oneshot.2 servo-thread
addf oneshot.3 servo-thread
addf or2.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 or2.6 servo-thread
addf or2.7 servo-thread
addf or2.8 servo-thread
addf updown.0 servo-thread
addf scale.0 servo-thread
addf sum2.0 servo-thread
addf sum2.1 servo-thread
addf sum2.2 servo-thread
addf sum2.3 servo-thread
addf sum2.4 servo-thread
addf xor2.0 servo-thread
addf xor2.1 servo-thread
addf xor2.2 servo-thread
# Set static values and default values
setp oneshot.1.width [PLASMA]IGNITION_TIMEOUT
setp oneshot.2.width [PLASMA]ARC_OK_FILTER_TIME
setp oneshot.3.width [PLASMA]EXTINGUISH_TIMEOUT
setp oneshot.3.falling 1
setp oneshot.3.rising 0
setp comp.2.in0 [PLASMA]MAX_FAILED_IGNITIONS
setp mux2.1.in0 -1
setp mux2.1.in1 1
setp mux2.3.in0 0
# Set the lowest value the THC will try to move the torch
setp sum2.4.in0 [AXIS_2]MIN_LIMIT
# Set default gains for sum, positive for addition and negative for subtraction
# Setting positive gains will become implicit and those can be removed safely in a later version
setp sum2.0.gain0 1
setp sum2.0.gain1 1
setp sum2.1.gain0 1
setp sum2.1.gain1 1
setp sum2.2.gain0 1
setp sum2.2.gain1 -1
setp sum2.3.gain0 1
setp sum2.3.gain1 -1
setp sum2.4.gain0 1
setp sum2.4.gain1 -1
# Set Hysterisis for float comp
setp comp.1.hyst 0.001
# Set percentage multiplier for scale
setp scale.0.gain 0.01
# Set edge detectors to work on falling edges to detect Ignition Timeouts
setp edge.0.in-edge 1
setp edge.1.in-edge 1
# Hook up parallel port pins
net MoveDown parport.1.pin-11-in-not => or2.0.in0
net MoveUp parport.1.pin-12-in-not => or2.0.in1 mux2.1.sel
# Hook up component pins using the net command
net FloatSwitch parport.1.pin-03-in => or2.1.in1 and2.4.in0 and2.5.in1 and2.6.in1
net ArcOK parport.1.pin-15-in-not => or2.4.in1 xor2.1.in1 oneshot.2.in
net FilteredArcOK xor2.1.out => or2.1.in0 or2.6.in0 not.1.in and2.4.in1 flipflop.1.set oneshot.3.in flipflop.2.set and2.2.in0
net TimersOrArcOK or2.4.out => or2.5.in0 or2.3.in0
net LockHeight and2.0.out => xor2.2.in0
net EnabledAdjustHeight and2.1.out => mux2.3.sel
net ReleaseFeedHold and2.2.out => xor2.0.in1
net TorchOn => and2.3.out parport.1.pin-01-out oneshot.1.in not.2.in
net FloatSwitchEstop and2.4.out => logic.0.in-02
net FloatAndTorchOn and2.5.out => or2.2.in1
net TorchAndFloat and2.6.out => flipflop.0.set
net PosAndFloat and2.7.out => or2.5.in1
net IgnitionEstop comp.2.out => logic.0.in-01
net StartTorchOn and2.8.out => and2.3.in0
net OriginalPosZ-cmd joint.2.motor-pos-cmd => mux2.5.in0 sum2.2.in1
net JointPoz-cmd joint.2.pos-cmd => sum2.2.in0
net CHLTriggered comp.0.out => and2.0.in0
net AtPosition comp.1.equal => and2.7.in0
net VelX ddt.0.out => hypot.0.in0
net VelY ddt.1.out => hypot.0.in1
net FloatSwitchSet flipflop.0.out => or2.3.in1 and2.7.in1
net ModeIsAuto halui.mode.is-auto => mux2.5.sel
net VelXY hypot.0.out => minmax.0.in comp.0.in0
net TriggerEStop logic.0.or => estop-latch.0.fault-in
net MaximumVelocity minmax.0.max => mult2.1.in0
net TurnTorchOn motion.spindle-forward => xor2.0.in0 and2.8.in0 and2.6.in0 mux2.4.sel not.0.in
net HeightAdjustment mult2.0.out => mux2.3.in1
net VelocityThreshold mult2.1.out => comp.0.in1
net HeightOffset mux2.0.out => sum2.1.in1
net AdjustmentDirection mux2.1.out => mult2.0.in1
net PositionSnapshot mux2.2.out => sum2.1.in0 mux2.2.in0
net SelectedAdjustment mux2.3.out => mux2.0.in1
net PosZ-cmd mux2.4.out => stepgen.2.position-cmd comp.1.in1
net PosSelectB mux2.5.out => mux2.4.in0
net PosSelectC mux2.6.out => mux2.4.in1
net TurnTorchOff not.0.out => and2.5.in0 or2.7.in0 updown.0.reset
net ReversedArcOK not.1.out => minmax.0.reset
net PierceDelayElapsed oneshot.0.out-not => and2.2.in1
net IgnitionTimer oneshot.1.out => edge.0.in or2.8.in0
net AdjustHeight or2.0.out => xor2.2.in1 and2.1.in0
net TakeSnapshot or2.1.out => mux2.2.sel
net TriggerLimit or2.2.out => joint.2.neg-lim-sw-in joint.2.pos-lim-sw-in joint.2.home-sw-in
net ProbeOrArcOK or2.3.out => mux2.6.sel
net PAFOrArcOK or2.5.out => and2.3.in1
net EstopOrArcOK or2.6.out => flipflop.0.reset
net ExtEStop parport.0.pin-10-in => logic.0.in-00
net ExtEStop => logic.0.in-00
net LimitZ parport.0.pin-13-in => or2.2.in0
net ThresholdPercentage scale.0.out => mult2.1.in1
net PosZ-fb stepgen.2.position-fb => joint.2.motor-pos-fb mux2.2.in1 comp.1.in0
net PierceOffset sum2.0.out => mux2.0.in0
net DestinationHeight sum2.1.out => mux2.6.in1
net JointAxisDiff sum2.2.out => sum2.3.in1 sum2.4.in1
net StepCordsTH sum2.3.out => mux2.5.in1
net StepCordsML sum2.4.out => mux2.6.in0
net FeedHold xor2.0.out => motion.feed-hold
net CHLSwitched xor2.2.out => and2.1.in1
net ArcOKTimer oneshot.2.out => xor2.1.in0
net PierceLatch flipflop.1.out => mux2.0.sel oneshot.0.in
net IgnitionCounterS32 updown.0.count => conv-s32-float.0.in
net IgnitionCounterFloat conv-s32-float.0.out => comp.2.in1
net IgnitionTimerOff oneshot.1.out-not => updown.0.countup
net TorchOff not.2.out => flipflop.1.reset
net TorchTurnedOffOrTimeout or2.7.out => or2.6.in1
net IgnitionTimeout edge.0.out => or2.7.in1
net ExtinguishTimer oneshot.3.out edge.1.in
net ExtinguishLatch flipflop.2.out or2.8.in1
net ExtinguishTimeout edge.1.out flipflop.2.reset
net Timers or2.8.out => or2.4.in0

View File

@@ -0,0 +1,32 @@
############################# Parallel Ports ##############################################
# Load Driver for Two Parallel Ports, one for Breakout Board, other for Plasma Torch Height Control
loadrt hal_parport cfg="0xa400 0xac00 in"
# Connect both Paralell Ports to Threads for Read / Write
addf parport.0.read base-thread 1
addf parport.0.write base-thread -1
addf parport.1.read base-thread 1
addf parport.1.write base-thread -1
# Invert pins to make motors move in right direction
setp parport.0.pin-03-out-invert 1
setp parport.0.pin-05-out-invert 1
# Hook up the step and dir signals to the parport pins
# Axis A and Y are the same axis but different motors
net StepX stepgen.0.step => parport.0.pin-02-out
net DirX stepgen.0.dir => parport.0.pin-03-out
net StepY stepgen.1.step => parport.0.pin-04-out
net DirY stepgen.1.dir => parport.0.pin-05-out
net StepZ stepgen.2.step => parport.0.pin-06-out
net DirZ stepgen.2.dir => parport.0.pin-07-out
net StepA stepgen.3.step => parport.0.pin-08-out
net DirA stepgen.3.dir => parport.0.pin-09-out
# Hook up limit and home switches, each axis shares a common pin for homing, limit min and limit max
net LimitX parport.1.pin-06-in-not => joint.0.neg-lim-sw-in joint.0.pos-lim-sw-in joint.0.home-sw-in
net LimitY parport.1.pin-07-in-not => joint.1.neg-lim-sw-in joint.1.pos-lim-sw-in joint.1.home-sw-in
# Z axis Limit switch handled by THC, see thc.hal
#net LimitZ parport.1.pin-13-in => joint.2.neg-lim-sw-in joint.2.pos-lim-sw-in joint.2.home-sw-in
net LimitA parport.1.pin-09-in-not => joint.3.neg-lim-sw-in joint.3.pos-lim-sw-in joint.3.home-sw-in

View File

@@ -0,0 +1,190 @@
###################### Torch Height Control ##########################
# Load realtime hal components for THC
loadrt and2 count=9
loadrt comp count=3
loadrt updown
loadrt flipflop count=3
loadrt hypot
loadrt logic personality=0x203
loadrt minmax
loadrt mult2 count=2
loadrt mux2 count=7
loadrt not count=3
loadrt oneshot count=4
loadrt or2 count=9
loadrt scale
loadrt sum2 count=5
loadrt xor2 count=4
loadrt conv_s32_float
loadrt edge count=2
# Attach realtime hal components to a realtime 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 and2.5 servo-thread
addf and2.6 servo-thread
addf and2.7 servo-thread
addf and2.8 servo-thread
addf comp.0 servo-thread
addf comp.1 servo-thread
addf comp.2 servo-thread
addf conv-s32-float.0 servo-thread
addf edge.0 servo-thread
addf edge.1 servo-thread
addf flipflop.0 servo-thread
addf flipflop.1 servo-thread
addf flipflop.2 servo-thread
addf hypot.0 servo-thread
addf logic.0 servo-thread
addf minmax.0 servo-thread
addf mult2.0 servo-thread
addf mult2.1 servo-thread
addf mux2.0 servo-thread
addf mux2.1 servo-thread
addf mux2.2 servo-thread
addf mux2.3 servo-thread
addf mux2.4 servo-thread
addf mux2.5 servo-thread
addf mux2.6 servo-thread
addf not.0 servo-thread
addf not.1 servo-thread
addf not.2 servo-thread
addf oneshot.0 servo-thread
addf oneshot.1 servo-thread
addf oneshot.2 servo-thread
addf oneshot.3 servo-thread
addf or2.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 or2.6 servo-thread
addf or2.7 servo-thread
addf or2.8 servo-thread
addf updown.0 servo-thread
addf scale.0 servo-thread
addf sum2.0 servo-thread
addf sum2.1 servo-thread
addf sum2.2 servo-thread
addf sum2.3 servo-thread
addf sum2.4 servo-thread
addf xor2.0 servo-thread
addf xor2.1 servo-thread
addf xor2.2 servo-thread
# Set static values and default values
setp oneshot.1.width [PLASMA]IGNITION_TIMEOUT
setp oneshot.2.width [PLASMA]ARC_OK_FILTER_TIME
setp oneshot.3.width [PLASMA]EXTINGUISH_TIMEOUT
setp oneshot.3.falling 1
setp oneshot.3.rising 0
setp comp.2.in0 [PLASMA]MAX_FAILED_IGNITIONS
setp mux2.1.in0 -1
setp mux2.1.in1 1
setp mux2.3.in0 0
# Set the lowest value the THC will try to move the torch
setp sum2.4.in0 [AXIS_2]MIN_LIMIT
# Set default gains for sum, positive for addition and negative for subtraction
# Setting positive gains will become implicit and those can be removed safely in a later version
setp sum2.0.gain0 1
setp sum2.0.gain1 1
setp sum2.1.gain0 1
setp sum2.1.gain1 1
setp sum2.2.gain0 1
setp sum2.2.gain1 -1
setp sum2.3.gain0 1
setp sum2.3.gain1 -1
setp sum2.4.gain0 1
setp sum2.4.gain1 -1
# Set Hysterisis for float comp
setp comp.1.hyst 0.001
# Set percentage multiplier for scale
setp scale.0.gain 0.01
# Set edge detectors to work on falling edges to detect Ignition Timeouts
setp edge.0.in-edge 1
setp edge.1.in-edge 1
# Hook up parallel port pins
net MoveDown parport.1.pin-06-in-not => or2.0.in0
net MoveUp parport.1.pin-07-in-not => or2.0.in1 mux2.1.sel
# Hook up component pins using the net command
net FloatSwitch parport.1.pin-03-in => or2.1.in1 and2.4.in0 and2.5.in1 and2.6.in1
net ArcOK parport.1.pin-08-in-not => or2.4.in1 xor2.1.in1 oneshot.2.in
net FilteredArcOK xor2.1.out => or2.1.in0 or2.6.in0 not.1.in and2.4.in1 flipflop.1.set oneshot.3.in flipflop.2.set and2.2.in0
net TimersOrArcOK or2.4.out => or2.5.in0 or2.3.in0
net LockHeight and2.0.out => xor2.2.in0
net EnabledAdjustHeight and2.1.out => mux2.3.sel
net ReleaseFeedHold and2.2.out => xor2.0.in1
net TorchOn => and2.3.out parport.1.pin-01-out oneshot.1.in not.2.in
net FloatSwitchEstop and2.4.out => logic.0.in-02
net FloatAndTorchOn and2.5.out => or2.2.in1
net TorchAndFloat and2.6.out => flipflop.0.set
net PosAndFloat and2.7.out => or2.5.in1
net IgnitionEstop comp.2.out => logic.0.in-01
net StartTorchOn and2.8.out => and2.3.in0
net OriginalPosZ-cmd joint.2.motor-pos-cmd => mux2.5.in0 sum2.2.in1
net JointPoz-cmd joint.2.pos-cmd => sum2.2.in0
net CHLTriggered comp.0.out => and2.0.in0
net AtPosition comp.1.equal => and2.7.in0
net VelX ddt.0.out => hypot.0.in0
net VelY ddt.1.out => hypot.0.in1
net FloatSwitchSet flipflop.0.out => or2.3.in1 and2.7.in1
net ModeIsAuto halui.mode.is-auto => mux2.5.sel
net VelXY hypot.0.out => minmax.0.in comp.0.in0
net TriggerEStop logic.0.or => estop-latch.0.fault-in
net MaximumVelocity minmax.0.max => mult2.1.in0
net TurnTorchOn motion.spindle-forward => xor2.0.in0 and2.8.in0 and2.6.in0 mux2.4.sel not.0.in
net HeightAdjustment mult2.0.out => mux2.3.in1
net VelocityThreshold mult2.1.out => comp.0.in1
net HeightOffset mux2.0.out => sum2.1.in1
net AdjustmentDirection mux2.1.out => mult2.0.in1
net PositionSnapshot mux2.2.out => sum2.1.in0 mux2.2.in0
net SelectedAdjustment mux2.3.out => mux2.0.in1
net PosZ-cmd mux2.4.out => stepgen.2.position-cmd comp.1.in1
net PosSelectB mux2.5.out => mux2.4.in0
net PosSelectC mux2.6.out => mux2.4.in1
net TurnTorchOff not.0.out => and2.5.in0 or2.7.in0 updown.0.reset
net ReversedArcOK not.1.out => minmax.0.reset
net PierceDelayElapsed oneshot.0.out-not => and2.2.in1
net IgnitionTimer oneshot.1.out => edge.0.in or2.8.in0
net AdjustHeight or2.0.out => xor2.2.in1 and2.1.in0
net TakeSnapshot or2.1.out => mux2.2.sel
net TriggerLimit or2.2.out => joint.2.neg-lim-sw-in joint.2.pos-lim-sw-in joint.2.home-sw-in
net ProbeOrArcOK or2.3.out => mux2.6.sel
net PAFOrArcOK or2.5.out => and2.3.in1
net EstopOrArcOK or2.6.out => flipflop.0.reset
net ExtEStop parport.0.pin-10-in => logic.0.in-00
net ExtEStop => logic.0.in-00
net LimitZ parport.0.pin-13-in => or2.2.in0
net ThresholdPercentage scale.0.out => mult2.1.in1
net PosZ-fb stepgen.2.position-fb => joint.2.motor-pos-fb mux2.2.in1 comp.1.in0
net PierceOffset sum2.0.out => mux2.0.in0
net DestinationHeight sum2.1.out => mux2.6.in1
net JointAxisDiff sum2.2.out => sum2.3.in1 sum2.4.in1
net StepCordsTH sum2.3.out => mux2.5.in1
net StepCordsML sum2.4.out => mux2.6.in0
net FeedHold xor2.0.out => motion.feed-hold
net CHLSwitched xor2.2.out => and2.1.in1
net ArcOKTimer oneshot.2.out => xor2.1.in0
net PierceLatch flipflop.1.out => mux2.0.sel oneshot.0.in
net IgnitionCounterS32 updown.0.count => conv-s32-float.0.in
net IgnitionCounterFloat conv-s32-float.0.out => comp.2.in1
net IgnitionTimerOff oneshot.1.out-not => updown.0.countup
net TorchOff not.2.out => flipflop.1.reset
net TorchTurnedOffOrTimeout or2.7.out => or2.6.in1
net IgnitionTimeout edge.0.out => or2.7.in1
net ExtinguishTimer oneshot.3.out edge.1.in
net ExtinguishLatch flipflop.2.out or2.8.in1
net ExtinguishTimeout edge.1.out flipflop.2.reset
net Timers or2.8.out => or2.4.in0

View File

@@ -0,0 +1,32 @@
############################# Parallel Ports ##############################################
# Load Driver for Two Parallel Ports, one for Breakout Board, other for Plasma Torch Height Control
loadrt hal_parport cfg="0xa400 0xac00 in"
# Connect both Paralell Ports to Threads for Read / Write
addf parport.0.read base-thread 1
addf parport.0.write base-thread -1
addf parport.1.read base-thread 1
addf parport.1.write base-thread -1
# Invert pins to make motors move in right direction
setp parport.0.pin-03-out-invert 1
setp parport.0.pin-05-out-invert 1
# Hook up the step and dir signals to the parport pins
# Axis A and Y are the same axis but different motors
net StepX stepgen.0.step => parport.0.pin-02-out
net DirX stepgen.0.dir => parport.0.pin-03-out
net StepY stepgen.1.step => parport.0.pin-04-out
net DirY stepgen.1.dir => parport.0.pin-05-out
net StepZ stepgen.2.step => parport.0.pin-06-out
net DirZ stepgen.2.dir => parport.0.pin-07-out
net StepA stepgen.3.step => parport.0.pin-08-out
net DirA stepgen.3.dir => parport.0.pin-09-out
# Hook up limit and home switches, each axis shares a common pin for homing, limit min and limit max
net LimitX parport.0.pin-11-in => joint.0.neg-lim-sw-in joint.0.pos-lim-sw-in joint.0.home-sw-in
net LimitY parport.0.pin-12-in => joint.1.neg-lim-sw-in joint.1.pos-lim-sw-in joint.1.home-sw-in
# Z axis Limit switch handled by THC, see thc.hal
#net LimitZ parport.1.pin-13-in => joint.2.neg-lim-sw-in joint.2.pos-lim-sw-in joint.2.home-sw-in
net LimitA parport.0.pin-15-in => joint.3.neg-lim-sw-in joint.3.pos-lim-sw-in joint.3.home-sw-in

View File

@@ -0,0 +1,54 @@
############################ Step Generators #########################################
# Stepper module, four step generators, all using step/dir
loadrt stepgen step_type=0,0,0,0
# Load realtime ddt for velocity calculations used for CHL
loadrt ddt count=2
# Hook functions to base thread (high speed thread for step generation)
addf stepgen.make-pulses base-thread
# Hook functions to servo thread
addf stepgen.capture-position servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread
addf ddt.0 servo-thread
addf ddt.1 servo-thread
# Configure signals for Z axis to be twice the size of the signals for other axis because
# Z axis has a slo-syn driver which can't handle smaller step sizes
setp stepgen.2.steplen 35200
setp stepgen.2.stepspace 35200
setp stepgen.2.dirsetup 35200
setp stepgen.2.dirhold 35200
# Set stepgen module scaling - get values from ini file
setp stepgen.0.position-scale [AXIS_0]SCALE
setp stepgen.1.position-scale [AXIS_1]SCALE
setp stepgen.2.position-scale [AXIS_2]SCALE
setp stepgen.3.position-scale [AXIS_3]SCALE
# Set stepgen module accel limits - get values from ini file
setp stepgen.0.maxaccel [AXIS_0]STEPGEN_MAXACCEL
setp stepgen.1.maxaccel [AXIS_1]STEPGEN_MAXACCEL
setp stepgen.2.maxaccel [AXIS_2]STEPGEN_MAXACCEL
setp stepgen.3.maxaccel [AXIS_3]STEPGEN_MAXACCEL
# Hook up stepgen to motion modules
net PosX-cmd joint.0.motor-pos-cmd => stepgen.0.position-cmd
net PosX-fb stepgen.0.position-fb => joint.0.motor-pos-fb ddt.0.in
net PosY-cmd joint.1.motor-pos-cmd => stepgen.1.position-cmd
net PosY-fb stepgen.1.position-fb => joint.1.motor-pos-fb ddt.1.in
# Z Axis Position and feedback signals handled by THC, see thc.hal
#net PosZ-cmd joint.2.motor-pos-cmd => stepgen.2.position-cmd
#net PosZ-fb stepgen.2.position-fb => joint.2.motor-pos-fb
net PosA-cmd joint.3.motor-pos-cmd => stepgen.3.position-cmd
net PosA-fb stepgen.3.position-fb => joint.3.motor-pos-fb
# Hook up enable signals for step generators
net EnableX joint.0.amp-enable-out => stepgen.0.enable
net EnableY joint.1.amp-enable-out => stepgen.1.enable
net EnableZ joint.2.amp-enable-out => stepgen.2.enable
net EnableA joint.3.amp-enable-out => stepgen.3.enable

View File

@@ -0,0 +1,190 @@
###################### Torch Height Control ##########################
# Load realtime hal components for THC
loadrt and2 count=9
loadrt comp count=3
loadrt updown
loadrt flipflop count=3
loadrt hypot
loadrt logic personality=0x203
loadrt minmax
loadrt mult2 count=2
loadrt mux2 count=7
loadrt not count=3
loadrt oneshot count=4
loadrt or2 count=9
loadrt scale
loadrt sum2 count=5
loadrt xor2 count=4
loadrt conv_s32_float
loadrt edge count=2
# Attach realtime hal components to a realtime 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 and2.5 servo-thread
addf and2.6 servo-thread
addf and2.7 servo-thread
addf and2.8 servo-thread
addf comp.0 servo-thread
addf comp.1 servo-thread
addf comp.2 servo-thread
addf conv-s32-float.0 servo-thread
addf edge.0 servo-thread
addf edge.1 servo-thread
addf flipflop.0 servo-thread
addf flipflop.1 servo-thread
addf flipflop.2 servo-thread
addf hypot.0 servo-thread
addf logic.0 servo-thread
addf minmax.0 servo-thread
addf mult2.0 servo-thread
addf mult2.1 servo-thread
addf mux2.0 servo-thread
addf mux2.1 servo-thread
addf mux2.2 servo-thread
addf mux2.3 servo-thread
addf mux2.4 servo-thread
addf mux2.5 servo-thread
addf mux2.6 servo-thread
addf not.0 servo-thread
addf not.1 servo-thread
addf not.2 servo-thread
addf oneshot.0 servo-thread
addf oneshot.1 servo-thread
addf oneshot.2 servo-thread
addf oneshot.3 servo-thread
addf or2.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 or2.6 servo-thread
addf or2.7 servo-thread
addf or2.8 servo-thread
addf updown.0 servo-thread
addf scale.0 servo-thread
addf sum2.0 servo-thread
addf sum2.1 servo-thread
addf sum2.2 servo-thread
addf sum2.3 servo-thread
addf sum2.4 servo-thread
addf xor2.0 servo-thread
addf xor2.1 servo-thread
addf xor2.2 servo-thread
# Set static values and default values
setp oneshot.1.width [PLASMA]IGNITION_TIMEOUT
setp oneshot.2.width [PLASMA]ARC_OK_FILTER_TIME
setp oneshot.3.width [PLASMA]EXTINGUISH_TIMEOUT
setp oneshot.3.falling 1
setp oneshot.3.rising 0
setp comp.2.in0 [PLASMA]MAX_FAILED_IGNITIONS
setp mux2.1.in0 -1
setp mux2.1.in1 1
setp mux2.3.in0 0
# Set the lowest value the THC will try to move the torch
setp sum2.4.in0 [AXIS_2]MIN_LIMIT
# Set default gains for sum, positive for addition and negative for subtraction
# Setting positive gains will become implicit and those can be removed safely in a later version
setp sum2.0.gain0 1
setp sum2.0.gain1 1
setp sum2.1.gain0 1
setp sum2.1.gain1 1
setp sum2.2.gain0 1
setp sum2.2.gain1 -1
setp sum2.3.gain0 1
setp sum2.3.gain1 -1
setp sum2.4.gain0 1
setp sum2.4.gain1 -1
# Set Hysterisis for float comp
setp comp.1.hyst 0.001
# Set percentage multiplier for scale
setp scale.0.gain 0.01
# Set edge detectors to work on falling edges to detect Ignition Timeouts
setp edge.0.in-edge 1
setp edge.1.in-edge 1
# Hook up parallel port pins
net MoveDown parport.1.pin-06-in-not => or2.0.in0
net MoveUp parport.1.pin-07-in-not => or2.0.in1 mux2.1.sel
# Hook up component pins using the net command
net FloatSwitch parport.1.pin-13-in => or2.1.in1 and2.4.in0 and2.5.in1 and2.6.in1
net ArcOK parport.1.pin-08-in-not => or2.4.in1 xor2.1.in1 oneshot.2.in
net FilteredArcOK xor2.1.out => or2.1.in0 or2.6.in0 not.1.in and2.4.in1 flipflop.1.set oneshot.3.in flipflop.2.set and2.2.in0
net TimersOrArcOK or2.4.out => or2.5.in0 or2.3.in0
net LockHeight and2.0.out => xor2.2.in0
net EnabledAdjustHeight and2.1.out => mux2.3.sel
net ReleaseFeedHold and2.2.out => xor2.0.in1
net TorchOn => and2.3.out parport.1.pin-01-out oneshot.1.in not.2.in
net FloatSwitchEstop and2.4.out => logic.0.in-02
net FloatAndTorchOn and2.5.out => or2.2.in1
net TorchAndFloat and2.6.out => flipflop.0.set
net PosAndFloat and2.7.out => or2.5.in1
net IgnitionEstop comp.2.out => logic.0.in-01
net StartTorchOn and2.8.out => and2.3.in0
net OriginalPosZ-cmd joint.2.motor-pos-cmd => mux2.5.in0 sum2.2.in1
net JointPoz-cmd joint.2.pos-cmd => sum2.2.in0
net CHLTriggered comp.0.out => and2.0.in0
net AtPosition comp.1.equal => and2.7.in0
net VelX ddt.0.out => hypot.0.in0
net VelY ddt.1.out => hypot.0.in1
net FloatSwitchSet flipflop.0.out => or2.3.in1 and2.7.in1
net ModeIsAuto halui.mode.is-auto => mux2.5.sel
net VelXY hypot.0.out => minmax.0.in comp.0.in0
net TriggerEStop logic.0.or => estop-latch.0.fault-in
net MaximumVelocity minmax.0.max => mult2.1.in0
net TurnTorchOn motion.spindle-forward => xor2.0.in0 and2.8.in0 and2.6.in0 mux2.4.sel not.0.in
net HeightAdjustment mult2.0.out => mux2.3.in1
net VelocityThreshold mult2.1.out => comp.0.in1
net HeightOffset mux2.0.out => sum2.1.in1
net AdjustmentDirection mux2.1.out => mult2.0.in1
net PositionSnapshot mux2.2.out => sum2.1.in0 mux2.2.in0
net SelectedAdjustment mux2.3.out => mux2.0.in1
net PosZ-cmd mux2.4.out => stepgen.2.position-cmd comp.1.in1
net PosSelectB mux2.5.out => mux2.4.in0
net PosSelectC mux2.6.out => mux2.4.in1
net TurnTorchOff not.0.out => and2.5.in0 or2.7.in0 updown.0.reset
net ReversedArcOK not.1.out => minmax.0.reset
net PierceDelayElapsed oneshot.0.out-not => and2.2.in1
net IgnitionTimer oneshot.1.out => edge.0.in or2.8.in0
net AdjustHeight or2.0.out => xor2.2.in1 and2.1.in0
net TakeSnapshot or2.1.out => mux2.2.sel
net TriggerLimit or2.2.out => joint.2.neg-lim-sw-in joint.2.pos-lim-sw-in joint.2.home-sw-in
net ProbeOrArcOK or2.3.out => mux2.6.sel
net PAFOrArcOK or2.5.out => and2.3.in1
net EstopOrArcOK or2.6.out => flipflop.0.reset
net ExtEStop parport.0.pin-10-in => logic.0.in-00
net ExtEStop => logic.0.in-00
net LimitZ parport.0.pin-13-in => or2.2.in0
net ThresholdPercentage scale.0.out => mult2.1.in1
net PosZ-fb stepgen.2.position-fb => joint.2.motor-pos-fb mux2.2.in1 comp.1.in0
net PierceOffset sum2.0.out => mux2.0.in0
net DestinationHeight sum2.1.out => mux2.6.in1
net JointAxisDiff sum2.2.out => sum2.3.in1 sum2.4.in1
net StepCordsTH sum2.3.out => mux2.5.in1
net StepCordsML sum2.4.out => mux2.6.in0
net FeedHold xor2.0.out => motion.feed-hold
net CHLSwitched xor2.2.out => and2.1.in1
net ArcOKTimer oneshot.2.out => xor2.1.in0
net PierceLatch flipflop.1.out => mux2.0.sel oneshot.0.in
net IgnitionCounterS32 updown.0.count => conv-s32-float.0.in
net IgnitionCounterFloat conv-s32-float.0.out => comp.2.in1
net IgnitionTimerOff oneshot.1.out-not => updown.0.countup
net TorchOff not.2.out => flipflop.1.reset
net TorchTurnedOffOrTimeout or2.7.out => or2.6.in1
net IgnitionTimeout edge.0.out => or2.7.in1
net ExtinguishTimer oneshot.3.out edge.1.in
net ExtinguishLatch flipflop.2.out or2.8.in1
net ExtinguishTimeout edge.1.out flipflop.2.reset
net Timers or2.8.out => or2.4.in0