Stepper Closed Loop and PID Tuning Question

More
07 Jan 2018 16:38 #104120 by MatthiasF1210
Hello everybody,

I am using linuxcnc since 1 year on my 3axis mill (wabeco F1210 with homemade cnc components) in an open loop configuration with kind of standard setup.

In the last 3 weeks I did a complete rebuild and added some linear encoders to change the system to closed loop. While doing this I want to renew my hal and ini-File from scratch. So far everything is going ok, even when there is a lot of stuff to learn in all this configuration stuff.

The attached halscope is showing the ferror on X while I am doing a +5mm +10mm -15mm sequence. This was the best result I could find.
My first question is, how is the result? I like it, except of the spike in the beginning of the movement. But I don't know if it is realistic to expect better results.

I wonder if this is not backlash what I see, but I could not influence the behaviour by changing the backlash in the ini file.

Machine details:
Stepper and mechanics:
- Sanyo Denki 103 H7823 1740 (4,0A, 3,00Nm) -> 1600step/rev
- tooth belt 2:1
- ball screw 5mm/rev
--> 640step/mm --> 1step = 0,00156mm
Encoder:
- 1µm
- Mesa 6i25

Hal
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~¯
# Aufbau der Wabeco 3Achse CNC Fräse
# 	- Mesa 6i25 betrieben als 5i25
#	- P2 Anschluss an CNC Steuerung nach EinfachCNC
#	- P3 Anschluss an Maschinenschnittstelle
#
# Features:
#	- 3 Glasmassstäbe mit 1µm Auflösung
#
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~¯

# Include Sektion
loadrt trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
loadrt hostmot2
loadrt hm2_pci config="num_encoders=5 num_pwmgens=1 num_stepgens=4 sserial_port_0=0xxxxxxx"

loadrt pid names=pid.x,pid.y,pid.z,pid.a
loadrt abs names=abs.spindle
loadrt lowpass names=lowpass.spindle

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Generelle Funktionen
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Funtionen
addf hm2_5i25.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	#->  Vorhalt für 4.Achse
#addf abs.spindle              servo-thread	#->  Spindelregelung Später integrieren
#addf lowpass.spindle          servo-thread	#->  Spindelregelung Später integrieren
addf hm2_5i25.0.write         servo-thread


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Generelle Parameter
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
setp hm2_5i25.0.watchdog.timeout_ns 5000000

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Debounce Modul (Entprellung)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
loadrt debounce cfg=8,1				#8 Filter in Gruppe1 und 1 Filter von Gruppe 2
setp debounce.0.delay 		20
addf debounce.0 		servo-thread
setp debounce.1.delay 		1
addf debounce.1 		servo-thread


#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Externe Ein-/Ausgänge
# P3
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
net toolprobe-ext     <=  hm2_5i25.0.gpio.008.in
net touchprobe-ext     <=  hm2_5i25.0.gpio.010.in
net estop-ext	<=  hm2_5i25.0.gpio.020.in

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Externe Ein-/Ausgänge
# P2
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

setp hm2_5i25.0.gpio.018.is_opendrain 	1
setp hm2_5i25.0.gpio.022.is_opendrain 	1
setp hm2_5i25.0.gpio.024.is_opendrain 	1
#setp hm2_5i25.0.gpio.032.is_opendrain	1	# Reserve für eine Zukünftige RL/LL Steuerung der Spindel
#setp hm2_5i25.0.gpio.033.is_opendrain 	1	# Reserve für eine Zukünftige RL/LL Steuerung der Spindel

setp hm2_5i25.0.gpio.018.is_output 	1
setp hm2_5i25.0.gpio.022.is_output 	1
setp hm2_5i25.0.gpio.024.is_output 	1
#setp hm2_5i25.0.gpio.032.is_output 	1	# Reserve für eine Zukünftige RL/LL Steuerung der Spindel
#setp hm2_5i25.0.gpio.033.is_output 	1	# Reserve für eine Zukünftige RL/LL Steuerung der Spindel


net x-enable    	=> hm2_5i25.0.gpio.018.out
net ext-230V-plug 	=> hm2_5i25.0.gpio.022.out
net spindle-on 		=> hm2_5i25.0.gpio.024.out
      
      

#*******************
#  AXIS X Einstellungen
#*******************

# PID Einstellungen

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

# Step Gen signals/setup

setp   hm2_5i25.0.stepgen.00.dirsetup        	[AXIS_0]DIRSETUP
setp   hm2_5i25.0.stepgen.00.dirhold         	[AXIS_0]DIRHOLD
setp   hm2_5i25.0.stepgen.00.steplen         	[AXIS_0]STEPLEN
setp   hm2_5i25.0.stepgen.00.stepspace       	[AXIS_0]STEPSPACE
setp   hm2_5i25.0.stepgen.00.position-scale  	[AXIS_0]STEP_SCALE
setp   hm2_5i25.0.stepgen.00.step_type        	0		# Standard Step Signal
setp   hm2_5i25.0.stepgen.00.control-type     	1		# position control mode (0) (Stepper Openloop) and velocity control mode (1) (Closed Loop)  
setp   hm2_5i25.0.stepgen.00.maxaccel         	[AXIS_0]STEPGEN_MAXACCEL
setp   hm2_5i25.0.stepgen.00.maxvel           	[AXIS_0]STEPGEN_MAXVEL

# SetUp Encoder

setp    hm2_5i25.0.encoder.00.counter-mode 	0
setp    hm2_5i25.0.encoder.00.filter 		1	# 1(0) the counter needs 15(3)clk to register a change
setp    hm2_5i25.0.encoder.00.index-invert	0
setp    hm2_5i25.0.encoder.00.index-mask 	0
setp    hm2_5i25.0.encoder.00.index-mask-invert 0
setp    hm2_5i25.0.encoder.00.scale 		[AXIS_0]ENCODER_SCALE


# ---closedloop stepper signals---

net x-idx-enable <= pid.x.index-enable <=> axis.0.index-enable <=> hm2_5i25.0.encoder.00.index-enable
net x-enable     <= axis.0.amp-enable-out => pid.x.enable => hm2_5i25.0.stepgen.00.enable
net x-pos-cmd    <= axis.0.motor-pos-cmd =>  pid.x.command
net x-pos-fb     <= pid.x.feedback <= hm2_5i25.0.encoder.00.position => axis.0.motor-pos-fb
net x-vel-cmd    <= axis.0.joint-vel-cmd =>  pid.x.command-deriv
net x-output     <= pid.x.output => hm2_5i25.0.stepgen.00.velocity-cmd
        
# ---setup home / limit switch signals---

net x-home-sw     <= hm2_5i25.0.encoder.00.input-index => axis.0.home-sw-in
net x-neg-limit     =>  axis.0.neg-lim-sw-in
net x-pos-limit     =>  axis.0.pos-lim-sw-in    

INI
[EMC]
MACHINE = Test_Mesa
DEBUG = 0

[DISPLAY]
DISPLAY = axis
EMBED_TAB_NAME = GladeVCP
EMBED_TAB_COMMAND = halcmd loadusr -Wn gladevcp gladevcp -c gladevcp -H gvcp_call_list.hal -x {XID} gvcp-panel.ui
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
MAX_FEED_OVERRIDE = 1.4
MAX_SPINDLE_OVERRIDE = 2.000000
MIN_SPINDLE_OVERRIDE = 0.100000
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 5
PROGRAM_PREFIX = /home/linuxcnc/linuxcnc/nc_files
PYVCP = pyvcp-panel.xml
INCREMENTS = 5mm 1mm .5mm .1mm .05mm .01mm .005mm
POSITION_FEEDBACK = ACTUAL

# Geschwindigkeit in mm/s
DEFAULT_LINEAR_VELOCITY = 10.000000
MAX_LINEAR_VELOCITY = 50.000000
MIN_LINEAR_VELOCITY = 0.500000
DEFAULT_ANGULAR_VELOCITY = 12.000000
MAX_ANGULAR_VELOCITY = 180.000000
MIN_ANGULAR_VELOCITY = 1.666667
EDITOR = gedit
GEOMETRY = xyz




[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
SUBROUTINE_PATH = macros
# Enables the reading of INI and HAL values from gcode
FEATURES=12
# is the sub, with is called when a error during tool change happens
ON_ABORT_COMMAND=O <on_abort> call
# The remap code
REMAP=M6  modalgroup=6 prolog=change_prolog ngc=change epilog=change_epilog

[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
COMM_WAIT = 0.010
BASE_PERIOD = 100000
SERVO_PERIOD = 1000000
TRAJ_PERIOD = 1000000

[HOSTMOT2]
# **** This is for info only ****
# DRIVER0=hm2_pci
# BOARD0=5i25

[HAL]
HALUI = halui
HALFILE = Test_Mesa_v3.hal
HALFILE = custom.hal
POSTGUI_HALFILE = postgui_call_list.hal
SHUTDOWN = shutdown.hal

[HALUI]

[TRAJ]
AXES = 3
COORDINATES = X Y Z
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
DEFAULT_VELOCITY = 2.50
#globales Maximum gültig für alle Achsen
MAX_VELOCITY = 50.00
MAX_ACCELERATION = 60
#für Setuparbeiten das Homing unterdrücken
NO_FORCE_HOMING = 1

[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100
TOOL_TABLE = tool.tbl

#********************
# Axis X
#********************
[AXIS_0]
TYPE = LINEAR
HOME = 20

# Erlaubte Abweichung von der Sollposition in Abhängigleit von der Geschwindigkeit
# findet eine Interpolation von den beiden Werten statt
FERROR = 10.0
MIN_FERROR = 10.0
BACKLASH = 0.00

# Geschwindigkeit in mm/s
#25 mm/s entspricht 1500mm/min entspricht 1200U/min am Steppermotor
MAX_VELOCITY = 40.0
MAX_ACCELERATION = 60

# PID Reger Abstimmungen
P = 35
I = 0
D = 0
FF0 = 0
FF1 = 1.0015
FF2 = 0.0005
BIAS = 0
DEADBAND = 0.0005
MAX_OUTPUT = 65

# Abstimmung der Stepper Signale (damit sollten max 1000U/min möglich sein)
# - Stepper Hardware 1600 Step pro Umdrehung 
# (in nanoseconds)
DIRSETUP   = 12000
DIRHOLD    = 12000
STEPLEN    = 15000
STEPSPACE  = 15000
# 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 = 50
STEPGEN_MAXACCEL = 100

# Umrechnug Step in mm Vorschub
# 1600 Step/rev, Untersetzung 2:1 , 5mm/rev
STEP_SCALE = 640	
# 1000cnt/mm inverse
ENCODER_SCALE = -1000

# Homeposition
MIN_LIMIT = -0.01
MAX_LIMIT = 200.0
HOME_OFFSET = 0.0
HOME_SEQUENCE = 0

Thanks for your feedback...

Matthias
Attachments:

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

More
07 Jan 2018 17:37 - 07 Jan 2018 17:38 #104126 by PCW
People are often disappointed when they attach linear scales to motion systems because you get a clear
look at almost all the positioning errors...

I think the error spike you see is mostly "stiction" since its much worse when starting motion from a stop
This is quite significant with dovetail type ways
Last edit: 07 Jan 2018 17:38 by PCW.

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

More
07 Jan 2018 18:17 #104127 by MatthiasF1210
Hi PCW,

thanks for your opinion. Overall I am not worried about the precision of the machine, I am just trying to get the best out of it.

"Stiction " makes totally sense, but this leads me to the next question. Is there a Parameter to compensate stiction? This should be possible in theories, just add a little extra while the movement starts...

Thanks

Matthias

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

More
07 Jan 2018 20:01 #104132 by PCW
There's nothing specifically in the PID component for stiction but its probably possible to wire something
up in hal to give a fixed "kick" in the direction of motion when motion starts after having been stopped for
some time (time enough for the oil film to leak out)

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

Time to create page: 0.164 seconds
Powered by Kunena Forum