项目开源网站 LinuxCNChttps://www.linuxcnc.org/当前release版本2.8.4
Downloads (linuxcnc.org)https://www.linuxcnc.org/downloads/可以直接下载安装好linuxcnc的实时debian系统,直接刻盘安装就可以了
安装IgH主站,网上有很多教程可供参考
git clone https://gitlab.com/etherlab.org/ethercat.git
安装linuxcnc-ethercat
git clone https://github.com/sittner/linuxcnc-ethercat
-
cd linuxcnc-ethercat
-
sudo make configure
-
sudo make
-
sudo install
安装cia402,控制ethercat伺服需要用到
git clone https://github.com/dbraun1981/hal-cia402
cd hal-cia402
sudo compile --install cia402.comp
配置文件放在linuxcnc/configs/sim.axis下
sd710.ini
# This config file was created 2023-07-27 05:34:43.371981 by the update_ini script
# The original config files may be found in the /home/taotech/linuxcnc/configs/sim.axis/sd710.old.old directory
[EMC]
# The version string for this INI file.
VERSION = 1.1
MACHINE = EtherCAT Machine
DEBUG = 1
[DISPLAY]
DISPLAY = axis
EDITOR = gedit
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
MAX_FEED_OVERRIDE = 1.2
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 0
INCREMENTS = 5mm 1mm .5mm .1mm .05mm .01mm .005mm
[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image
PROGRAM_EXTENSION = .py Python Script
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python
[RS274NGC]
PARAMETER_FILE = linuxcnc.var
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
BASE_PERIOD = 0
SERVO_PERIOD = 1000000
[TASK]
TASK = milltask
CYCLE_TIME = 0.005
[HAL]
HALFILE = sd710.hal
[HALUI]
[TRAJ]
AXES = 1
HOME = 0 0 0
COORDINATES = X
LINEAR_UNITS = mm
ANGULAR_UNITS = deg
DEFAULT_LINEAR_VELOCITY = 100
MAX_LINEAR_VELOCITY = 400
[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100
TOOL_TABLE = tool.tbl
[KINS]
KINEMATICS = trivkins coordinates=X
#This is a best-guess at the number of joints, it should be checked
JOINTS = 1
[AXIS_X]
MIN_LIMIT = -200
MAX_LIMIT = 500
MAX_VELOCITY = 375.0
MAX_ACCELERATION = 2000.0
[JOINT_0]
TYPE = LINEAR
HOME = 0.0
MAX_VELOCITY = 375.0
MAX_ACCELERATION = 2000.0
STEPGEN_MAXACCEL = 0
SCALE = 1
FERROR = 1
MIN_FERROR = 2000
MIN_LIMIT = -200
MAX_LIMIT = 500
HOME_DELAY = 50
HOME_VEL = 1
HOME_OFFSET = 100.0
HOME_SEARCH_VEL = 0.0
HOME_LATCH_VEL = 0.0
HOME_USE_INDEX = NO
HOME_IGNORE_LIMITS = NO
HOME_SEQUENCE = 0
sd710.hal
###########################################################
#
# CIA 402 example snippet Hal
#
###########################################################
###########################################################
# Setup
###########################################################
loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadusr -W lcec_conf sd710.xml
loadrt lcec
loadrt cia402 count=1
loadrt pid names=s-pid,0-pid
###########################################################
# Functions servo-thread
###########################################################
addf lcec.read-all servo-thread
addf cia402.0.read-all servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf s-pid.do-pid-calcs servo-thread
addf 0-pid.do-pid-calcs servo-thread
addf cia402.0.write-all servo-thread
addf lcec.write-all servo-thread
#########################################
#nets
#########################################
net emc-enable => iocontrol.0.emc-enable-in
sets emc-enable 1
#config
#
# Joint 0
#
setp cia402.0.csp-mode 1
setp cia402.0.pos-scale 800
#from servo(ethercat) to cia402
net 0-statusword lcec.0.0.cia-statusword => cia402.0.statusword
net 0-drv-act-pos lcec.0.0.actual-position => cia402.0.drv-actual-position
#from motion to cia
net 0-home-index <= joint.0.index-enable => cia402.0.home
net 0-enable <= joint.0.amp-enable-out => cia402.0.enable
net 0-amp-fault => joint.0.amp-fault-in <= cia402.0.drv-fault
net 0-pos-cmd <= joint.0.motor-pos-cmd => cia402.0.pos-cmd
net 0-pos-fb => joint.0.motor-pos-fb <= cia402.0.pos-fb
#net 0-home lcec.0.0.in-5 => joint.0.home-sw-in
#from cia402 to servo(ethercat)
net 0-controlword cia402.0.controlword => lcec.0.0.cia-controlword
net 0-drv-target-pos cia402.0.drv-target-position => lcec.0.0.target-position
sd710.xml
masters>
<master idx="0" appTimePeriod="1000000" refClockSyncCycles="5">
<slave idx="0" type="generic" vid="00850104" pid="01030507" configPdos="true">
<syncManager idx="0" dir="out"/>
<syncManager idx="1" dir="in"/>
<syncManager idx="2" dir="out">
<pdo idx="1601">
<pdoEntry idx="6040" subIdx="00" bitLen="16" halPin="cia-controlword" halType="u32"/>
<pdoEntry idx="607A" subIdx="00" bitLen="32" halPin="target-position" halType="s32"/>
</pdo>
</syncManager>
<syncManager idx="3" dir="in">
<pdo idx="1A01">
<pdoEntry idx="6041" subIdx="00" bitLen="16" halPin="cia-statusword" halType="u32"/>
<pdoEntry idx="6064" subIdx="00" bitLen="32" halPin="actual-position" halType="s32"/>
</pdo>
</syncManager>
<dcConf assignActivate="300" sync0Cycle="*1" sync0Shift="250000"/>
</slave>
</master>
</masters>
配置完成后可以启动linuxcnc软件,选择sd710启动
效果参考
linuxcnc-ethercat单轴_哔哩哔哩_bilibilihttps://www.bilibili.com/video/BV1w94y1e7jc/?vd_source=235dd4c4dfb5d45fd9bed45715a82077#reply177527865760