Linuxcnc-ethercat从入门到放弃(1)、环境搭建

项目开源网站 LinuxCNCicon-default.png?t=N6B9https://www.linuxcnc.org/当前release版本2.8.4

Downloads (linuxcnc.org)icon-default.png?t=N6B9https://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

  1. cd linuxcnc-ethercat

  2. sudo make configure

  3. sudo make

  4. 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单轴_哔哩哔哩_bilibiliicon-default.png?t=N6B9https://www.bilibili.com/video/BV1w94y1e7jc/?vd_source=235dd4c4dfb5d45fd9bed45715a82077#reply177527865760

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值