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,223 @@
[EMC]
MACHINE = 12extrajoints
VERSION = 1.1
[APPLICATIONS]
APP = halshow --fformat %.6f extrajoints.halshow
# joint4 example:
APP = sim_pin --title "j4 extrajoint" \
j4.limit3.min \
j4.limit3.max \
j4.limit3.maxv \
j4.limit3.maxa \
j4.limit3.in
[KINS]
JOINTS = 16
#NOTE: 4 conventional joints, 12 extra (motmod) total=16
KINEMATICS = trivkins coordinates=XYYZ kinstype=both
[EMCMOT]
EMCMOT = motmod num_extrajoints=12
SERVO_PERIOD = 1000000
[HAL]
TWOPASS = on
HALFILE = LIB:basic_sim.tcl
HALFILE = ./extrajoints.tcl
HALUI = halui
[DISPLAY]
DISPLAY = axis
MAX_LINEAR_VELOCITY = 1
PROGRAM_PREFIX = .
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
[RS274NGC]
PARAMETER_FILE = sim.var
[TRAJ]
COORDINATES = XYYZ
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
[JOINT_0]
TYPE = LINEAR
HOME_SEQUENCE = 0
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MAX_VELOCITY = 10
MAX_ACCELERATION = 100
[JOINT_1]
TYPE = LINEAR
HOME_SEQUENCE = -1
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MAX_VELOCITY = 10
MAX_ACCELERATION = 100
[JOINT_2]
TYPE = LINEAR
HOME_SEQUENCE = -1
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MAX_VELOCITY = 10
MAX_ACCELERATION = 100
[JOINT_3]
TYPE = LINEAR
HOME_SEQUENCE = 2
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MAX_VELOCITY = 10
MAX_ACCELERATION = 100
[JOINT_4]
# this 'extra' joint is managed by a
# limit3 component after homing
TYPE = LINEAR
HOME_SEQUENCE = 3
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MIN_LIMIT = -10
MAX_LIMIT = 10
MAX_VELOCITY = 5
MAX_ACCELERATION = 100
[JOINT_5]
# this 'extra' joint is managed by a
# limit3 component after homing
TYPE = LINEAR
HOME_SEQUENCE = 4
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MIN_LIMIT = -10
MAX_LIMIT = 10
MAX_VELOCITY = 5
MAX_ACCELERATION = 100
[JOINT_6]
# this 'extra' joint is managed by a
# limit3 component after homing
TYPE = LINEAR
HOME_SEQUENCE = 5
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MIN_LIMIT = -10
MAX_LIMIT = 10
MAX_VELOCITY = 5
MAX_ACCELERATION = 100
[JOINT_7]
# this 'extra' joint is managed by a
# limit3 component after homing
TYPE = LINEAR
HOME_SEQUENCE = 6
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MIN_LIMIT = -10
MAX_LIMIT = 10
MAX_VELOCITY = 5
MAX_ACCELERATION = 100
[JOINT_8]
# this 'extra' joint is managed by a
# limit3 component after homing
TYPE = LINEAR
HOME_SEQUENCE = 7
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MIN_LIMIT = -10
MAX_LIMIT = 10
MAX_VELOCITY = 5
MAX_ACCELERATION = 100
[JOINT_9]
# this 'extra' joint is managed by a
# limit3 component after homing
TYPE = LINEAR
HOME_SEQUENCE = 8
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MIN_LIMIT = -10
MAX_LIMIT = 10
MAX_VELOCITY = 5
MAX_ACCELERATION = 100
[JOINT_10]
# this 'extra' joint is managed by a
# limit3 component after homing
TYPE = LINEAR
HOME_SEQUENCE = 9
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MIN_LIMIT = -10
MAX_LIMIT = 10
MAX_VELOCITY = 5
MAX_ACCELERATION = 100
[JOINT_11]
# this 'extra' joint is managed by a
# limit3 component after homing
TYPE = LINEAR
HOME_SEQUENCE = 10
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MIN_LIMIT = -10
MAX_LIMIT = 10
MAX_VELOCITY = 5
MAX_ACCELERATION = 100
[JOINT_12]
# this 'extra' joint is managed by a
# limit3 component after homing
TYPE = LINEAR
HOME_SEQUENCE = 11
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MIN_LIMIT = -10
MAX_LIMIT = 10
MAX_VELOCITY = 5
MAX_ACCELERATION = 100
[JOINT_13]
# this 'extra' joint is managed by a
# limit3 component after homing
TYPE = LINEAR
HOME_SEQUENCE = 12
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MIN_LIMIT = -10
MAX_LIMIT = 10
MAX_VELOCITY = 5
MAX_ACCELERATION = 100
[JOINT_14]
# this 'extra' joint is managed by a
# limit3 component after homing
TYPE = LINEAR
HOME_SEQUENCE = 13
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MIN_LIMIT = -10
MAX_LIMIT = 10
MAX_VELOCITY = 5
MAX_ACCELERATION = 100
[JOINT_15]
# Uses IMMEDIATE homing
# this 'extra' joint is managed by a
# limit3 component after homing
TYPE = LINEAR
HOME_SEQUENCE = 14
HOME_SEARCH_VEL = 0
HOME_LATCH_VEL = 0
MIN_LIMIT = -10
MAX_LIMIT = 10
MAX_VELOCITY = 5
MAX_ACCELERATION = 100

View File

@@ -0,0 +1,61 @@
# 1extrajoint demo
# immediate homing -- jog joint4 to make a motor-offset before homing
loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
addf motion-command-handler servo-thread
addf motion-controller servo-thread
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
net J0:loop <= joint.0.motor-pos-cmd
net J0:loop => joint.0.motor-pos-fb
net J1:loop <= joint.1.motor-pos-cmd
net J1:loop => joint.1.motor-pos-fb
net J2:loop <= joint.2.motor-pos-cmd
net J2:loop => joint.2.motor-pos-fb
net J3:loop <= joint.3.motor-pos-cmd
net J3:loop => joint.3.motor-pos-fb
#--------------------------------------------
# extra joint (joint4)
# For simulation just connect pos-cmd to pos-fb:
net J4:loop <= joint.4.motor-pos-cmd
net J4:loop => joint.4.motor-pos-fb
# NOTE: For a stepgen in position control mode:
# net J4:loop <= joint.4.motor-pos-cmd
# net J4:loop => joint.4.motor-pos-fb
# net J4:loop => stepgen_position_command
# NOTE: A stepgen can be also used in velocity control mode
# with a PID loop but it is not necessarily required
# and position mode control is much simpler
# NOTE: For a pid motor controller (motor/amplifier/encoder):
# net J4:cmd <= joint.4.motor-pos-cmd
# net J4:cmd => pid_command_input
# net J4:fb <= encoder_measurement_output
# net J4:fb => joint.4.motor-pos-fb
#-----------------------------------------------------------
# motion planner for extra joint (joint4)
loadrt limit3 names=j4.limit3
# These constraints apply to homing managed by
# LinuxCNC and post-homing managed by the limit3 component:
setp j4.limit3.min [JOINT_4]MIN_LIMIT
setp j4.limit3.max [JOINT_4]MAX_LIMIT
setp j4.limit3.maxv [JOINT_4]MAX_VELOCITY
setp j4.limit3.maxa [JOINT_4]MAX_ACCELERATION
addf j4.limit3 servo-thread
net J4:out <= j4.limit3.out
net J4:out => joint.4.posthome-cmd
net J4:enable <= joint.4.homed
net J4:enable => j4.limit3.enable

View File

@@ -0,0 +1,82 @@
# This sim config uses 'immediate' homing
# To demonstrate motor-offsets:
# jog the extra joint(4) away from its turn-on position
# then home-all
[EMC]
MACHINE = 1extrajoint
VERSION = 1.1
[APPLICATIONS]
APP = halshow --fformat %.6f extrajoints.halshow
APP = sim_pin --title "j4 extrajoint" \
j4.limit3.min \
j4.limit3.max \
j4.limit3.maxv \
j4.limit3.maxa \
j4.limit3.in
[KINS]
JOINTS = 5
# NOTE: 4 kinematic joints + 1 extra (motmod) total=5
KINEMATICS = trivkins coordinates=XYYZ kinstype=both
[EMCMOT]
EMCMOT = motmod num_extrajoints=1
SERVO_PERIOD = 1000000
[HAL]
HALFILE = 1extrajoint.hal
HALUI = halui
[DISPLAY]
DISPLAY = axis
MAX_LINEAR_VELOCITY = 1
PROGRAM_PREFIX = .
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
[RS274NGC]
PARAMETER_FILE = sim.var
[TRAJ]
COORDINATES = XYYZ
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
[JOINT_0]
TYPE = LINEAR
HOME_SEQUENCE = 1
MAX_VELOCITY = 10
MAX_ACCELERATION = 100
[JOINT_1]
TYPE = LINEAR
HOME_SEQUENCE = -2
MAX_VELOCITY = 10
MAX_ACCELERATION = 100
[JOINT_2]
TYPE = LINEAR
HOME_SEQUENCE = -2
MAX_VELOCITY = 10
MAX_ACCELERATION = 100
[JOINT_3]
TYPE = LINEAR
HOME_SEQUENCE = 3
MAX_VELOCITY = 10
MAX_ACCELERATION = 100
[JOINT_4]
# this 'extra' joint is managed by a
# limit3 component after homing
TYPE = LINEAR
HOME_SEQUENCE = 0
MIN_LIMIT = -10
MAX_LIMIT = 10
MAX_VELOCITY = 5
MAX_ACCELERATION = 100

View File

@@ -0,0 +1,37 @@
1extrajoint demo
Demo of the motmod num_extrajoints= parameter
a) XYYZ correspond one-to-one to
joints 0123
b) Joint4 is an 'extra joint' that is
not related to any axis letter but
is managed independently by a limit3
component.
c) All joints use 'immediate homing'
d) Using extra joints requires
NON-identity kinematics and all
joints (including joint4) must be
homed before switching to world
mode.
e) A halshow app is opened to display
key pin values
f) A sim_pin app is opened to set key
pin values
Usage:
1) F1 (Estop Off)
2) F2 (Machine On)
3) jog joint4 to create a small offset
4) Ctrl-HOME (Home all)
5) demonstrate joint.4 movement using
the provided M144 mdi command:
M144 P4 Q1.23 ;move joint.4 to 1.23
M144 P4 Q3.21 ;move joint.4 to 3.21
6) Alternately, demonstrate joint.[45]
movement using sim_pin settings:
j4.limit3.min min value
j4.limit3.max max value
j4.limit3.maxv max velocity
j4.limit3.maxa max acceleration
j4.limit3.in requested value

View File

@@ -0,0 +1,30 @@
# use limit3 for motion planning:
loadrt limit3 names=j4.limit3,j5.limit3
# These constraints apply to homing managed by
# LinuxCNC and post-homing managed by the limit3 component:
setp j4.limit3.min [JOINT_4]MIN_LIMIT
setp j4.limit3.max [JOINT_4]MAX_LIMIT
setp j4.limit3.maxv [JOINT_4]MAX_VELOCITY
setp j4.limit3.maxa [JOINT_4]MAX_ACCELERATION
addf j4.limit3 servo-thread
net J4:out <= j4.limit3.out
net J4:out => joint.4.posthome-cmd
net J4.enable <= joint.4.homed
net J4.enable => j4.limit3.enable
setp j5.limit3.min [JOINT_5]MIN_LIMIT
setp j5.limit3.max [JOINT_5]MAX_LIMIT
setp j5.limit3.maxv [JOINT_5]MAX_VELOCITY
setp j5.limit3.maxa [JOINT_5]MAX_ACCELERATION
addf j5.limit3 servo-thread
net J5:out <= j5.limit3.out
net J5:out => joint.5.posthome-cmd
net J5.enable <= joint.5.homed
net J5.enable => j5.limit3.enable

View File

@@ -0,0 +1,107 @@
[EMC]
MACHINE = 2extrajoints
VERSION = 1.1
[APPLICATIONS]
APP = halshow --fformat %.6f extrajoints.halshow
APP = sim_pin --title "j4 extrajoint" \
j4.limit3.min \
j4.limit3.max \
j4.limit3.maxv \
j4.limit3.maxa \
j4.limit3.in
APP = sim_pin --title "j5 extrajoints" \
j5.limit3.min \
j5.limit3.max \
j5.limit3.maxv \
j5.limit3.maxa \
j5.limit3.in
[KINS]
JOINTS = 6
#NOTE: 4 conventional joints, 2 extra (motmod) total=6
KINEMATICS = trivkins coordinates=XYYZ kinstype=both
[EMCMOT]
EMCMOT = motmod num_extrajoints=2
SERVO_PERIOD = 1000000
[HAL]
HALFILE = LIB:basic_sim.tcl
HALFILE = ./2extrajoints.hal
HALUI = halui
[DISPLAY]
DISPLAY = axis
MAX_LINEAR_VELOCITY = 1
PROGRAM_PREFIX = .
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
[RS274NGC]
PARAMETER_FILE = sim.var
[TRAJ]
COORDINATES = XYYZ
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
[JOINT_0]
TYPE = LINEAR
HOME_SEQUENCE = 1
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MAX_VELOCITY = 10
MAX_ACCELERATION = 100
[JOINT_1]
TYPE = LINEAR
HOME_SEQUENCE = -2
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MAX_VELOCITY = 10
MAX_ACCELERATION = 100
[JOINT_2]
TYPE = LINEAR
HOME_SEQUENCE = -2
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MAX_VELOCITY = 10
MAX_ACCELERATION = 100
[JOINT_3]
TYPE = LINEAR
HOME_SEQUENCE = 3
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MAX_VELOCITY = 10
MAX_ACCELERATION = 100
[JOINT_4]
# this 'extra' joint is managed by a
# limit3 component after homing
TYPE = LINEAR
HOME_SEQUENCE = 0
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MIN_LIMIT = -10
MAX_LIMIT = 10
MAX_VELOCITY = 5
MAX_ACCELERATION = 100
[JOINT_5]
# this 'extra' joint is managed by a
# limit3 component after homing
TYPE = LINEAR
HOME_SEQUENCE = 0
HOME_SEARCH_VEL = 20
HOME_LATCH_VEL = 20
MIN_LIMIT = -10
MAX_LIMIT = 10
MAX_VELOCITY = 5
MAX_ACCELERATION = 100

View File

@@ -0,0 +1,46 @@
2extrajoints demo
Demo of the motmod num_extrajoints= parameter
a) XYYZ correspond one-to-one to
joints 0123
b) joint.4 and joint.5 are 'extra'
joints not related to any axis
letter but managed independently by
limit3 components.
c) The configuration uses basic_sim.tcl
and simulates home switches for all
joints.
d) Using extra joints requires
NON-identity kinematics and all
joints (including joint4) must be
homed before switching to world
mode.
e) A halshow app is opened to display
key pin values
f) A sim_pin app is opened to set key
pin values
Usage:
1) F1 (Estop Off)
2) F2 (Machine On)
3) optionally jog joint.4 and joint.5
prior to homing to observe motor
offset
4) Ctrl-HOME (Home all)
5) demonstrate joint.[45] movement
using the provided M144 mdi
command:
M144 P4 Q1.23 move joint.4 to 1.23
M144 P4 Q4.56 move joint.4 to 4.56
M144 P5 Q3.21 move joint.5 to 3.21
M144 P5 Q2.22 move joint.5 to 2.22
etc.
6) Alternately, demonstrate joint.[45]
movement using sim_pin settings:
j4.limit3.min min value
j4.limit3.max max value
j4.limit3.maxv max velocity
j4.limit3.maxa max acceleration
j4.limit3.in requested value
similar for j5

View File

@@ -0,0 +1,35 @@
#!/usr/bin/tclsh
# M144 demo for extra joints
# Usage: M144 [Pjoint_num] [Qposition]
# Mcodes substitute "-1.000000" for omitted p,q values
# so these are handled as special cases
# Note: this also disallows a q value of -1 (sigh)
set min_joint_num 4
set max_joint_num 15
proc fail {msg} {
puts "\nFAIL: $::argv0 $msg"
puts "Usage: $::argv0 P<jointnumber> Q<position>"
exit 1
}
set p [lindex $::argv 0]
set q [lindex $::argv 1]
if {"$p" == "-1.000000"} {fail "Missing Pvalue"}
if {"$q" == "-1.000000"} {fail "Missing Qvalue (or -1)"}
set p [expr int($p)]
if {$p < $min_joint_num || $p > $max_joint_num} {
fail "Bad Pvalue (extra joint number) <$p>"
}
set cmd "halcmd setp j${p}.limit3.in $q"
if [catch {eval exec $cmd} msg] {
fail "Command:$cmd\n$msg"
}
puts "\nOK: $::argv0: $cmd"
exit 0

View File

@@ -0,0 +1,18 @@
extrajoints demos
1extrajoint
5 joints total
1 extra joint (joint.4)
immediate homing
(jog joint4 before homing to
create a small motor offset)
2extrajoints
6 joints total
2 extra joints (joint.4,5)
simulated home switches
12extrajoints
16 joints total
12 extra joints (joint.4-15)
simulated home switches

View File

@@ -0,0 +1,28 @@
pin+j4.limit3.in
pin+j4.limit3.out
pin+joint.4.posthome-cmd
pin+joint.4.homed
pin+joint.4.motor-pos-cmd
pin+joint.4.motor-pos-fb
pin+joint.4.motor-offset
pin+j4.limit3.max
pin+j4.limit3.min
pin+j4.limit3.maxv
pin+j4.limit3.maxa
pin+j5.limit3.in
pin+j5.limit3.out
pin+joint.5.posthome-cmd
pin+joint.5.homed
pin+joint.5.motor-pos-cmd
pin+joint.5.motor-pos-fb
pin+joint.5.motor-offset
pin+j5.limit3.max
pin+j5.limit3.min
pin+j5.limit3.maxv
pin+j5.limit3.maxa

View File

@@ -0,0 +1,35 @@
# extrajoints.tcl (requires [HAL]TWOPASS
# create limit3 and signals for all extra joints
set script [file tail [info script]]
set min_joint_num 0 ;# first possible extra joint
set max_joint_num 15 ;# last possible extra joint
for {set j $min_joint_num} {$j <= $max_joint_num} {incr j} {
if [catch {getp joint.${j}.posthome-cmd} msg] {
#puts "$::argv0: skip $j"
continue
} else {
if [::tp::passnumber] {
puts "$script: Create limit3 for extra joint $j"
}
}
catch {
# use limit3 for motion planning:
loadrt limit3 names=j${j}.limit3
addf j${j}.limit3 servo-thread
# These constraints apply to homing managed by
# LinuxCNC and post-homing managed by the limit3 component:
setp j${j}.limit3.min [set ::JOINT_[set j](MIN_LIMIT)]
setp j${j}.limit3.max [set ::JOINT_[set j](MAX_LIMIT)]
setp j${j}.limit3.maxv [set ::JOINT_[set j](MAX_VELOCITY)]
setp j${j}.limit3.maxa [set ::JOINT_[set j](MAX_ACCELERATION)]
net J${j}:out <= j${j}.limit3.out
net J${j}:out => joint.${j}.posthome-cmd
net J${j}.enable <= joint.${j}.homed
net J${j}.enable => j${j}.limit3.enable
}
}