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

1
configs/by_interface/pluto/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
axis_manualtoolchange.hal

View File

@@ -0,0 +1 @@
Pluto fpga boards

View File

@@ -0,0 +1 @@
This configuration is for a hobby sized (Sherline) servo-operated lathe based on the Pluto servo driver. The hardware is a Pluto FPGA board ($60) which counts the encoders and generates up/down PWM at high frequency in order to drive H bridges for the lathe's servos. On this prototype machine both servos are driven with one L298 dual H bridge (which is usually used to drive one stepper.) This is an example of (very) inexpensive servo use on a hobby machine and it gives very good performance.

View File

@@ -0,0 +1,9 @@
T1 P1 D0.100000 Z+0.100000 I+95.000000 J+155.000000 Q1 ;
T2 P2 D0.100000 I+85.000000 J+25.000000 Q2 ;
T3 P3 D0.100000 I+275.000000 J+335.000000 Q3 ;
T4 P4 D0.100000 I+265.000000 J+205.000000 Q4 ;
T5 P5 D0.100000 I+210.000000 J+150.000000 Q5 ;
T6 P6 D0.100000 X+0.500000 Z+0.500000 I+120.000000 J+60.000000 Q6 ;
T7 P7 D0.100000 I-30.000000 J+30.000000 Q7 ;
T8 P8 D0.100000 I+240.000000 J+300.000000 Q8 ;
T9 P9 D0.100000 Q9 ;

View File

@@ -0,0 +1,107 @@
# load realtime modules
loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadrt pid num_chan=2 debug=1
loadrt ddt count=4
loadrt pluto_servo
loadrt scale
loadrt mux2
loadrt debounce cfg=1
loadrt limit1 count=1
# define the order of execution for RT code
addf pluto-servo.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 pluto-servo.write servo-thread
addf ddt.0 servo-thread
addf ddt.1 servo-thread
addf ddt.2 servo-thread
addf ddt.3 servo-thread
addf scale.0 servo-thread
addf mux2.0 servo-thread
addf debounce.0 servo-thread
addf limit1.0 servo-thread
setp pluto-servo.encoder.0.scale [JOINT_0]INPUT_SCALE
setp pluto-servo.encoder.1.scale [JOINT_2]INPUT_SCALE
setp pluto-servo.encoder.2.scale -4096
setp pluto-servo.pwm.0.scale 26 # volts supply
setp pluto-servo.pwm.1.scale 26
setp pid.0.maxoutput 26 # volts at motor
setp pid.1.maxoutput 26
# the values below come from the ini
setp pid.0.Pgain [JOINT_0]P
setp pid.0.Igain [JOINT_0]I
setp pid.0.Dgain [JOINT_0]D
setp pid.0.bias [JOINT_0]BIAS
setp pid.0.FF0 [JOINT_0]FF0
setp pid.0.FF1 [JOINT_0]FF1
setp pid.0.FF2 [JOINT_0]FF2
setp pid.0.deadband [JOINT_0]DEADBAND
setp pid.1.Pgain [JOINT_2]P
setp pid.1.Igain [JOINT_2]I
setp pid.1.Dgain [JOINT_2]D
setp pid.1.bias [JOINT_2]BIAS
setp pid.1.FF0 [JOINT_2]FF0
setp pid.1.FF1 [JOINT_2]FF1
setp pid.1.FF2 [JOINT_2]FF2
setp pid.1.deadband [JOINT_2]DEADBAND
net Xpos-fb pluto-servo.encoder.0.position => pid.0.feedback joint.0.motor-pos-fb
net Zpos-fb pluto-servo.encoder.1.position => pid.1.feedback joint.2.motor-pos-fb
net Xpos-cmd joint.0.motor-pos-cmd => pid.0.command ddt.0.in
net Zpos-cmd joint.2.motor-pos-cmd => pid.1.command ddt.2.in
net Xvel-cmd pid.0.output => pluto-servo.pwm.0.value
net Zvel-cmd pid.1.output => pluto-servo.pwm.1.value
net Xvel ddt.0.out => ddt.1.in
net Xacc ddt.1.out
net Zvel ddt.2.out => ddt.3.in
net Zacc ddt.3.out
# machine ON
net Xenable joint.0.amp-enable-out => pid.0.enable pluto-servo.pwm.0.enable pluto-servo.dout.09
net Zenable joint.2.amp-enable-out => pid.1.enable pluto-servo.pwm.1.enable
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
# spindle SSR
# net spindle-fwd spindle.0.forward pluto-servo.dout.00
setp debounce.0.delay 3
net Xswitch pluto-servo.din.00-not => debounce.0.0.in
net Xswitch-debounced debounce.0.0.out => joint.0.home-sw-in joint.0.pos-lim-sw-in
# 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
# spindle speed control
setp pluto-servo.pwm.3.enable 1
# this needs scale/offset to give the right speeds, but 0 should be 0
net spindle-speed-cmd spindle.0.speed-out => limit1.0.in
net spindle-speed-cmd-limited limit1.0.out => scale.0.in
setp scale.0.gain 0.00026315789 # 1/3800
setp scale.0.offset 0.105
setp mux2.0.in0 0
setp limit1.0.max 1300
net spindle-speed-scaled scale.0.out => mux2.0.in1
net spindle-fwd spindle.0.forward => mux2.0.sel pluto-servo.dout.00
net spindle-pwm mux2.0.out => pluto-servo.pwm.3.value
# spindle position, for threading
net spindle-index spindle.0.index-enable <=> pluto-servo.encoder.2.index-enable
net spindle-pos pluto-servo.encoder.2.position => spindle.0.revs
net spindle-speed-fb pluto-servo.encoder.2.velocity => spindle.0.speed-in

View File

@@ -0,0 +1,127 @@
[EMC]
VERSION = 1.1
MACHINE = LATHE-PLUTO
DEBUG = 0
[DISPLAY]
PYVCP = vcp.xml
DISPLAY = axis
LATHE = 1
CYCLE_TIME = 0.200
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
MAX_FEED_OVERRIDE = 1.5
PROGRAM_PREFIX = ../../nc_files/
# Editor to be used with Axis
#EDITOR = geany
[FILTER]
PROGRAM_EXTENSION = .py Python Script
PROGRAM_EXTENSION = .NGC rs274ngc files
py = python3
[RS274NGC]
PARAMETER_FILE = emc.var
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
SERVO_PERIOD = 500000
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
[HAL]
HALFILE = lathe-pluto.hal
HALFILE = axis_manualtoolchange.hal
POSTGUI_HALFILE = postgui.hal
[HALUI]
#No Content
[TRAJ]
COORDINATES = X Z
HOME = 0 0 0
LINEAR_UNITS = mm
ANGULAR_UNITS = deg
DEFAULT_LINEAR_VELOCITY = 10
MAX_LINEAR_VELOCITY = 32.5
DEFAULT_LINEAR_ACCELERATION = 400
MAX_LINEAR_ACCELERATION = 707
[EMCIO]
TOOL_TABLE = emc.tbl
TOOL_CHANGE_POSITION = 40 0 20
[KINS]
KINEMATICS = trivkins
JOINTS = 3
[AXIS_X]
MIN_LIMIT = -10.0
MAX_LIMIT = 40.50001
MAX_VELOCITY = 23
MAX_ACCELERATION = 500
[JOINT_0]
TYPE = LINEAR
UNITS = 1.0
HOME = 40.5
MAX_VELOCITY = 23
MAX_ACCELERATION = 500
BACKLASH = 0.06
CYCLE_TIME = 0.001000
INPUT_SCALE = 6000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -10.0
MAX_LIMIT = 40.50001
FERROR = .1
MIN_FERROR = .03
HOME_OFFSET = 41.14
HOME_SEARCH_VEL = 12
HOME_LATCH_VEL = -0.2
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = YES
P = 1000
I = 30000
D = 7
BIAS = 0
FF0 = 0
FF1 = 1
FF2 = 0.025
DEADBAND=.00009
[AXIS_Z]
MIN_LIMIT = -1.0
MAX_LIMIT = 90.0
MAX_VELOCITY = 23
MAX_ACCELERATION = 500
[JOINT_2]
TYPE = LINEAR
UNITS = 1.0
HOME = 0.000
MAX_VELOCITY = 23
MAX_ACCELERATION = 500
BACKLASH = 0.00
CYCLE_TIME = 0.001000
INPUT_SCALE = -6000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -1.0
MAX_LIMIT = 90.0
FERROR = 0.35
MIN_FERROR = 0.20
HOME_OFFSET = 0.0
HOME_SEARCH_VEL = 0.0
HOME_LATCH_VEL = 0.0
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = NO
P = 1000
I = 30000
D = 7
BIAS = 0
FF0 = 0
FF1 = 1
FF2 = 0.025
DEADBAND=.00009

View File

@@ -0,0 +1,4 @@
net Xvel-cmd pyvcp.xpid-bar
net Zvel-cmd pyvcp.zpid-bar
net spindle-speed-cmd pyvcp.spindle-bar

View File

@@ -0,0 +1,13 @@
<?xml version='1.0' encoding='UTF-8'?>
<pyvcp>
<label><text>"X PID"</text></label>
<bar><halpin>"xpid-bar"</halpin><min_>-26</min_><max_>26</max_></bar>
<label><text>"Z PID"</text></label>
<bar><halpin>"zpid-bar"</halpin><min_>-26</min_><max_>26</max_></bar>
<label><text>"Spindle"</text></label>
<bar><halpin>"spindle-bar"</halpin><min_>0</min_><max_>1500</max_></bar>
</pyvcp>

View File

@@ -0,0 +1,195 @@
# EMC controller parameters for generic controller. Make these what you need
# for your system.
# General note: Comments can either be preceded with a # or ; - either is
# acceptable, although # is in keeping with most linux config files.
# Settings with a + at the front of the comment are likely needed to get
# changed by the user.
# Settings with a - at the front are highly unneeded to be changed
###############################################################################
# General section
###############################################################################
[EMC]
#- Version of this INI file
VERSION = 1.1
#+ Name of machine, for use with display, etc.
MACHINE = LinuxCNC-HAL-STEP-PLUTO
#+ Debug level, 0 means no messages. See src/emc/nml_int/emcglb.h for others
DEBUG = 0
# DEBUG = 0x00000007
# DEBUG = 0x7FFFFFFF
###############################################################################
# Sections for display options
###############################################################################
[DISPLAY]
DISPLAY = axis
# Cycle time, in seconds, that display will sleep between polls
CYCLE_TIME = 0.200
#- Path to help file
HELP_FILE = doc/help.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.2
#- Prefix to be used
PROGRAM_PREFIX = ../../nc_files/
#- Introductory graphic
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 5
# Editor to be used with Axis
#EDITOR = geany
###############################################################################
# Task controller section
###############################################################################
[FILTER]
#No Content
[RS274NGC]
#- File containing interpreter variables
PARAMETER_FILE = stepper.var
###############################################################################
# Motion control section
###############################################################################
[EMCMOT]
#- Name of the motion controller to use (only one exists for nontrivkins)
EMCMOT = motmod
#- Timeout for comm to emcmot, in seconds
COMM_TIMEOUT = 1.0
#- Servo task period, in nanosecs
SERVO_PERIOD = 1000000
###############################################################################
# Hardware Abstraction Layer section
###############################################################################
[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
###############################################################################
# Part program interpreter section
###############################################################################
[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 = pluto_pinout.hal
HALFILE =
#- list of halcmd commands to execute
# commands are executed in the order in which they appear
#HALCMD = save neta
###############################################################################
# Trajectory planner section
###############################################################################
[HALUI]
#No Content
[TRAJ]
#+ machine specific settings
# COORDINATES = X Y Z A B C
COORDINATES = X Y Z
HOME = 0 0 0
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 1.2
MAX_LINEAR_VELOCITY = 1.2
DEFAULT_LINEAR_ACCELERATION = 15.0
MAX_LINEAR_ACCELERATION = 20.0
###############################################################################
# Axes sections
###############################################################################
#+ First axis
[EMCIO]
#- tool table file
TOOL_TABLE = stepper.tbl
[KINS]
KINEMATICS = trivkins
JOINTS = 3
[AXIS_X]
MIN_LIMIT = -10.0
MAX_LIMIT = 10.0
MAX_VELOCITY = .5667
MAX_ACCELERATION = 20.0
[JOINT_0]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = .5667
MAX_ACCELERATION = 20.0
BACKLASH = 0.000
SCALE = 6400
OUTPUT_SCALE = 1.000
MIN_LIMIT = -10.0
MAX_LIMIT = 10.0
FERROR = 0.050
MIN_FERROR = 0.010
HOME_OFFSET = 0.0
HOME_SEARCH_VEL = 0.0
HOME_LATCH_VEL = 0.0
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = NO
#+ Second axis
[AXIS_Y]
MIN_LIMIT = -10.0
MAX_LIMIT = 10.0
MAX_VELOCITY = .5667
MAX_ACCELERATION = 20.0
[JOINT_1]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = .5667
MAX_ACCELERATION = 20.0
BACKLASH = 0.000
SCALE = 6400
OUTPUT_SCALE = 1.000
MIN_LIMIT = -10.0
MAX_LIMIT = 10.0
FERROR = 0.050
MIN_FERROR = 0.010
HOME_OFFSET = 0.0
HOME_SEARCH_VEL = 0.0
HOME_LATCH_VEL = 0.0
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = NO
#+ Third axis
[AXIS_Z]
MIN_LIMIT = -2.0
MAX_LIMIT = 4.0
MAX_VELOCITY = .3667
MAX_ACCELERATION = 15.0
[JOINT_2]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = .3667
MAX_ACCELERATION = 15.0
BACKLASH = 0.000
SCALE = 8000
OUTPUT_SCALE = 1.000
MIN_LIMIT = -2.0
MAX_LIMIT = 4.0
FERROR = 0.050
MIN_FERROR = 0.010
HOME_OFFSET = 0.0
HOME_SEARCH_VEL = 0.0
HOME_LATCH_VEL = 0.0
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = NO
###############################################################################
# section for main IO controller parameters
###############################################################################

View File

@@ -0,0 +1,40 @@
# first load the core RT modules that will be needed
# kinematics
loadrt [KINS]KINEMATICS
# motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadrt pluto_step
addf pluto-step.read servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf pluto-step.write servo-thread
setp pluto-step.stepgen.0.scale [JOINT_0]SCALE
setp pluto-step.stepgen.1.scale [JOINT_1]SCALE
setp pluto-step.stepgen.2.scale [JOINT_2]SCALE
net Xpos-cmd joint.0.motor-pos-cmd => pluto-step.stepgen.0.position-cmd
net Ypos-cmd joint.1.motor-pos-cmd => pluto-step.stepgen.1.position-cmd
net Zpos-cmd joint.2.motor-pos-cmd => pluto-step.stepgen.2.position-cmd
net Xpos-fb pluto-step.stepgen.0.position-fb => joint.0.motor-pos-fb
net Ypos-fb pluto-step.stepgen.1.position-fb => joint.1.motor-pos-fb
net Zpos-fb pluto-step.stepgen.2.position-fb => joint.2.motor-pos-fb
net Xen joint.0.amp-enable-out => pluto-step.stepgen.0.enable
net Yen joint.1.amp-enable-out => pluto-step.stepgen.1.enable
net Zen joint.2.amp-enable-out => pluto-step.stepgen.2.enable
# create a signal for the estop loopback
net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
# create signals for tool prepare loopback
net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared
# create a signal for "spindle on"
net spindle_on spindle.0.on => pluto-step.dout.00
setp pluto-step.stepgen.steplen 20000
setp pluto-step.stepgen.stepspace 20000
setp pluto-step.stepgen.dirtime 20000