Hello everyone
I'm Japanese and I'm not good at English. Posts use Google Translate, so please forgive me if it's hard to read.
There is a phenomenon that the operation of the rigid tap is troublesome. Is there a problem with the HAL or INI settings?
I will post HAL and INI first.
Code:
loadrt [KINS]KINEMATICS
#loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS num_spindles=1
# EtherCAT Driver
loadusr -W /usr/share/ethercat/linuxcnc_ethercat/src/lcec_conf ethercat-conf.xml
loadrt lcec
loadrt ddt names=ddt_spPos
loadrt or2 names=or2_z-ot,or2_oient #count=2
loadrt mux2 names=mux2_orient
# Add PID
loadrt pid names=pid_x,pid_y,pid_z,pid_sp,pid_orient #num_chan=4
loadrt not
# Add Spindle Orient
loadrt orient names=orient
#=============== Add Functions ==================
addf lcec.read-all servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf orient servo-thread
addf ddt_spPos servo-thread
addf or2_z-ot servo-thread
addf or2_oient servo-thread
addf mux2_orient servo-thread
#----- PID -------
addf pid_x.do-pid-calcs servo-thread
addf pid_y.do-pid-calcs servo-thread
addf pid_z.do-pid-calcs servo-thread
addf pid_sp.do-pid-calcs servo-thread
addf pid_orient.do-pid-calcs servo-thread #Spindle-Orient
addf lcec.write-all servo-thread
net dout-00 <= motion.digital-out-00
net estop-out <= iocontrol.0.user-enable-out
#net estop-out => iocontrol.0.emc-enable-in
# X-Axis
setp lcec.0.2.aout-0-max-dc [JOINT_0]OUTPUT_MAX_LIMIT
setp lcec.0.2.aout-0-min-dc [JOINT_0]OUTPUT_MIN_LIMIT
setp lcec.0.2.aout-0-scale [JOINT_0]OUTPUT_SCALE
setp lcec.0.2.enc-0-pos-scale [JOINT_0]ENCODER_SCALE
setp lcec.0.2.aout-0-enable 1
# Y-Axis
setp lcec.0.2.aout-1-max-dc [JOINT_1]OUTPUT_MAX_LIMIT
setp lcec.0.2.aout-1-min-dc [JOINT_1]OUTPUT_MIN_LIMIT
setp lcec.0.2.aout-1-scale [JOINT_1]OUTPUT_SCALE
setp lcec.0.2.enc-1-pos-scale [JOINT_1]ENCODER_SCALE
setp lcec.0.2.aout-1-enable 1
# Z-Axis
setp lcec.0.2.aout-2-max-dc [JOINT_2]OUTPUT_MAX_LIMIT
setp lcec.0.2.aout-2-min-dc [JOINT_2]OUTPUT_MIN_LIMIT
setp lcec.0.2.aout-2-scale [JOINT_2]OUTPUT_SCALE
setp lcec.0.2.enc-2-pos-scale [JOINT_2]ENCODER_SCALE
setp lcec.0.2.aout-2-enable 1
# PID Parameter
# X-Axis
setp pid_x.Pgain [JOINT_0]P
setp pid_x.Igain [JOINT_0]I
setp pid_x.Dgain [JOINT_0]D
setp pid_x.bias [JOINT_0]BIAS
setp pid_x.FF0 [JOINT_0]FF0
setp pid_x.FF1 [JOINT_0]FF1
setp pid_x.FF2 [JOINT_0]FF2
setp pid_x.deadband [JOINT_0]DEADBAND
setp pid_x.maxoutput [JOINT_0]MAX_OUTPUT
# Y-Axis
setp pid_y.Pgain [JOINT_1]P
setp pid_y.Igain [JOINT_1]I
setp pid_y.Dgain [JOINT_1]D
setp pid_y.bias [JOINT_1]BIAS
setp pid_y.FF0 [JOINT_1]FF0
setp pid_y.FF1 [JOINT_1]FF1
setp pid_y.FF2 [JOINT_1]FF2
setp pid_y.deadband [JOINT_1]DEADBAND
setp pid_y.maxoutput [JOINT_1]MAX_OUTPUT
# Z-Axis
setp pid_z.Pgain [JOINT_2]P
setp pid_z.Igain [JOINT_2]I
setp pid_z.Dgain [JOINT_2]D
setp pid_z.bias [JOINT_2]BIAS
setp pid_z.FF0 [JOINT_2]FF0
setp pid_z.FF1 [JOINT_2]FF1
setp pid_z.FF2 [JOINT_2]FF2
setp pid_z.deadband [JOINT_2]DEADBAND
setp pid_z.maxoutput [JOINT_2]MAX_OUTPUT
# Spindle PID Parameter
setp pid_sp.Pgain [SPINDLE_0]P
setp pid_sp.Igain [SPINDLE_0]I
setp pid_sp.Dgain [SPINDLE_0]D
setp pid_sp.bias [SPINDLE_0]BIAS
setp pid_sp.FF0 [SPINDLE_0]FF0
setp pid_sp.FF1 [SPINDLE_0]FF1
setp pid_sp.FF2 [SPINDLE_0]FF2
setp pid_sp.deadband [SPINDLE_0]DEADBAND
setp pid_sp.maxoutput 10
# Spindle Orientation PID Parameter
setp pid_orient.Pgain [SPINDLE_0]ORI-P
setp pid_orient.Igain [SPINDLE_0]ORI-I
setp pid_orient.Dgain [SPINDLE_0]ORI-D
#setp pid_orient.bias [SPINDLE_0]ORI-BIAS
#setp pid_orient.FF0 [SPINDLE_0]ORI-FF0
#setp pid_orient.FF1 [SPINDLE_0]ORI-FF1
#setp pid_orient.FF2 [SPINDLE_0]ORI-FF2
#setp pid_orient.deadband [SPINDLE_0]ORI-DEADBAND
setp pid_orient.maxoutput 10
# PID Connect Signals
# X-Axis
net pid-x-out <= pid_x.output
net pid-x-out => lcec.0.2.aout-0-value
net pid-x-fb <= lcec.0.2.enc-0-pos
net pid-x-fb => pid_x.feedback
net pid-x-fb => joint.0.motor-pos-fb
net pid-x-cmd <= joint.0.motor-pos-cmd
net pid-x-cmd => pid_x.command
# Y-Axis
net pid-y-out <= pid_y.output
net pid-y-out => lcec.0.2.aout-1-value
net pid-y-fb <= lcec.0.2.enc-1-pos
net pid-y-fb => pid_y.feedback
net pid-y-fb => joint.1.motor-pos-fb
net pid-y-cmd <= joint.1.motor-pos-cmd
net pid-y-cmd => pid_y.command
# Z-Axis
net pid-z-out <= pid_z.output
net pid-z-out => lcec.0.2.aout-2-value
net pid-z-fb <= lcec.0.2.enc-2-pos
net pid-z-fb => pid_z.feedback
net pid-z-fb => joint.2.motor-pos-fb
net pid-z-cmd <= joint.2.motor-pos-cmd
net pid-z-cmd => pid_z.command
#*************************** Spindle Setting *************
# W-Axis(Spindle)
setp lcec.0.2.aout-3-max-dc 1
setp lcec.0.2.aout-3-min-dc -1
setp lcec.0.2.aout-3-enable 1
setp lcec.0.2.aout-3-scale 10
setp lcec.0.2.enc-3-pos-scale 4000 #3000rpm Wako LNE020C
#setp lcec.0.2.enc-3-pos-scale 4096 #10000rpm Wako BXR006
#setp pid_sp.error-previous-target 0
net spindle-pid-output => mux2_orient.in0
net orient-pid-output => mux2_orient.in1
net spindle-speed-aout <= mux2_orient.out
net spindle-speed-aout => lcec.0.2.aout-3-value
net spindle-index-enable <=> lcec.0.2.enc-3-index-ext-pos-enable
net spindle-index-enable <=> spindle.0.index-enable
net spindle-Pos-fb <= lcec.0.2.enc-3-pos
net spindle-Pos-fb => spindle.0.revs
net spindle-Pos-fb => ddt_spPos.in
net spindle-Vel-fb <= ddt_spPos.out
net spindle-Vel-fb => spindle.0.speed-in
net spindle-enable1 <= spindle.0.on
net spindle-enable1 => or2_oient.in0
net spindle-enable2 <= spindle.0.orient
net spindle-enable2 => or2_oient.in1
net spindle-enable2 => orient.enable
net spindle-enable2 => mux2_orient.sel
net spindle-enable-out <= or2_oient.out
net spindle-enable-out => lcec.0.2.dout-1
#********* Spindle Speed PID Control
net spindle-enable1 => pid_sp.enable
net spindle-Vel-fb => pid_sp.feedback
#net spindle-Pos-fb => pid_sp.feedback-deriv
net spindle-vel-cmd-rps <= spindle.0.speed-cmd-rps
net spindle-vel-cmd-rps => pid_sp.command
#net spindle-index-enable <=> pid_sp.index-enable
net spindle-pid-output <= pid_sp.output
#********* Spindle Orientation Control
setp orient.tolerance 1
net spindle-Pos-fb => orient.position
net orient-angle <= spindle.0.orient-angle
net orient-angle => orient.angle
net orient-mode <= spindle.0.orient-mode
net orient-mode => orient.mode
net spindle-in-pos <= orient.is-oriented
net spindle-in-pos => spindle.0.is-oriented
net orient-command <= orient.command
net orient-command => pid_orient.command
net orient-pid-output <= pid_orient.output
net spindle-Pos-fb => pid_orient.feedback
net spindle-enable2 => pid_orient.enable
net spindle-index-enable <=> pid_orient.index-enable
# Servo Amp Ready input
net sv-ready <= motion.motion-enabled
net sv-ready => pid_x.enable
net sv-ready => pid_y.enable
net sv-ready => pid_z.enable
net sv-ready => lcec.0.2.dout-0
net sv-ready => lcec.0.2.dout-2 #Brake Coil
#************ ServoAmp Alarm
net svamp-x-alm <= lcec.0.2.din-4-not
net svamp-x-alm => joint.0.amp-fault-in
net svamp-y-alm <= lcec.0.2.din-8-not
net svamp-y-alm => joint.1.amp-fault-in
net svamp-z-alm <= lcec.0.2.din-12-not
net svamp-z-alm => joint.2.amp-fault-in
net spdlamp-alm <= lcec.0.2.din-13-not
net spdlamp-alm => spindle.0.amp-fault-in
#Limit SW & Homing
# X-Axis
#net x-puls-limit joint.0.pos-hard-lim lcec.0.2.din-2-not
#net x-minus-limit joint.0.neg-hard-lim lcec.0.2.din-3-not
net x-puls-limit joint.0.pos-lim-sw-in lcec.0.2.din-2-not
net x-minus-limit joint.0.neg-lim-sw-in lcec.0.2.din-3-not
net x-home-sw joint.0.home-sw-in lcec.0.2.din-1-not
net x-home-index-enable joint.0.index-enable <=> lcec.0.2.enc-0-index-ext-pos-enable
net x-home-index-enable <=> pid_x.index-enable
# Y-Axis
net y-puls-limit joint.1.pos-lim-sw-in lcec.0.2.din-6-not
net y-minus-limit joint.1.neg-lim-sw-in lcec.0.2.din-7-not
net y-home-sw joint.1.home-sw-in lcec.0.2.din-5-not
net y-home-index-enable joint.1.index-enable <=> lcec.0.2.enc-1-index-ext-pos-enable
net y-home-index-enable <=> pid_y.index-enable
# Z-Axis
net z-puls-limit joint.2.pos-lim-sw-in lcec.0.2.din-10-not
net z-minus-sig1 or2_z-ot.in0 lcec.0.2.din-11-not
net z-minus-sig2 or2_z-ot.in1 lcec.0.1.din-1-not
net z-minus-sig3 or2_z-ot.out joint.2.neg-lim-sw-in
#net z-minus-limit => joint.2.neg-lim-sw-in
#net z-minus-limit <= lcec.0.2.din-11-not
net z-home-sw joint.2.home-sw-in lcec.0.2.din-9-not
net z-home-index-enable joint.2.index-enable <=> lcec.0.2.enc-2-index-ext-pos-enable
net z-home-index-enable <=> pid_z.index-enable
# Set Machuine
#net M6Fin iocontrol.0.tool-change => iocontrol.0.tool-changed
setp iocontrol.0.tool-changed 1
setp iocontrol.0.tool-prepared 1
#Tool-Length-mesure
net Tool_Probe => motion.probe-input
net Tool_Probe <= lcec.0.1.din-0-not
#extra I/O
net coolant-mist <= iocontrol.0.coolant-mist
net coolant-mist => lcec.0.2.dout-6
net EXT_STOP iocontrol.0.emc-enable-in lcec.0.2.din-0
Code:
[EMC]
MACHINE = my-mill
DEBUG = 0
VERSION = 1.1
[DISPLAY]
DISPLAY = axis
#DISPLAY = gmoccpy
EDITOR = gedit
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
ARCDIVISION = 64
GRIDS = 10mm 20mm 50mm 100mm 1in 2in 5in 10in
MAX_FEED_OVERRIDE = 2.0
MIN_SPINDLE_OVERRIDE = 0.5
MAX_SPINDLE_OVERRIDE = 1.2
#DEFAULT_SPINDLE_SPEED = 300
MAX_SPINDLE_SPEED = 3000
#MAX_SPINDLE_SPEED = 10000
DEFAULT_LINEAR_VELOCITY = 8.333
MIN_LINEAR_VELOCITY = 0
MAX_LINEAR_VELOCITY = 33.333
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 5
PROGRAM_PREFIX = /home/masao/linuxcnc/nc_files
INCREMENTS = 5mm 1mm .5mm .1mm .05mm .01mm .005mm 0.001mm
[KINS]
JOINTS = 3
KINEMATICS = trivkins coordinates=XYZ
#KINEMATICS = trivkins coordinates=X
[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale Depth Image
PROGRAM_EXTENSION = .py Python Script
PROGRAM_EXTENSION = .nc,.tap G-Code File
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python
[TASK]
TASK = milltask
CYCLE_TIME = 0.010
[RS274NGC]
PARAMETER_FILE = linuxcnc.var
ORIENT_OFFSET = 65
SUBROUTINE_PATH = /home/masao/linuxcnc/nc_files/macros
USER_M_PATH = /home/masao/linuxcnc/nc_files/macros
REMAP = M200 modalgroup=10 argspec=Pq ngc=m200
REMAP = M400 modalgroup=10 argspec=Pq ngc=m400
REMAP = G12 modalgroup=1 argspec=Pq ngc=g12
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
BASE_PERIOD = 100000
SERVO_PERIOD = 1000000
[HAL]
HALFILE = my-mill.hal
#HALFILE = ethercat.hal
HALFILE = mpg.hal
HALFILE = custom.hal
POSTGUI_HALFILE = postgui_call_list.hal
[TRAJ]
COORDINATES = X Y Z
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 8.333
MAX_LINEAR_VELOCITY = 33.333
DEFAULT_LINEAR_ACCELERATION = 667
MAX_LINEAR_ACCELERATION = 667
[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100
TOOL_TABLE = tool.tbl
[AXIS_X]
MAX_VELOCITY = 33.333
MAX_ACCELERATION = 667
MIN_LIMIT = -200.5
MAX_LIMIT = 0.5
[JOINT_0]
TYPE = LINEAR
MIN_LIMIT = -200.5
MAX_LIMIT = 0.5
MAX_VELOCITY = 33.333
MAX_ACCELERATION = 667
SCALE = 1.0
FERROR = 10
#MIN_FERROR = .25
INPUT_SCALE = 1
OUTPUT_SCALE = 10
MAX_OUTPUT = 0
BACKLASH = 0
OUTPUT_SCALE = 10
OUTPUT_MIN_LIMIT = -1
OUTPUT_MAX_LIMIT = 1
ENCODER_SCALE = 4000
HOME = 0.0
HOME_USE_INDEX = YES
HOME_OFFSET = -10.0
HOME_FINAL_VEL = 5.0
HOME_LATCH_VEL = 1.0
HOME_SEARCH_VEL = 8.0
#PID Parameter
DEADBAND = 0.00025
P = 25
I = 700
D = 0.1
FF0 = 0.0
FF1 = 0.0
FF2 = 0.0
BIAS = 0.000
[AXIS_Y]
MAX_VELOCITY = 33.333
MAX_ACCELERATION = 667
MIN_LIMIT = -140.5
MAX_LIMIT = 0.5
[JOINT_1]
TYPE = LINEAR
MIN_LIMIT = -140.5
MAX_LIMIT = 0.5
MAX_VELOCITY = 33.333
MAX_ACCELERATION = 667
SCALE = 1.0
FERROR = 10
#MIN_FERROR = .25
INPUT_SCALE = 1
OUTPUT_SCALE = -10
MAX_OUTPUT = 0
BACKLASH = -0.015
OUTPUT_SCALE = 10
OUTPUT_MIN_LIMIT = -1
OUTPUT_MAX_LIMIT = 1
ENCODER_SCALE = -4000
HOME = 0.0
HOME_OFFSET = -13.4
HOME_SEARCH_VEL = 8.
HOME_USE_INDEX = YES
HOME_LATCH_VEL = 1
HOME_FINAL_VEL = 5
#PID Parameter
DEADBAND = 0.00049
P = 15
I = 200
D = 0.12
FF0 = 0.000
FF1 = 0.0
FF2 = 0.0
BIAS = 0.0
[AXIS_Z]
MAX_VELOCITY = 33.333
MAX_ACCELERATION = 667
MIN_LIMIT = -120.5
MAX_LIMIT = 0.5
[JOINT_2]
TYPE = LINEAR
MIN_LIMIT = -120.5
MAX_LIMIT = 0.5
MAX_VELOCITY = 33.333
MAX_ACCELERATION = 667
SCALE = 1.0
FERROR = 30
#MIN_FERROR = .25
INPUT_SCALE = 1
OUTPUT_SCALE = 10
MAX_OUTPUT = 0
BACKLASH = 0
OUTPUT_MIN_LIMIT = -1
OUTPUT_MAX_LIMIT = 1
ENCODER_SCALE = 4000
HOME = 0.0
HOME_OFFSET = -10.
HOME_SEARCH_VEL = 5.0
HOME_USE_INDEX = YES
HOME_LATCH_VEL = 1
HOME_FINAL_VEL = 5.0
#PID Parameter
DEADBAND = 0.00049
P = 20
I = 200
D = 0.12
#P = 7.3
#I = 300
#D = 0.045
FF0 = 0.0
FF1 = 0.0
FF2 = 0.0
BIAS = 0.0
[SPINDLE_0]
OUTPUT_MAX_LIMIT = 1
OUTPUT_MIN_LIMIT = -1
MAX_ACCELERATION = 50000
#PID Parameter
DEADBAND = 0.00025
P = 0.4
I = 0.5
D = 0
FF0 = 0.000
FF1 = 0.000
FF2 = 0.0
BIAS = 0.000
ORI-DEADBAND = 0.01
ORI-P = 6
ORI-I = 10
ORI-D = 0.14
ORI-FF0 = 0.000
ORI-FF1 = 0.000
ORI-FF2 = 0.0
ORI-BIAS = 0.000
[METROL]
M_X = 0
M_Y = 0
TIMES = 3
HIGHT = 45.831
The spindle of the machine is driven by a servo motor and uses a torque-controlled servo amplifier. Control is connected via PID with Linux CNC. We also do spindle orientation. The control relations are organized by the method taught in the forum.
I will explain the phenomenon.
G90G54G0X-20.Y-20.Z50.
S200M3
G0Z2.
G33.1Z-9.K0.5
G0Z50.
M5
M2
After executing G33.1, the spindle will rotate faster than the command value and start tapping. The number of rotations may reach the maximum rotation of the spindle.
The return of tapping returns at the commanded rotation speed. However, if the machine is rotated too fast, it may not be possible to decelerate when returning.
When monitoring with WATCH with HAL Configrations, pid_sp.command does not change at the start of tap processing, and the sign is inverted at the time of return. The number of rotations of pid_sp.feedback increases during tap processing, and the return value is similar to that of the command.
The Z-axis movement appears to be synchronized with the spindle.
The state of the spindle before the start of G33.1 is stable and maintains the specified rotation.
This abnormal state is wondering whether the pid_sp setting is bad or the HAL description is bad.
I have rewritten HAL so far and tried it with ON / OFF of pid_sp.error-previous-target and connection of pid_sp.index-enale, not connected. I'm in trouble because I couldn't find anything else to try.
The reason why the spindle motor amplifier was torque controlled was for orientation, and before that, it was used in speed control mode. At this time, spindole.0.speed-out was calculated by scale and controlled by analog voltage. At this time, there was no problem with the rigid tap.
Apparently, pid_sp behaves abnormally when I start G33.1, so I've read various manuals, but I can't find anything that applies. I would appreciate it if you could teach me.
Thank you very much.