这里写目录标题
- 1、 cia402安装
- 2、找伺服描述文件(xml)
- 3、配置ethercat-config.xml
- 3.1、打开hal-cia402/example/ethercat-conf.xml
- 3.2、修改 ethercat-conf.xml文件中vid="0x000116c7" pid="0x003e0402"
- 3.3、其他参数,根据伺服厂家提供的xml,修改对应参数
- 4、配置hal文件
1、 cia402安装
sudo apt -y install git build-essential libtool automake
git clone https://github.com/dbraun1981/hal-cia402.git
cd hal-cia402
sudo halcompile --install cia402.comp
//提示找不到halcompile ,执行如下命令
sudo apt install linuxcnc-uspace-dev
2、找伺服描述文件(xml)
博主使用禾川 SV-X3EB020A-A2,在伺服官网下载https://www.hcfa.cn/content/details57_544.html
3、配置ethercat-config.xml
3.1、打开hal-cia402/example/ethercat-conf.xml
<masters>
<master idx="0" appTimePeriod="1000000" refClockSyncCycles="1">
<slave idx="0" type="generic" vid="0000026C" pid="0000003C" configPdos="true">
<dcConf assignActivate="300" sync0Cycle="*1" sync0Shift="0"/>
<syncManager idx="2" dir="out">
<pdo idx="1600">
<pdoEntry idx="6040" subIdx="00" bitLen="16" halPin="cia-controlword" halType="u32"/>
<pdoEntry idx="6060" subIdx="00" bitLen="8" halPin="opmode" halType="s32"/>
<pdoEntry idx="607A" subIdx="00" bitLen="32" halPin="target-position" halType="s32"/>
<pdoEntry idx="60FF" subIdx="00" bitLen="32" halPin="target-velocity" halType="s32"/>
</pdo>
</syncManager>
<syncManager idx="3" dir="in">
<pdo idx="1a00">
<pdoEntry idx="6041" subIdx="00" bitLen="16" halPin="cia-statusword" halType="u32"/>
<pdoEntry idx="6061" subIdx="00" bitLen="8" halPin="opmode-display" halType="s32"/>
<pdoEntry idx="6064" subIdx="00" bitLen="32" halPin="actual-position" halType="s32"/>
<pdoEntry idx="606C" subIdx="00" bitLen="32" halPin="actual-velocity" halType="s32"/>
<pdoEntry idx="6077" subIdx="00" bitLen="32" halPin="actual-torque" halType="s32"/>
</pdo>
</syncManager>
</slave>
</master>
</masters>
3.2、修改 ethercat-conf.xml文件中vid=“0x000116c7” pid=“0x003e0402”
- 伺服通电,连上电脑
- 使用
ethercat cstruct
/* Master 0, Slave 0, "HCFA X3E Servo Driver"
* `Vendor ID: 0x000116c7`
* `Product code: 0x003e0402`
* Revision number: 0x00000001
*/
ec_pdo_entry_info_t slave_0_pdo_entries[] = {
{0x6040, 0x00, 16}, /* Control Word */
{0x6060, 0x00, 8}, /* Modes of operation */
{0x607a, 0x00, 32}, /* Target position */
{0x60b8, 0x00, 16}, /* Touch Probe Function */
{0x603f, 0x00, 16}, /* Error Code */
{0x6041, 0x00, 16}, /* Status Word */
{0x6064, 0x00, 32}, /* Position actual value */
{0x6061, 0x00, 8}, /* Modes of operation display */
{0x60b9, 0x00, 16}, /* Touch Probe Status */
{0x60ba, 0x00, 32}, /* Touch Probe1 Pos1 Pos Value */
{0x60f4, 0x00, 32}, /* Following error actual value */
{0x60fd, 0x00, 32}, /* Digital inputs */
{0x213f, 0x00, 16}, /* Servo Error Code */
};
ec_pdo_info_t slave_0_pdos[] = {
{0x1600, 4, slave_0_pdo_entries + 0}, /* 1st RxPDO-Mapping */
{0x1a00, 9, slave_0_pdo_entries + 4}, /* 1st TxPDO-Mapping */
};
ec_sync_info_t slave_0_syncs[] = {
{0, EC_DIR_OUTPUT, 0, NULL, EC_WD_DISABLE},
{1, EC_DIR_INPUT, 0, NULL, EC_WD_DISABLE},
{2, EC_DIR_OUTPUT, 1, slave_0_pdos + 0, EC_WD_ENABLE},
{3, EC_DIR_INPUT, 1, slave_0_pdos + 1, EC_WD_DISABLE},
{0xff}
};
3.3、其他参数,根据伺服厂家提供的xml,修改对应参数
4、配置hal文件
- linuxcnc/configs/创建
test
文件夹
mkdir -p test
- 复制一份gmoccapy.ini文件放入
test
文件夹,改名test.ini
[EMC]
VERSION = 1.1
MACHINE = Test
DEBUG = 0
[DISPLAY]
DISPLAY = gmoccapy
CYCLE_TIME = 0.100
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
MAX_FEED_OVERRIDE = 1.0
MAX_SPINDLE_OVERRIDE = 1.0
PROGRAM_PREFIX = ../../nc_files/
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 1
INCREMENTS = 5mm 1mm .5mm .1mm .05mm .01mm .005mm
[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg,.txt,.TXT Grayscale Depth Image
PROGRAM_EXTENSION = .py Python Script
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python
[RS274NGC]
PARAMETER_FILE = test.var
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
BASE_PERIOD = 100000
SERVO_PERIOD = 1000000
[TASK]
TASK = milltask
CYCLE_TIME = 0.001
[HAL]
HALUI = halui
HALFILE = test.hal
[HALUI]
MDI_COMMAND=(debug,macro0)
[TRAJ]
SPINDLES = 1
COORDINATES = X Y Z
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 100
MAX_LINEAR_VELOCITY = 200.0
DEFAULT_LINEAR_ACCELERATION = 100.0
MAX_LINEAR_ACCELERATION = 100.0
NO_FORCE_HOMING = 1
[KINS]
KINEMATICS = trivkins coordinates=XYZ
JOINTS = 3
[AXIS_X]
MAX_VELOCITY = 200
MAX_ACCELERATION = 100.0
MIN_LIMIT = -50.0
MAX_LIMIT = 50.0
[JOINT_0]
TYPE = LINEAR
BACKLASH = 0.0000
MIN_LIMIT = -50.0
MAX_LIMIT = 50.0
MIN_FERROR = 0.254
FERROR = 1.27
HOME_SEARCH_VEL = 0.0
HOME_LATCH_VEL = 0.0
HOME_FINAL_VEL = 1
HOME_IGNORE_LIMITS = NO
HOME_USE_INDEX = NO
HOME_OFFSET = 0
HOME_ABSOLUTE_ENCODER = 1
HOME_SEQUENCE = 0
[AXIS_Y]
MAX_VELOCITY = 200
MAX_ACCELERATION = 100.0
MIN_LIMIT = -200.0
MAX_LIMIT = 200.0
[JOINT_1]
TYPE = LINEAR
BACKLASH = 0.0000
MIN_LIMIT = -200.0
MAX_LIMIT = 200.0
MIN_FERROR = 0.254
FERROR = 1.27
HOME_SEARCH_VEL = 0.0
HOME_LATCH_VEL = 0.0
HOME_FINAL_VEL = 1
HOME_IGNORE_LIMITS = NO
HOME_USE_INDEX = NO
HOME_OFFSET = 0
HOME = 0
HOME_ABSOLUTE_ENCODER = 1
HOME_SEQUENCE = 0
[AXIS_Z]
MAX_VELOCITY = 200
MAX_ACCELERATION = 100.0
MIN_LIMIT = -200.0
MAX_LIMIT = 200.0
[JOINT_2]
TYPE = LINEAR
BACKLASH = 0.0000
MIN_LIMIT = -200.0
MAX_LIMIT = 200.0
MIN_FERROR = 0.254
FERROR = 1.27
HOME_SEARCH_VEL = 0.0
HOME_LATCH_VEL = 0.0
HOME_FINAL_VEL = 1
HOME_IGNORE_LIMITS = NO
HOME_USE_INDEX = NO
HOME_OFFSET = 0
HOME = 0
HOME_ABSOLUTE_ENCODER = 1
HOME_SEQUENCE = 0
[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100
TOOL_TABLE = tool.tbl
[SPINDLE_0]
MAX_FORWARD_VELOCITY = 1000
MIN_FORWARD_VELOCITY = 100
MAX_REVERSE_VELOCITY = 1000
MIN_REVERSE_VELOCITY = 100
INCREMENT = 100
- 复制一份修改后的ethercat-conf.xml,放入
test
文件夹 test
文件夹中分别有ethercat-conf.xml、test.ini、test.hal
https://www.bilibili.com/video/BV1YMYvecER5/?spm_id_from=333.788.videopod.sections&vd_source=2ab693954765c32e59d2e4b3a8e560ed