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 @@
ServoToGo

View File

@@ -0,0 +1,244 @@
# 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-STG
#+ 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]
#+ Name of display program, e.g., axis
# DISPLAY = axis
DISPLAY = tklinuxcnc
# Cycle time, in seconds, that display will sleep between polls
CYCLE_TIME = 0.200
#- Path to help file
HELP_FILE = tklinuxcnc.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
###############################################################################
# Task controller section
###############################################################################
[FILTER]
#No Content
[RS274NGC]
#- File containing interpreter variables
PARAMETER_FILE = stg.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 - will be rounded to an int multiple of BASE_PERIOD
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 = core_servo.hal
HALFILE = stg_motion.hal
HALFILE = stg_io.hal
#- 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 R P W
COORDINATES = X Y Z
HOME = 0 0 0
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 0.424
MAX_LINEAR_VELOCITY = 30.48
DEFAULT_LINEAR_ACCELERATION = 300.0
MAX_LINEAR_ACCELERATION = 500.0
###############################################################################
# Axes sections
###############################################################################
#+ First axis
# each setting is commented for axis_0
[EMCIO]
#- tool table file
TOOL_TABLE = stg.tbl
[KINS]
KINEMATICS = trivkins
JOINTS = 3
[AXIS_X]
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
MAX_VELOCITY = 30.48
MAX_ACCELERATION = 500.0
[JOINT_0]
# type of axis, LINEAR vs. ROTARY
TYPE = LINEAR
# home position
HOME = 0.000
# maximum velocity
MAX_VELOCITY = 30.48
# maximum acceleration
MAX_ACCELERATION = 500.0
# mechanical backlash measured
BACKLASH = 0.000
# time to update the axis
# number of encoder ticks / unit
INPUT_SCALE = 200
# dac gain for output
OUTPUT_SCALE = 1.000
# dac bias for output
OUTPUT_OFFSET = 0.000
# minimum travel limit (from position 0)
MIN_LIMIT = -1000.0
# maximum travel limit (from position 0)
MAX_LIMIT = 1000.0
# following error at max speed
FERROR = 1.270
# following error when halted
MIN_FERROR = 0.254
# read HAL_Introduction.pdf for an insight about Homing
HOME_OFFSET = 0.0
HOME_SEARCH_VEL = 0.0
HOME_LATCH_VEL = 0.0
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = NO
# PID tuning params
MAX_OUTPUT = 1.0
DEADBAND = 0.000381
P = 100.0
I = 0.000
D = 0.000
FF0 = 0.000
FF1 = 0.000
FF2 = 0.0
BIAS = 0.000
#+ Second axis
[AXIS_Y]
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
MAX_VELOCITY = 30.48
MAX_ACCELERATION = 500.0
[JOINT_1]
TYPE = LINEAR
HOME = 0.000
MAX_VELOCITY = 30.48
MAX_ACCELERATION = 500.0
BACKLASH = 0.000
INPUT_SCALE = 200
OUTPUT_SCALE = 1.000
OUTPUT_OFFSET = 0.000
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
FERROR = 1.270
MIN_FERROR = 0.254
HOME_OFFSET = 0.0
HOME_SEARCH_VEL = 0.0
HOME_LATCH_VEL = 0.0
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = NO
# PID tuning params
MAX_OUTPUT = 1.0
DEADBAND = 0.000381
P = 100.0
I = 0.000
D = 0.000
FF0 = 0.000
FF1 = 0.000
FF2 = 0.0
BIAS = 0.000
#+ Third axis
[AXIS_Z]
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
MAX_VELOCITY = 30.48
MAX_ACCELERATION = 500.0
[JOINT_2]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 30.48
MAX_ACCELERATION = 500.0
BACKLASH = 0.000
INPUT_SCALE = 200
OUTPUT_SCALE = 1.000
OUTPUT_OFFSET = 0.000
MIN_LIMIT = -1000.0
MAX_LIMIT = 1000.0
FERROR = 1.270
MIN_FERROR = 0.254
HOME_OFFSET = 0.0
HOME_SEARCH_VEL = 0.0
HOME_LATCH_VEL = 0.0
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = NO
# PID tuning params
MAX_OUTPUT = 1.0
DEADBAND = 0.000381
P = 100.0
I = 0.000
D = 0.000
FF0 = 0.000
FF1 = 0.000
FF2 = 0.0
BIAS = 0.000
###############################################################################
# section for main IO controller parameters
###############################################################################

View File

@@ -0,0 +1,4 @@
T1 P1 D0.125000 Z+0.511000 ;1/8 end mill
T2 P2 D0.062500 Z+0.100000 ;1/16 end mill
T3 P3 D0.201000 Z+1.273000 ;#7 tap drill
T99999 P99999 Z+0.100000 ;big tool number

View File

@@ -0,0 +1,32 @@
This configuration step is intended for servo machines running the ServoToGo card.
Both the STG1 and STG2 are supported.
You can have either a standard pinout (LinuxCNC style) or you could make a new one which would suit your own custom cabling.
Right now the ini file is for metric setup, but an inch specific one could be easily added.
Detailed description:
* nml files
-- it uses a default nml file (found in configs/common/linuxcnc.nml)
* hal files
-- it uses a default servo hal file (configs/common/core_servo.hal)
-- stg_motion.hal - this is the main hal file for the STG, it loads the stg driver and sets up motion specific links, it is fairly well commented, so it should be easy to read / modify.
-- stg_io.hal - this is the second hal file for the STG, it configures IO specific links (like the pin number where the X limit switch is, or where the spindle start pin is connected), it is fairly well commented, so it should be easy to read / modify. This servo setup is mostly for serious machines, so the ESTOP should really be planned / implemented properly (that means use an external ESTOP chain, and let LinuxCNC know about it, and let LinuxCNC interrupt the external chain too).
Read more about this in the wiki at http://wiki.linuxcnc.org/
* additional files
-- stg.tbl - this is the tool table file, and it holds definitions for the tools used, along with tool sizes for compensation (tool length & tool diameter)
-- stg.var - the variables file. This file is used by the interpreter to save internal variables when LinuxCNC shuts down, and rereads them on the next startup.
Further specific information can be found in the LinuxCNC wiki:
http://wiki.linuxcnc.org/

View File

@@ -0,0 +1,111 @@
# HAL config file for ServoToGo STG ISA board
#
# install driver (only needed if stg_motion.hal doesn't get run)
#loadrt hal_stg
# add I/O to servo thread so they will be evaluated
# every servo period
# read inputs first
addf stg.di-read servo-thread 1
# write outputs last
addf stg.do-write servo-thread 1
#uncomment following line if ADC's are needed (for example spindle-tach feedback)
#addf stg.0.read-adcs servo-thread 1
#
# Connect motion controller I/Os
#
# connect limit/home switch outputs to motion controller
net Xminlim <= stg.in-02
net Xminlim => joint.0.neg-lim-sw-in
net Xmaxlim <= stg.in-01
net Xmaxlim => joint.0.pos-lim-sw-in
net Xhome <= stg.in-00
net Xhome => joint.0.home-sw-in
net Yminlim <= stg.in-06
net Yminlim => joint.1.neg-lim-sw-in
net Ymaxlim <= stg.in-05
net Ymaxlim => joint.1.pos-lim-sw-in
net Yhome <= stg.in-04
net Yhome => joint.1.home-sw-in
net Zminlim <= stg.in-10
net Zminlim => joint.2.neg-lim-sw-in
net Zmaxlim <= stg.in-09
net Zmaxlim => joint.2.pos-lim-sw-in
net Zhome <= stg.in-08
net Zhome => joint.2.home-sw-in
#continue in the same manner for further axes (A,B,C)
# connect amp faults to motion controller
net Xfault <= stg.in-03
net Xfault => joint.0.amp-fault-in
net Yfault <= stg.in-07
net Yfault => joint.1.amp-fault-in
net Zfault <= stg.in-11
net Zfault => joint.2.amp-fault-in
# connect index pulses to motion controller
# do these when index pulsing is figured out
#newsig Xindex bit
#newsig Yindex bit
#newsig Zindex bit
#linksp Xindex <= stg.0.enc-index
#linksp Xindex => joint.0.index-enable
#linksp Yindex <= stg.1.enc-index
#linksp Yindex => joint.1.index-enable
#linksp Zindex <= stg.2.enc-index
#linksp Zindex => joint.2.index-enable
# connect amp enables to motion controller
net Xenable => stg.out-00
net Yenable => stg.out-01
net Zenable => stg.out-02
# connect watchdog reset to motion controller
# needs watchdo
#newsig WatchdogRst bit
#linksp WatchdogRst <= stg.watchdog-reset
#linksp WatchdogRst => motion.watchdog-reset-out
#
# Connect I/O controller I/Os
#
# connect e-stop write/sense to I/O controller
# these connections assume an external ESTOP circuitry will be used
# if it's not used, comment the next lines and uncomment the loopback
net EstopSense <= stg.in-12
net EstopSense => iocontrol.0.emc-enable-in
net EstopWrite <= stg.out-07
net EstopWrite => iocontrol.0.user-enable-out
# ESTOP loopback, only use this for a simple machine without external ESTOP
# you really SHOULDN'T use a servo machine without proper ESTOP
#net estop-loop iocontrol.0.user-enable-out iocontrol.0.emc-enable-in
# connect spindle fwd/rev to I/O controller
net SpindleFwd <= stg.out-06
net SpindleFwd => spindle.0.forward
net SpindleRev <= stg.out-05
net SpindleRev => spindle.0.reverse
# connect spindle brake to I/O controller
net SpindleBrakeOn <= stg.out-10
net SpindleBrakeOn => spindle.0.brake
# connect mist/flood coolant to I/O controller
net MistOn <= stg.out-11
net MistOn => iocontrol.0.coolant-mist
net FloodOn <= stg.out-12
net FloodOn => iocontrol.0.coolant-flood
# 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

View File

@@ -0,0 +1,37 @@
# HAL config file for ServoToGo STG ISA board
#
# install driver, this should autodetect the board
# if that doesn't work, try using base=0xABC, where ABC matches your setup
# loadrt hal_stg base=0x200
loadrt hal_stg
# add functions to servo thread so they will be evaluated
# every servo period
# read inputs first
addf stg.capture-position servo-thread 1
# write outputs last
addf stg.write-dacs servo-thread -1
# connect position feedback signals to encoders
net Xpos-fb <= stg.0.position
net Ypos-fb <= stg.1.position
net Zpos-fb <= stg.2.position
# get feedback scaling from ini file
setp stg.0.position-scale [JOINT_0]INPUT_SCALE
setp stg.1.position-scale [JOINT_1]INPUT_SCALE
setp stg.2.position-scale [JOINT_2]INPUT_SCALE
# connect PID output signals to DACs
net Xoutput => stg.0.dac-value
net Youtput => stg.1.dac-value
net Zoutput => stg.2.dac-value
# set output scaling from ini file
setp stg.0.dac-gain [JOINT_0]OUTPUT_SCALE
setp stg.1.dac-gain [JOINT_1]OUTPUT_SCALE
setp stg.2.dac-gain [JOINT_2]OUTPUT_SCALE
# set output offset to zero
setp stg.0.dac-offset [JOINT_0]OUTPUT_OFFSET
setp stg.1.dac-offset [JOINT_1]OUTPUT_OFFSET
setp stg.2.dac-offset [JOINT_2]OUTPUT_OFFSET