Skip to content

Instantly share code, notes, and snippets.

@Bouni
Created September 13, 2024 11:38
Show Gist options
  • Save Bouni/e527587b2c7e71c0acf1ae600860c89b to your computer and use it in GitHub Desktop.
Save Bouni/e527587b2c7e71c0acf1ae600860c89b to your computer and use it in GitHub Desktop.
First working draft of a 3 axis linuxcnc setup with Omron 1S servo drives over ethercat
<masters>
<master idx="0" appTimePeriod="1000000" refClockSyncCycles="-1" name="master0">
<slave idx="0" type="EK1110" />
<slave idx="1" type="R88D-1SN01H-ECT" name="x-servo">
<dcConf assignActivate="300" sync0Cycle="*1" sync0Shift="0"/>
<watchdog divider="2498" intervals="1000"/>
</slave>
<slave idx="2" type="R88D-1SN01H-ECT" name="y-servo">
<dcConf assignActivate="300" sync0Cycle="*1" sync0Shift="0"/>
<watchdog divider="2498" intervals="1000"/>
</slave>
<slave idx="3" type="R88D-1SN01H-ECT" name="z-servo">
<dcConf assignActivate="300" sync0Cycle="*1" sync0Shift="0"/>
<watchdog divider="2498" intervals="1000"/>
</slave>
</master>
</masters>
# vi: ft=linuxcnc-hal
loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadusr -W lcec_conf ethercat-conf.xml
loadrt lcec
addf lcec.read-all servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf lcec.write-all servo-thread
net emc-enable => iocontrol.0.emc-enable-in
sets emc-enable 1
##*******************
## AXIS X
##*******************
net x-enable <= joint.0.amp-enable-out => lcec.master0.x-servo.enable
net x-amp-fault => joint.0.amp-fault-in <= lcec.master0.x-servo.fault
net x-pos-cmd <= joint.0.motor-pos-cmd => lcec.master0.x-servo.pos-cmd
net x-pos-fb => joint.0.motor-pos-fb <= lcec.master0.x-servo.pos-fb
##*******************
## AXIS Y
##*******************
net y-enable <= joint.1.amp-enable-out => lcec.master0.y-servo.enable
net y-amp-fault => joint.1.amp-fault-in <= lcec.master0.y-servo.fault
net y-pos-cmd <= joint.1.motor-pos-cmd => lcec.master0.y-servo.pos-cmd
net y-pos-fb => joint.1.motor-pos-fb <= lcec.master0.y-servo.pos-fb
##*******************
## AXIS Z
##*******************
net z-enable <= joint.2.amp-enable-out => lcec.master0.z-servo.enable
net z-amp-fault => joint.2.amp-fault-in <= lcec.master0.z-servo.fault
net z-pos-cmd <= joint.2.motor-pos-cmd => lcec.master0.z-servo.pos-cmd
net z-pos-fb => joint.2.motor-pos-fb <= lcec.master0.z-servo.pos-fb
# EMC controller parameters for a simulated machine.
# General note: Comments can either be preceded with a # or ; - either is
# acceptable, although # is in keeping with most linux config files.
# General section -------------------------------------------------------------
[EMC]
# Version of this INI file
VERSION = 1.1
# Name of machine, for use with display, etc.
MACHINE = Omron 1S test setup
# Debug level, 0 means no messages. See src/emc/nml_int/emcglb.h for others
#DEBUG = 0x7FFFFFFF
DEBUG = 0
# Sections for display options ------------------------------------------------
[DISPLAY]
# Name of display program, e.g., axis
DISPLAY = axis
# Cycle time, in seconds, that display will sleep between polls
CYCLE_TIME = 0.100
# 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
MAX_SPINDLE_OVERRIDE = 1.0
MAX_LINEAR_VELOCITY = 5
DEFAULT_LINEAR_VELOCITY = .25
DEFAULT_SPINDLE_SPEED = 200
# Prefix to be used
PROGRAM_PREFIX = /home/user/linuxcnc/nc_files
[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Grayscale Depth Image
PROGRAM_EXTENSION = .py Python Script
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python3
# Task controller 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.001
# Part program interpreter section --------------------------------------------
[RS274NGC]
# File containing interpreter variables
PARAMETER_FILE = sim.var
# Motion control section ------------------------------------------------------
[EMCMOT]
EMCMOT = motmod
# Timeout for comm to emcmot, in seconds
COMM_TIMEOUT = 1.0
# BASE_PERIOD is unused in this configuration but specified in core_sim.hal
BASE_PERIOD = 0
# Servo task period, in nano-seconds
SERVO_PERIOD = 1000000
# section for main IO controller parameters -----------------------------------
[EMCIO]
# Name of IO controller program, e.g., io
EMCIO = io
# cycle time, in seconds
CYCLE_TIME = 0.100
# tool table file
TOOL_TABLE = sim.tbl
TOOL_CHANGE_POSITION = 0 0 0
TOOL_CHANGE_QUILL_UP = 1
# Hardware Abstraction Layer section --------------------------------------------------
[HAL]
HALFILE = ethercat.hal
HALUI = halui
# Trajectory planner section --------------------------------------------------
[TRAJ]
COORDINATES = X Y Z
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
#MAX_LINEAR_VELOCITY = 4
#DEFAULT_LINEAR_ACCELERATION = 100
#MAX_LINEAR_ACCELERATION = 100
POSITION_FILE = position.txt
NO_FORCE_HOMING = 1
[KINS]
KINEMATICS = trivkins
JOINTS = 3
# Axes sections ---------------
[AXIS_X]
MAX_VELOCITY = 200
MAX_ACCELERATION = 1000.0
[AXIS_Y]
MAX_VELOCITY = 200
MAX_ACCELERATION = 1000.0
[AXIS_Z]
MAX_VELOCITY = 200
MAX_ACCELERATION = 1000.0
# Joints sections -------------
[JOINT_0]
TYPE = LINEAR
# HOME = 0.0
# FERROR = 10.0
# MIN_FERROR = 1.0
MAX_VELOCITY = 200
MAX_ACCELERATION = 1000.0
# PID
P = 20.0
I = 0.0
D = 0.0
FF0 = 0.0
FF1 = 1.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 0.0
POS_SCALE = 8388608
# Physical Axis Setup and Homing
#MIN_LIMIT = -0.01
#MAX_LIMIT = 672.0
HOME_ABSOLUTE_ENCODER = 2
[JOINT_1]
TYPE = LINEAR
# HOME = 0.0
# FERROR = 10.0
# MIN_FERROR = 1.0
MAX_VELOCITY = 200
MAX_ACCELERATION = 1000.0
# PID
P = 20.0
I = 0.0
D = 0.0
FF0 = 0.0
FF1 = 1.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 0.0
POS_SCALE = 8388608
# Physical Axis Setup and Homing
#MIN_LIMIT = -0.01
#MAX_LIMIT = 672.0
HOME_ABSOLUTE_ENCODER = 2
[JOINT_2]
TYPE = LINEAR
# HOME = 0.0
# FERROR = 10.0
# MIN_FERROR = 1.0
MAX_VELOCITY = 200
MAX_ACCELERATION = 1000.0
# PID
P = 20.0
I = 0.0
D = 0.0
FF0 = 0.0
FF1 = 1.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 0.0
POS_SCALE = 8388608
# Physical Axis Setup and Homing
#MIN_LIMIT = -0.01
#MAX_LIMIT = 672.0
HOME_ABSOLUTE_ENCODER = 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment