Position error with encoder

More
17 Aug 2021 15:12 #217990 by Messkid
Hi everyone,

I'm pretty new to linuxcnc and i'm working on a BF-16 retrofit with a Mesa 7i95 board and encoders on the X and Y axis.

I noticed some errors during milling a part, like a 0.5 mm shift on the X axis, so now i'm running some tests and I can see some error in the position after a program. I set my part origin with my probe sensor on the X and Y axis, run a program without milling anything and then probe again my part to see if anything changed, and i can notice sometime a 0.6 mm shift on X, than a 0.2 mm on both axis... It looks like it's never the same. 

I don't understand because I suppose the Ferror value is authorizing an error during a trajectory, but it's not supposed to create an offset in my position (I guess...)

Thanks for you help, i'll post just here my INI and HAL file : 

INI : 
# Généré par PNCconf le Sun Apr 18 11:08:51 2021
# Using LinuxCNC version:  2.8
# Si vous modifiez ce fichier, il sera
# écrasé quand vous relancerez PNCconf
[EMC]
MACHINE = CNC-BF16
DEBUG = 0
VERSION = 1.1
[DISPLAY]
#DISPLAY = axis
DISPLAY = gmoccapy
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
MAX_FEED_OVERRIDE = 1.500000
MAX_SPINDLE_OVERRIDE = 1.500000
MIN_SPINDLE_OVERRIDE = 0.500000
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 5
PROGRAM_PREFIX = /home/machinekit/linuxcnc/nc_files
INCREMENTS = 10mm 1mm .1mm .01mm
POSITION_FEEDBACK = ACTUAL
DEFAULT_LINEAR_VELOCITY = 30.000000
MAX_LINEAR_VELOCITY = 30.000000
MIN_LINEAR_VELOCITY = 0.010000
DEFAULT_ANGULAR_VELOCITY = 20.000000
MAX_ANGULAR_VELOCITY = 25.000000
MIN_ANGULAR_VELOCITY = 0.010000
EDITOR = gedit
GEOMETRY = xyz
EMBED_TAB_NAME=Probe Screen 
EMBED_TAB_LOCATION=ntb_preview
EMBED_TAB_COMMAND=halcmd loadusr -Wn gladevcp gladevcp -c gladevcp -x {XID} -u ../python/probe_screen.py -H ../probe_icons/probe_screen.hal ../probe_icons/probe_screen.glade
#EMBED_TAB_NAME = Camera
#EMBED_TAB_LOCATION = ntb_preview
#EMBED_TAB_COMMAND = gladevcp -x {XID} camview.glade
[PROBE_SCREEN]
# Offset from [AXIS_Z]MAX_LIMIT for performing moves during various probe
# screen movements. This must be a negative number.
Z_SAFE_TRAVEL_OFFSET = -0.1
[TOOLSENSOR]
# Absolute coordinates of the toolsetter pad
X = 0
Y = 97
# Absolute Z start search coordinates
Z = -65
# Maximum search distance and direction (sign)
MAXPROBE = -110
# Speed of movements during working in Probe Screen
RAPID_SPEED = 600
# Diameter of toolsetter pad 
TS_DIAMETER = 10
# The speed of the reverse rotation of the spindle when measuring the tool diameter
REV_ROTATION_SPEED = 300
# distance to trigger the tool sensor
TRIG_DIST = 0.55
[CHANGE_POSITION]
# Absolute coordinates of the tool change point
X = 0
Y = 100
Z = 0
[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
[TASK]
TASK = milltask
CYCLE_TIME = 0.010
[RS274NGC]
PARAMETER_FILE = linuxcnc.var
# ---- PSNG start ---- #
RETAIN_G43 = 0
INI_VARS = 1
HAL_PIN_VARS = 1
SUBROUTINE_PATH = macros:../macros
REMAP=M6   modalgroup=6  prolog=change_prolog   ngc=manual_change  epilog=change_epilog
# ---- PSNG end ---- #
[PYTHON]
PATH_PREPEND = ../python
TOPLEVEL = ../python/toplevel.py
#PATH_PREPEND = ../
#TOPLEVEL = python/stdglue.py
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
SERVO_PERIOD = 1000000
[HMOT]
# **** This is for info only ****
CARD0=hm2_7i95.0
[HAL]
HALUI = halui
HALFILE = CNC-BF16.hal
HALFILE = custom.hal
POSTGUI_HALFILE = postgui_call_list.hal
SHUTDOWN = shutdown.hal
[HALUI]
[KINS]
JOINTS = 4
KINEMATICS = trivkins coordinates=XYZA
[TRAJ]
COORDINATES =  XYZA
MAX_ANGULAR_VELOCITY = 25.00
DEFAULT_ANGULAR_VELOCITY = 20.00
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 30.00
MAX_LINEAR_VELOCITY = 30.00
HOME =                     1 1 1 2
NO_FORCE_HOMING =          1
DEFAULT_ACCELERATION = 125
[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100
TOOL_TABLE = tool.tbl
TOOL_CHANGE_QUILL_UP = 1
#******************************************
[AXIS_X]
MAX_VELOCITY = 25.0
MAX_ACCELERATION = 120.0
MIN_LIMIT = -0.5
MAX_LIMIT = 212.0
[JOINT_0]
TYPE = LINEAR
HOME = 0.0
FERROR = 1.5
MIN_FERROR = 1.1
BACKLASH = 0.01
MAX_VELOCITY = 25.0
MAX_ACCELERATION = 120.0
# The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
STEPGEN_MAXVEL = 90
STEPGEN_MAXACCEL = 300.00
P = 100
I = 0.0
D = 0.0
FF0 = 0.0
FF1 = 1.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.005
MAX_OUTPUT = 0.0
ENCODER_SCALE = 6615
# these are in nanoseconds
DIRSETUP   = 10000
DIRHOLD    = 10000
STEPLEN    = 5000
STEPSPACE  = 5000
STEP_SCALE = 800
MIN_LIMIT = -0.5
MAX_LIMIT = 212.0
HOME_OFFSET = -0.1
HOME_SEARCH_VEL     =  -5.0
HOME_LATCH_VEL      =   0.10
HOME_IGNORE_LIMITS  =    YES
HOME_SEQUENCE = 0
#******************************************
#******************************************
[AXIS_Y]
MAX_VELOCITY = 25.0
MAX_ACCELERATION = 120.0
MIN_LIMIT = -0.5
MAX_LIMIT = 155.0
[JOINT_1]
TYPE = LINEAR
HOME = 0.0
FERROR = 1.5
MIN_FERROR = 1.1
BACKLASH = 0.0
MAX_VELOCITY = 25.0
MAX_ACCELERATION = 120.0
# The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
STEPGEN_MAXVEL = 90.00
STEPGEN_MAXACCEL = 300.00
P = 100.0
I = 0.0
D = 0.0
FF0 = 0.0
FF1 = 1.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.00
MAX_OUTPUT = 0.0
ENCODER_SCALE = 3415
# these are in nanoseconds
DIRSETUP   = 10000
DIRHOLD    = 10000
STEPLEN    = 5000
STEPSPACE  = 5000
STEP_SCALE = -800
MIN_LIMIT = -0.5
MAX_LIMIT = 155.0
HOME_OFFSET = -0.1
HOME_SEARCH_VEL     =  -5.0
HOME_LATCH_VEL      =   0.10
HOME_IGNORE_LIMITS  =    YES
HOME_SEQUENCE = 1
#******************************************
#******************************************
[AXIS_Z]
MAX_VELOCITY = 25
MAX_ACCELERATION = 120.0
MIN_LIMIT = -195.0
MAX_LIMIT = 0.5
[JOINT_2]
TYPE = LINEAR
HOME = 0.0
FERROR = 1.5
MIN_FERROR = 1.1
MAX_VELOCITY = 25
MAX_ACCELERATION = 120.0
# The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
STEPGEN_MAXVEL = 90
STEPGEN_MAXACCEL = 300
P = 100
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
ENCODER_SCALE = -106.76
# these are in nanoseconds
DIRSETUP   = 10000
DIRHOLD    = 10000
STEPLEN    = 5000
STEPSPACE  = 5000
STEP_SCALE = 800.0
MIN_LIMIT = -195.0
MAX_LIMIT = 0.5
HOME_OFFSET = 0.1
HOME_SEARCH_VEL     =   5.0
HOME_LATCH_VEL      =   -0.10
HOME_IGNORE_LIMITS  =    YES
HOME_SEQUENCE = 2
#******************************************
#******************************************
[AXIS_A]
MAX_VELOCITY = 25.0
MAX_ACCELERATION = 120.0
MIN_LIMIT = -9999.0
MAX_LIMIT = 9999.0
[JOINT_3]
TYPE = ANGULAR
HOME = 0.0
FERROR = 0.1
MIN_FERROR = 0.01
MAX_VELOCITY = 25.0
MAX_ACCELERATION = 120.0
# The values below should be 25% larger than MAX_VELOCITY and MAX_ACCELERATION
# If using BACKLASH compensation STEPGEN_MAXACCEL should be 100% larger.
STEPGEN_MAXVEL = 90.00
STEPGEN_MAXACCEL = 300.00
P = 1000.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
# these are in nanoseconds
DIRSETUP   = 10000
DIRHOLD    = 10000
STEPLEN    = 5000
STEPSPACE  = 5000
STEP_SCALE = 200
MIN_LIMIT = -9999.0
MAX_LIMIT = 9999.0
HOME_OFFSET = 0.0
#******************************************
[SPINDLE_0]
P = 0
I = 0
D = 0
FF0 = 1
FF1 = 0
FF2 = 0
BIAS = 0
DEADBAND = 0
MAX_OUTPUT = 2000

and the HAL file : 
# Généré par PNCconf le Sun Apr 18 11:08:51 2021
# Using LinuxCNC version:  2.8
# Si vous modifiez ce fichier, il sera
# écrasé quand vous relancerez PNCconf

loadrt [KINS]KINEMATICS
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
loadrt hostmot2
loadrt hm2_eth board_ip="10.10.10.10" config=" num_encoders=4 num_pwmgens=0 num_stepgens=5 sserial_port_0=00xxxx" 
setp    hm2_7i95.0.watchdog.timeout_ns 5000000
loadrt pid names=pid.x,pid.y,pid.z,pid.a,pid.s
loadrt estop_latch
loadrt mux8 count=1
loadrt not count=1
loadrt or2 count=1

addf hm2_7i95.0.read          servo-thread
addf motion-command-handler   servo-thread
addf motion-controller        servo-thread
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.a.do-pid-calcs       servo-thread
addf pid.s.do-pid-calcs       servo-thread
addf hm2_7i95.0.write         servo-thread
addf estop-latch.0            servo-thread
addf not.0                      servo-thread
addf mux8.0                      servo-thread
addf or2.0                    servo-thread
setp hm2_7i95.0.dpll.01.timer-us -50
setp hm2_7i95.0.stepgen.timer-number 1


# external output signals


net machine-is-enabled      =>  not.0.in
net machine-is-disabled     not.0.out => hm2_7i95.0.ssr.00.out-00
net machine-is-disabled      hm2_7i95.0.ssr.00.out-01

# external input signals

net pend-counts   <=  hm2_7i95.0.inmux.00.enc0-count     #input-00 and input-01
net x-home-sw     <=  hm2_7i95.0.inmux.00.input-02
net y-home-sw     <=  hm2_7i95.0.inmux.00.input-03
net z-home-sw     <=  hm2_7i95.0.inmux.00.input-04
net probe-in      <=  hm2_7i95.0.inmux.00.input-05-not
net faultin       <=  hm2_7i95.0.inmux.00.input-06-not   #arret urgence
net mpg-x         <=  hm2_7i95.0.inmux.00.input-07
net mpg-y         <=  hm2_7i95.0.inmux.00.input-08
net mpg-z         <=  hm2_7i95.0.inmux.00.input-09
net mpg-A         <=  hm2_7i95.0.inmux.00.input-10
net scale1        <=  hm2_7i95.0.inmux.00.input-11
net scale2        <=  hm2_7i95.0.inmux.00.input-12
net scale3        <=  hm2_7i95.0.inmux.00.input-13
net tool-lenght   <=  hm2_7i95.0.inmux.00.input-14-not

#*******************
#  AXIS X JOINT 0
#*******************

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
setp   pid.x.error-previous-target true
# This setting is to limit bogus stepgen
# velocity corrections caused by position
# feedback sample time jitter.
setp   pid.x.maxerror 0.012700

net x-index-enable  <=> pid.x.index-enable
net x-enable        =>  pid.x.enable
net x-pos-cmd       =>  pid.x.command
net x-pos-fb        =>  pid.x.feedback
net x-output        <=  pid.x.output

# Step Gen signals/setup

setp   hm2_7i95.0.stepgen.00.dirsetup        [JOINT_0]DIRSETUP
setp   hm2_7i95.0.stepgen.00.dirhold         [JOINT_0]DIRHOLD
setp   hm2_7i95.0.stepgen.00.steplen         [JOINT_0]STEPLEN
setp   hm2_7i95.0.stepgen.00.stepspace       [JOINT_0]STEPSPACE
setp   hm2_7i95.0.stepgen.00.position-scale  [JOINT_0]STEP_SCALE
setp   hm2_7i95.0.stepgen.00.step_type        0
setp   hm2_7i95.0.stepgen.00.control-type     1
setp   hm2_7i95.0.stepgen.00.maxaccel         [JOINT_0]STEPGEN_MAXACCEL
setp   hm2_7i95.0.stepgen.00.maxvel           [JOINT_0]STEPGEN_MAXVEL

# ---Encoder feedback signals/setup---

setp    hm2_7i95.0.encoder.00.counter-mode 0
setp    hm2_7i95.0.encoder.00.filter 1
setp    hm2_7i95.0.encoder.00.index-invert 0
setp    hm2_7i95.0.encoder.00.index-mask 0
setp    hm2_7i95.0.encoder.00.index-mask-invert 0
setp    hm2_7i95.0.encoder.00.scale          [JOINT_0]ENCODER_SCALE

net x-pos-fb               <=  hm2_7i95.0.encoder.00.position
net x-vel-fb               <=  hm2_7i95.0.encoder.00.velocity

net x-index-enable    joint.0.index-enable  <=>  hm2_7i95.0.encoder.00.index-enable
net x-pos-rawcounts        <=  hm2_7i95.0.encoder.00.rawcounts

# ---closedloop stepper signals---

net x-pos-cmd    <= joint.0.motor-pos-cmd
net x-vel-cmd    <= joint.0.vel-cmd
net x-output     <= hm2_7i95.0.stepgen.00.velocity-cmd
#net x-pos-fb     <= hm2_7i95.0.stepgen.00.position-fb       
net x-pos-fb     => joint.0.motor-pos-fb
net x-enable     <= joint.0.amp-enable-out
net x-enable     => hm2_7i95.0.stepgen.00.enable

# ---setup home / limit switch signals---

net x-home-sw     =>  joint.0.home-sw-in

# --- setup parameters---

setp joint.0.jog-vel-mode 1
setp axis.x.jog-vel-mode 1

#*******************
#  AXIS Y JOINT 1
#*******************

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
setp   pid.y.error-previous-target true
# This setting is to limit bogus stepgen
# velocity corrections caused by position
# feedback sample time jitter.
setp   pid.y.maxerror 0.012700

net y-index-enable  <=> pid.y.index-enable
net y-enable        =>  pid.y.enable
net y-pos-cmd       =>  pid.y.command
net y-pos-fb        =>  pid.y.feedback
net y-output        <=  pid.y.output

# Step Gen signals/setup

setp   hm2_7i95.0.stepgen.01.dirsetup        [JOINT_1]DIRSETUP
setp   hm2_7i95.0.stepgen.01.dirhold         [JOINT_1]DIRHOLD
setp   hm2_7i95.0.stepgen.01.steplen         [JOINT_1]STEPLEN
setp   hm2_7i95.0.stepgen.01.stepspace       [JOINT_1]STEPSPACE
setp   hm2_7i95.0.stepgen.01.position-scale  [JOINT_1]STEP_SCALE
setp   hm2_7i95.0.stepgen.01.step_type        0
setp   hm2_7i95.0.stepgen.01.control-type     1
setp   hm2_7i95.0.stepgen.01.maxaccel         [JOINT_1]STEPGEN_MAXACCEL
setp   hm2_7i95.0.stepgen.01.maxvel           [JOINT_1]STEPGEN_MAXVEL

# ---Encoder feedback signals/setup---

setp    hm2_7i95.0.encoder.01.counter-mode 0
setp    hm2_7i95.0.encoder.01.filter 1
setp    hm2_7i95.0.encoder.01.index-invert 0
setp    hm2_7i95.0.encoder.01.index-mask 0
setp    hm2_7i95.0.encoder.01.index-mask-invert 0
setp    hm2_7i95.0.encoder.01.scale          [JOINT_1]ENCODER_SCALE

net y-pos-fb               <=  hm2_7i95.0.encoder.01.position
net y-vel-fb               <=  hm2_7i95.0.encoder.01.velocity

net y-index-enable    joint.1.index-enable  <=>  hm2_7i95.0.encoder.01.index-enable
net y-pos-rawcounts        <=  hm2_7i95.0.encoder.01.rawcounts

# ---closedloop stepper signals---

net y-pos-cmd    <= joint.1.motor-pos-cmd
net y-vel-cmd    <= joint.1.vel-cmd
net y-output     <= hm2_7i95.0.stepgen.01.velocity-cmd
#net y-pos-fb     <= hm2_7i95.0.stepgen.01.position-fb
net y-pos-fb     => joint.1.motor-pos-fb
net y-enable     <= joint.1.amp-enable-out
net y-enable     => hm2_7i95.0.stepgen.01.enable

# ---setup home / limit switch signals---

net y-home-sw     =>  joint.1.home-sw-in

# --- setup parameters---

setp joint.1.jog-vel-mode 1
setp axis.y.jog-vel-mode 1


#*******************
#  AXIS Z JOINT 2
#*******************

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
setp   pid.z.error-previous-target true
# This setting is to limit bogus stepgen
# velocity corrections caused by position
# feedback sample time jitter.
setp   pid.z.maxerror 0.012700

net z-index-enable  <=> pid.z.index-enable
net z-enable        =>  pid.z.enable
net z-pos-cmd       =>  pid.z.command
net z-pos-fb        =>  pid.z.feedback
net z-output        <=  pid.z.output

# Step Gen signals/setup

setp   hm2_7i95.0.stepgen.02.dirsetup        [JOINT_2]DIRSETUP
setp   hm2_7i95.0.stepgen.02.dirhold         [JOINT_2]DIRHOLD
setp   hm2_7i95.0.stepgen.02.steplen         [JOINT_2]STEPLEN
setp   hm2_7i95.0.stepgen.02.stepspace       [JOINT_2]STEPSPACE
setp   hm2_7i95.0.stepgen.02.position-scale  [JOINT_2]STEP_SCALE
setp   hm2_7i95.0.stepgen.02.step_type        0
setp   hm2_7i95.0.stepgen.02.control-type     1
setp   hm2_7i95.0.stepgen.02.maxaccel         [JOINT_2]STEPGEN_MAXACCEL
setp   hm2_7i95.0.stepgen.02.maxvel           [JOINT_2]STEPGEN_MAXVEL

# ---Encoder feedback signals/setup---

setp    hm2_7i95.0.encoder.02.counter-mode 0
setp    hm2_7i95.0.encoder.02.filter 1
setp    hm2_7i95.0.encoder.02.index-invert 0
setp    hm2_7i95.0.encoder.02.index-mask 0
setp    hm2_7i95.0.encoder.02.index-mask-invert 0
setp    hm2_7i95.0.encoder.02.scale          [JOINT_2]ENCODER_SCALE

#net z-pos-fb               <=  hm2_7i95.0.encoder.02.position
#net z-vel-fb               <=  hm2_7i95.0.encoder.02.velocity

net z-index-enable    joint.2.index-enable  <=>  hm2_7i95.0.encoder.02.index-enable
net z-pos-rawcounts        <=  hm2_7i95.0.encoder.02.rawcounts

# ---closedloop stepper signals---

net z-pos-cmd    <= joint.2.motor-pos-cmd
net z-vel-cmd    <= joint.2.vel-cmd
net z-output     <= hm2_7i95.0.stepgen.02.velocity-cmd
net z-pos-fb     <= hm2_7i95.0.stepgen.02.position-fb
net z-pos-fb     => joint.2.motor-pos-fb
net z-enable     <= joint.2.amp-enable-out
net z-enable     => hm2_7i95.0.stepgen.02.enable

# ---setup home / limit switch signals---

net z-home-sw     =>  joint.2.home-sw-in

# --- setup parameters---

setp joint.2.jog-vel-mode 1
setp axis.z.jog-vel-mode 1

#*******************
#  AXIS A JOINT 3
#*******************

setp   pid.a.Pgain     [JOINT_3]P
setp   pid.a.Igain     [JOINT_3]I
setp   pid.a.Dgain     [JOINT_3]D
setp   pid.a.bias      [JOINT_3]BIAS
setp   pid.a.FF0       [JOINT_3]FF0
setp   pid.a.FF1       [JOINT_3]FF1
setp   pid.a.FF2       [JOINT_3]FF2
setp   pid.a.deadband  [JOINT_3]DEADBAND
setp   pid.a.maxoutput [JOINT_3]MAX_OUTPUT
setp   pid.a.error-previous-target true
# This setting is to limit bogus stepgen
# velocity corrections caused by position
# feedback sample time jitter.
setp   pid.a.maxerror 0.012700

net a-index-enable  <=> pid.a.index-enable
net a-enable        =>  pid.a.enable
net a-pos-cmd       =>  pid.a.command
net a-pos-fb        =>  pid.a.feedback
net a-output        <=  pid.a.output

# Step Gen signals/setup

setp   hm2_7i95.0.stepgen.03.dirsetup        [JOINT_3]DIRSETUP
setp   hm2_7i95.0.stepgen.03.dirhold         [JOINT_3]DIRHOLD
setp   hm2_7i95.0.stepgen.03.steplen         [JOINT_3]STEPLEN
setp   hm2_7i95.0.stepgen.03.stepspace       [JOINT_3]STEPSPACE
setp   hm2_7i95.0.stepgen.03.position-scale  [JOINT_3]STEP_SCALE
setp   hm2_7i95.0.stepgen.03.step_type        0
setp   hm2_7i95.0.stepgen.03.control-type     1
setp   hm2_7i95.0.stepgen.03.maxaccel         [JOINT_3]STEPGEN_MAXACCEL
setp   hm2_7i95.0.stepgen.03.maxvel           [JOINT_3]STEPGEN_MAXVEL

# ---closedloop stepper signals---

net a-pos-cmd    <= joint.3.motor-pos-cmd
net a-vel-cmd    <= joint.3.vel-cmd
net a-output     <= hm2_7i95.0.stepgen.03.velocity-cmd
net a-pos-fb     <= hm2_7i95.0.stepgen.03.position-fb
net a-pos-fb     => joint.3.motor-pos-fb
net a-enable     <= joint.3.amp-enable-out
net a-enable     => hm2_7i95.0.stepgen.03.enable

# ---setup home / limit switch signals---

net a-home-sw     =>  joint.3.home-sw-in

# --- setup parameters---

setp joint.3.jog-vel-mode 1
setp axis.a.jog-vel-mode 1


#*******************
#  SPINDLE
#*******************

setp   pid.s.Pgain     [SPINDLE_0]P
setp   pid.s.Igain     [SPINDLE_0]I
setp   pid.s.Dgain     [SPINDLE_0]D
setp   pid.s.bias      [SPINDLE_0]BIAS
setp   pid.s.FF0       [SPINDLE_0]FF0
setp   pid.s.FF1       [SPINDLE_0]FF1
setp   pid.s.FF2       [SPINDLE_0]FF2
setp   pid.s.deadband  [SPINDLE_0]DEADBAND
setp   pid.s.maxoutput [SPINDLE_0]MAX_OUTPUT
setp   pid.s.error-previous-target true

net spindle-index-enable  <=> pid.s.index-enable
net spindle-enable        =>  pid.s.enable
net spindle-vel-cmd-rpm     => pid.s.command
net spindle-vel-fb-rpm      => pid.s.feedback
net spindle-output        <=  pid.s.output

# ---setup spindle control signals---

net spindle-vel-cmd-rps        <=  spindle.0.speed-out-rps
net spindle-vel-cmd-rps-abs    <=  spindle.0.speed-out-rps-abs
net spindle-vel-cmd-rpm        <=  spindle.0.speed-out
net spindle-vel-cmd-rpm-abs    <=  spindle.0.speed-out-abs
net spindle-enable             <=  spindle.0.on
net spindle-cw                 <=  spindle.0.forward
net spindle-ccw                <=  spindle.0.reverse
net spindle-brake              <=  spindle.0.brake
net spindle-revs               =>  spindle.0.revs
net spindle-at-speed           =>  spindle.0.at-speed
net spindle-vel-fb-rps         =>  spindle.0.speed-in
net spindle-index-enable      <=>  spindle.0.index-enable

# ---Setup spindle at speed signals---

sets spindle-at-speed true


#******************************
#connections de signaux divers
#******************************

#  ---signaux HALUI---

net axis-select-x  halui.axis.x.select
net jog-x-pos      halui.axis.x.plus
net jog-x-neg      halui.axis.x.minus
net jog-x-analog   halui.axis.x.analog
net x-is-homed     halui.joint.0.is-homed
net axis-select-y  halui.axis.y.select
net jog-y-pos      halui.axis.y.plus
net jog-y-neg      halui.axis.y.minus
net jog-y-analog   halui.axis.y.analog
net y-is-homed     halui.joint.1.is-homed
net axis-select-z  halui.axis.z.select
net jog-z-pos      halui.axis.z.plus
net jog-z-neg      halui.axis.z.minus
net jog-z-analog   halui.axis.z.analog
net z-is-homed     halui.joint.2.is-homed
net axis-select-a  halui.axis.a.select
net jog-a-pos      halui.axis.a.plus
net jog-a-neg      halui.axis.a.minus
net jog-a-analog   halui.axis.a.analog
net a-is-homed     halui.joint.3.is-homed
net jog-selected-pos      halui.axis.selected.plus
net jog-selected-neg      halui.axis.selected.minus
net spindle-manual-cw     halui.spindle.0.forward
net spindle-manual-ccw    halui.spindle.0.reverse
net spindle-manual-stop   halui.spindle.0.stop
net machine-is-on         halui.machine.is-on
net jog-speed             halui.axis.jog-speed
net MDI-mode              halui.mode.is-mdi

#  ---signaux d'arrosage---

net coolant-mist      <=  iocontrol.0.coolant-mist
net coolant-flood     <=  iocontrol.0.coolant-flood

#  ---signal de sonde---

net probe-in          =>  or2.0.in0
net tool-lenght       =>  or2.0.in1
net probe_or_tool        or2.0.out         =>  motion.probe-input

#  ---signaux contrôle mouvement---

net in-position               <=  motion.in-position
net machine-is-enabled        <=  motion.motion-enabled

#  ---signaux entrée / sortie numérique---

#  ---signaux d'A/U---

net outok        estop-latch.0.ok-out              iocontrol.0.emc-enable-in
net faultin      estop-latch.0.fault-in
net ok-in        iocontrol.0.user-enable-out       estop-latch.0.ok-in
net resetestop   iocontrol.0.user-request-enable   estop-latch.0.reset

#  ---signaux changeur manuel d'outil---

#loadusr -W hal_manualtoolchange
#net tool-change-request     iocontrol.0.tool-change       =>  hal_manualtoolchange.change
#net tool-change-confirmed   iocontrol.0.tool-changed      <=  hal_manualtoolchange.changed
#net tool-number             iocontrol.0.tool-prep-number  =>  hal_manualtoolchange.number
#net tool-prepare-loopback   iocontrol.0.tool-prepare      =>  iocontrol.0.tool-prepared

#******************************
# MPG
#******************************

# Tailles des pas de jog

setp mux8.0.in1 0.001
setp mux8.0.in2 0.01
setp mux8.0.in4 0.1

# Sélecteur de taille des pas du jog

net scale1        mux8.0.sel0
net scale2        mux8.0.sel1
net scale3        mux8.0.sel2

net pend-scale    joint.0.jog-scale     axis.x.jog-scale     <= mux8.0.out
net pend-scale    joint.1.jog-scale     axis.y.jog-scale
net pend-scale    joint.2.jog-scale     axis.z.jog-scale
net pend-scale    joint.3.jog-scale     axis.a.jog-scale

# Sélecteur d'axe

net mpg-x         joint.0.jog-enable    axis.x.jog-enable
net mpg-y         joint.1.jog-enable    axis.y.jog-enable
net mpg-z         joint.2.jog-enable    axis.z.jog-enable
net mpg-A         joint.3.jog-enable    axis.a.jog-enable


net pend-counts   joint.0.jog-counts    axis.x.jog-counts
net pend-counts   joint.1.jog-counts    axis.y.jog-counts
net pend-counts   joint.2.jog-counts    axis.z.jog-counts
net pend-counts   joint.3.jog-counts    axis.a.jog-counts

Please Log in or Create an account to join the conversation.

More
17 Aug 2021 15:27 - 17 Aug 2021 15:28 #217992 by PCW
Replied by PCW on topic Position error with encoder
If you get an offset after motion with an encoder feedback system,
it suggest this the encoder counting is incorrect This could be due to
errors in the encoder signals or perhaps EMI

As a first step to diagnosis, I would enable encoder error detection
something like:

setp hm2_7i95.0.encoder.00.quad-error-enable true

 and checking if hm2_7i95.0.encoder.00.quad-error gets set
(this will cause a popup error notifier on some GUIs)
 
Last edit: 17 Aug 2021 15:28 by PCW.
The following user(s) said Thank You: tommylight, Messkid

Please Log in or Create an account to join the conversation.

More
17 Aug 2021 15:44 #217993 by Messkid
Replied by Messkid on topic Position error with encoder
Thanks, i'll check this. I also opened the closed-loop system and used the step counting system to double check if i have an error with my encoders.

I use gemocappy so I add this command in my HAL file for both X and Y encoder and I should get a popup anytime an error in the encoder counting occurs ?

Please Log in or Create an account to join the conversation.

More
17 Aug 2021 16:08 #217997 by PCW
Replied by PCW on topic Position error with encoder
Not sure with Gmoccapy but you can always monitor the error with halshow or halmeter

Please Log in or Create an account to join the conversation.

More
17 Aug 2021 22:39 #218026 by andypugh
Another possibility is that a coupling is slipping on the shaft, or that the encoder disc in the motor is loose.

Please Log in or Create an account to join the conversation.

More
18 Aug 2021 07:38 - 18 Aug 2021 07:41 #218046 by Muzzer
Replied by Muzzer on topic Position error with encoder
Or the stepper drives are losing steps? This could be caused by the step length and step space values being too short ie effectively the step frequency is too high (you have 5us currently, equivalent to 100kHz) or the drive current through the step input opto being too low (what series resistor is fitted?). Possibly noise pickup on the step inputs. Sounds like a marginal effect if it's losing random distances each time.
What pulse frequency would you need to achieve the max velocity with the gearing, step scale etc settings here?
You could increase the step lengths, reduce the maxvel etc to see if the stepper drive is failing to register all the step inputs.
Last edit: 18 Aug 2021 07:41 by Muzzer.

Please Log in or Create an account to join the conversation.

More
18 Aug 2021 09:08 - 18 Aug 2021 09:12 #218052 by andypugh

Or the stepper drives are losing steps? 

This is (I think) a closed-loop system so it can only lose steps if they never arrive. If the system fails to move for a physical reason then it should either recover position or trip the following error. 
However, that dies assume that the right number of steps are received by the system. (It also assumes that LinuxCNC is not in the feedback loop) 


LinuxCNC is generating step commands and monitoring encoder feedback. Even if not all step commands arrive, the PID should correct for that.
So the only places to lose position seem to be:
1) Bad encoder counts
2) Mechanical slip (draw a marker pen line across the couplings)
3) Encoder mechanical problems, ie disc slipping on the shaft.
Last edit: 18 Aug 2021 09:12 by andypugh.

Please Log in or Create an account to join the conversation.

More
18 Aug 2021 09:20 #218055 by Messkid
Replied by Messkid on topic Position error with encoder
I everybody, i'm very surprised to see all your replies 

The encoders on the X and Y axis are linear encoders, so an issue regarding the encoders is the main cause I think. I disconnected the encoders on the HAL file and the result is very clear : the position is great after a blank program.
So now I need to find where the error is between the encoder and the mesa card, is there a way to avoid noise on the measure ?
Because the BF-16 has some float on the axis, and I want to avoid missed steps on my motors during a program.

I'll add the "quad-error-enable true" on the HAL file too to see if it changes anything !
Have a nice day everyone !

Please Log in or Create an account to join the conversation.

More
18 Aug 2021 09:24 #218057 by Aciera
Replied by Aciera on topic Position error with encoder
If this is a closed loop system would you not want at least an 'I' value > zero in your PID setup?

Please Log in or Create an account to join the conversation.

More
18 Aug 2021 09:49 #218061 by Messkid
Replied by Messkid on topic Position error with encoder
Before a PID tuning, i though that this kind of error i'm getting is beyond a faulty PID, but mayber i'm wrong. It looks like my encoder is missing steps here and therefore is creating an offset during the program

Please Log in or Create an account to join the conversation.

Time to create page: 0.502 seconds
Powered by Kunena Forum