Rotary axis scale units 7i77. pid output minimum too large.
- alan_3301
- Offline
- Elite Member
- Posts: 256
- Thank you received: 33
hm2_5i25.0.encoder.02.scale is set to 200. Servo encoder outputting 9000 PPR (36000 counts) geared 2:1 to the axis. I calculate 72,000 counts per revolution, or 200 counts per degree.
hm2_5i25.0.7i77.0.1.analogout5-scalemax is set to 9000. The axis speed at 10V is 1500rpm = 25rps = 9000 degrees/s
The ini has [TRAJ] ANGULAR_UNITS = degree. But maybe I'm not supposed to use degrees? Maybe scale should be set to 72000? and scalemax set to 1500 or 25?
I will try those numbers tomorrow to see if it makes any difference. In the meantime, can anyone say if this is the cause of the large minimum pid output?
Please Log in or Create an account to join the conversation.
- alan_3301
- Offline
- Elite Member
- Posts: 256
- Thank you received: 33
# Generated by PNCconf at Tue Jan 1 22:21:25 2002
# If you make changes to this file, they will be
# overwritten when you run PNCconf again
[EMC]
MACHINE = lathe1
DEBUG = 0
[DISPLAY]
DISPLAY = axis
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
MAX_FEED_OVERRIDE = 2.000000
MAX_SPINDLE_OVERRIDE = 1.000000
MIN_SPINDLE_OVERRIDE = 0.500000
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 5
PROGRAM_PREFIX = /home/alan/linuxcnc/nc_files
PYVCP = pyvcp-panel.xml
INCREMENTS = .1in .05in .01in .005in .001in .0005in .0001in
LATHE = 1
POSITION_FEEDBACK = ACTUAL
DEFAULT_LINEAR_VELOCITY = 0.250000
MAX_LINEAR_VELOCITY = 10.000000
MIN_LINEAR_VELOCITY = 0.010000
DEFAULT_ANGULAR_VELOCITY = 5
MAX_ANGULAR_VELOCITY = 60.00
MIN_ANGULAR_VELOCITY = 1
EDITOR = gedit
GEOMETRY = xz
[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
[EMCMOT]
EMCMOT = motmod
COMM_TIMEOUT = 1.0
COMM_WAIT = 0.010
SERVO_PERIOD = 1000000
[HOSTMOT2]
# **** This is for info only ****
# DRIVER0=hm2_pci
# BOARD0=5i25
[HAL]
HALUI = halui
HALFILE = lathe1.hal
HALFILE = custom.hal
POSTGUI_HALFILE = postgui_call_list.hal
SHUTDOWN = shutdown.hal
[HALUI]
[TRAJ]
AXES = 6
COORDINATES = X Z C
LINEAR_UNITS = inch
ANGULAR_UNITS = degree
CYCLE_TIME = 0.010
DEFAULT_VELOCITY = 0.20
MAX_LINEAR_VELOCITY = 2.00
[EMCIO]
EMCIO = io
CYCLE_TIME = 0.100
TOOL_TABLE = tool.tbl
#********************
# Axis X
#********************
[AXIS_0]
TYPE = LINEAR
HOME = 0.0
FERROR = 0.5
MIN_FERROR = 0.05
MAX_VELOCITY = 3.5
MAX_ACCELERATION = 30.0
P = 500.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
ENCODER_SCALE = 101600
OUTPUT_SCALE = -9.84251968503937
OUTPUT_MIN_LIMIT = -9.84251968503937
OUTPUT_MAX_LIMIT = 9.84251968503937
MIN_LIMIT = -0.001
MAX_LIMIT = 11.8
HOME_OFFSET = 0.0
#********************
# Axis Z
#********************
[AXIS_2]
TYPE = LINEAR
HOME = 0.0
FERROR = 0.5
MIN_FERROR = 0.05
MAX_VELOCITY = 3.5
MAX_ACCELERATION = 30.0
P = 500.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
ENCODER_SCALE = 101600
OUTPUT_SCALE = -9.84251968503937
OUTPUT_MIN_LIMIT = -9.84251968503937
OUTPUT_MAX_LIMIT = 9.84251968503937
MIN_LIMIT = -10.83
MAX_LIMIT = 0.001
HOME_OFFSET = 0.0
#********************
# Axis C
#********************
[AXIS_5]
TYPE = ANGULAR
WRAPPED_ROTARY = 1
HOME = 0.0
HOME_SEARCH_VEL = 0
FERROR = 9999999
MIN_FERROR = 9999999
MAX_VELOCITY = 3.5
MAX_ACCELERATION = 30.0
P = 4500
I = 0.0
D = 0.0
FF0 = 0.0
FF1 = 1.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 9000
#encoder output 200 counts per degree
ENCODER_SCALE = 200
#OUTPUT_SCALE = -9000
#output scale 9000 degrees/s @ 10V or 1500rpm or 25rps.
OUTPUT_MIN_LIMIT = -9000
OUTPUT_MAX_LIMIT = 9000
MIN_LIMIT = -360
MAX_LIMIT = 360
#HOME_OFFSET = 0.0
#********************
# Spindle
#********************
[SPINDLE_9]
P = 0.0
I = 0.0
D = 0.0
FF0 = 1.0
FF1 = 0.0
FF2 = 0.0
BIAS = 0.0
DEADBAND = 0.0
MAX_OUTPUT = 1500
#encoder output 72000 counts per rev
#ENCODER_SCALE = 72000
OUTPUT_SCALE = 9000
#output scale 9000 degrees/s @ 10V or 1500rpm or 25rps.
OUTPUT_MIN_LIMIT = -9000
OUTPUT_MAX_LIMIT = 9000
# Generated by PNCconf at Tue Jan 1 22:21:25 2002
# If you make changes to this file, they will be
# overwritten when you run PNCconf again
loadrt trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
loadrt hostmot2
loadrt hm2_pci config=" num_encoders=10 num_pwmgens=0 num_stepgens=0 sserial_port_0=300xxx"
setp hm2_5i25.0.watchdog.timeout_ns 5000000
loadrt pid names=pid.x,pid.z,pid.c,pid.s
loadrt abs names=abs.spindle
loadrt lowpass names=lowpass.spindle
loadrt scale names=scale.spindle,scale.spindle2,scale.spindle3
loadrt mux16 names=jogincr
loadrt mux2 count=1
loadrt muxbit2 count=1
#loadusr -W mb2hal config=mb2hal.ini
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.z.do-pid-calcs servo-thread
addf pid.c.do-pid-calcs servo-thread
addf pid.s.do-pid-calcs servo-thread
addf jogincr servo-thread
addf scale.spindle servo-thread
addf scale.spindle2 servo-thread
addf scale.spindle3 servo-thread
addf abs.spindle servo-thread
addf lowpass.spindle servo-thread
addf hm2_5i25.0.write servo-thread
addf mux2.0 servo-thread
addf muxbit2.0 servo-thread
#*******************
# AXIS X
#*******************
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 .0005
net x-index-enable <=> pid.x.index-enable
net x-enable => pid.x.enable
net x-pos-cmd => pid.x.command
net x-vel-cmd => pid.x.command-deriv
net x-pos-fb => pid.x.feedback
net x-output <= pid.x.output
# ---PWM Generator signals/setup---
setp hm2_5i25.0.7i77.0.1.analogout0-scalemax [AXIS_0]OUTPUT_SCALE
setp hm2_5i25.0.7i77.0.1.analogout0-minlim [AXIS_0]OUTPUT_MIN_LIMIT
setp hm2_5i25.0.7i77.0.1.analogout0-maxlim [AXIS_0]OUTPUT_MAX_LIMIT
net x-output => hm2_5i25.0.7i77.0.1.analogout0
net x-pos-cmd <= axis.0.motor-pos-cmd
net x-enable <= axis.0.amp-enable-out
# enable _all_ sserial pwmgens
net x-enable => hm2_5i25.0.7i77.0.1.analogena
# ---Encoder feedback signals/setup---
setp hm2_5i25.0.encoder.00.counter-mode 0
setp hm2_5i25.0.encoder.00.filter 1
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
net x-pos-fb <= hm2_5i25.0.encoder.00.position
net x-vel-fb <= hm2_5i25.0.encoder.00.velocity
net x-pos-fb => axis.0.motor-pos-fb
net x-index-enable axis.0.index-enable <=> hm2_5i25.0.encoder.00.index-enable
net x-pos-rawcounts <= hm2_5i25.0.encoder.00.rawcounts
# ---setup home / limit switch signals---
net x-home-sw => 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
#*******************
# AXIS Z
#*******************
setp pid.z.Pgain [AXIS_2]P
setp pid.z.Igain [AXIS_2]I
setp pid.z.Dgain [AXIS_2]D
setp pid.z.bias [AXIS_2]BIAS
setp pid.z.FF0 [AXIS_2]FF0
setp pid.z.FF1 [AXIS_2]FF1
setp pid.z.FF2 [AXIS_2]FF2
setp pid.z.deadband [AXIS_2]DEADBAND
setp pid.z.maxoutput [AXIS_2]MAX_OUTPUT
setp pid.z.error-previous-target true
setp pid.z.maxerror .0005
net z-index-enable <=> pid.z.index-enable
net z-enable => pid.z.enable
net z-pos-cmd => pid.z.command
net z-vel-cmd => pid.z.command-deriv
net z-pos-fb => pid.z.feedback
net z-output <= pid.z.output
# ---PWM Generator signals/setup---
setp hm2_5i25.0.7i77.0.1.analogout1-scalemax [AXIS_2]OUTPUT_SCALE
setp hm2_5i25.0.7i77.0.1.analogout1-minlim [AXIS_2]OUTPUT_MIN_LIMIT
setp hm2_5i25.0.7i77.0.1.analogout1-maxlim [AXIS_2]OUTPUT_MAX_LIMIT
net z-output => hm2_5i25.0.7i77.0.1.analogout1
net z-pos-cmd <= axis.2.motor-pos-cmd
net z-enable <= axis.2.amp-enable-out
# ---Encoder feedback signals/setup---
setp hm2_5i25.0.encoder.01.counter-mode 0
setp hm2_5i25.0.encoder.01.filter 1
setp hm2_5i25.0.encoder.01.index-invert 0
setp hm2_5i25.0.encoder.01.index-mask 0
setp hm2_5i25.0.encoder.01.index-mask-invert 0
setp hm2_5i25.0.encoder.01.scale [AXIS_2]ENCODER_SCALE
net z-pos-fb <= hm2_5i25.0.encoder.01.position
net z-vel-fb <= hm2_5i25.0.encoder.01.velocity
net z-pos-fb => axis.2.motor-pos-fb
net z-index-enable axis.2.index-enable <=> hm2_5i25.0.encoder.01.index-enable
net z-pos-rawcounts <= hm2_5i25.0.encoder.01.rawcounts
# ---setup home / limit switch signals---
net z-home-sw => axis.2.home-sw-in
net z-neg-limit => axis.2.neg-lim-sw-in
net z-pos-limit => axis.2.pos-lim-sw-in
#*******************
# SPINDLE S
#*******************
setp pid.s.Pgain [SPINDLE_9]P
setp pid.s.Igain [SPINDLE_9]I
setp pid.s.Dgain [SPINDLE_9]D
setp pid.s.bias [SPINDLE_9]BIAS
setp pid.s.FF0 [SPINDLE_9]FF0
setp pid.s.FF1 [SPINDLE_9]FF1
setp pid.s.FF2 [SPINDLE_9]FF2
setp pid.s.deadband [SPINDLE_9]DEADBAND
setp pid.s.maxoutput [SPINDLE_9]MAX_OUTPUT
setp pid.s.error-previous-target true
setp pid.s.maxerror .0005
net spindle-index-enable <=> pid.s.index-enable
net spindle-enable-mux => pid.s.enable
net spindle-vel-cmd-rpm => pid.s.command
net spindle-fb-rpm => pid.s.feedback
net spindle-pid-output <= pid.s.output
# ---PWM Generator signals/setup---
setp hm2_5i25.0.7i77.0.1.analogout5-scalemax [SPINDLE_9]OUTPUT_SCALE
setp hm2_5i25.0.7i77.0.1.analogout5-minlim [SPINDLE_9]OUTPUT_MIN_LIMIT
setp hm2_5i25.0.7i77.0.1.analogout5-maxlim [SPINDLE_9]OUTPUT_MAX_LIMIT
net spindle-pid-output => mux2.0.in0
net spindle-mux-output mux2.0.out => hm2_5i25.0.7i77.0.1.analogout5
net spindle-enable-mux muxbit2.0.out => hm2_5i25.0.7i77.0.1.spinena
net spindle-revs <= hm2_5i25.0.encoder.02.position
net spindle-vel-fb-dps <= hm2_5i25.0.encoder.02.velocity
net spindle-index-enable <=> hm2_5i25.0.encoder.02.index-enable
# ---setup spindle control signals---
net spindle-vel-cmd-rps <= motion.spindle-speed-out-rps
net spindle-vel-cmd-rps-abs <= motion.spindle-speed-out-rps-abs
net spindle-vel-cmd-rpm <= motion.spindle-speed-out
net spindle-vel-cmd-rpm-abs <= motion.spindle-speed-out-abs
net spindle-on-bit motion.spindle-on => muxbit2.0.in0
net spindle-cw <= motion.spindle-forward
net spindle-ccw <= motion.spindle-reverse
net spindle-brake <= motion.spindle-brake
#net spindle-revs => motion.spindle-revs
#need to divide by 360
setp scale.spindle2.gain 0.002777777777778
net spindle-revs scale.spindle2.in
net spindle-revs-scaled scale.spindle2.out => motion.spindle-revs
net spindle-at-speed => motion.spindle-at-speed
setp scale.spindle3.gain 0.016666666667
net spindle-vel-fb-dps scale.spindle3.in
net spindle-vel-fb-rps scale.spindle3.out => motion.spindle-speed-in
net spindle-index-enable <=> motion.spindle-index-enable
# ---Setup spindle at speed signals---
sets spindle-at-speed true
# Use ACTUAL spindle velocity from spindle encoder
# spindle-velocity bounces around so we filter it with lowpass
# spindle-velocity is signed so we use absolute component to remove sign
# ACTUAL velocity is in RPS not RPM so we scale it.
setp scale.spindle.gain 1
setp lowpass.spindle.gain 1.000000
net spindle-vel-fb-rps => scale.spindle.in
net spindle-fb-rpm scale.spindle.out => abs.spindle.in
net spindle-fb-rpm-abs abs.spindle.out => lowpass.spindle.in
net spindle-fb-rpm-abs-filtered <= lowpass.spindle.out
#*******************
# AXIS C piggybacking on AXIS_SPINDLE
#*******************
setp pid.c.Pgain [AXIS_5]P
setp pid.c.Igain [AXIS_5]I
setp pid.c.Dgain [AXIS_5]D
setp pid.c.bias [AXIS_5]BIAS
setp pid.c.FF0 [AXIS_5]FF0
setp pid.c.FF1 [AXIS_5]FF1
setp pid.c.FF2 [AXIS_5]FF2
setp pid.c.deadband [AXIS_5]DEADBAND
setp pid.c.maxoutput [AXIS_5]MAX_OUTPUT
setp pid.c.error-previous-target true
setp pid.c.maxerror .0005
net spindle-index-enable <=> pid.c.index-enable
net c-enable => pid.c.enable
net c-pos-cmd => pid.c.command
net c-vel-cmd => pid.c.command-deriv
net spindle-revs => pid.c.feedback
net c-output <= pid.c.output
#c-output taken care of by mux2 component in spindle section
net c-output => mux2.0.in1
net c-pos-cmd <= axis.5.motor-pos-cmd
net c-enable <= axis.5.amp-enable-out
net c-enable => muxbit2.0.in1
# ---Encoder feedback signals/setup---
setp hm2_5i25.0.encoder.02.counter-mode 0
setp hm2_5i25.0.encoder.02.filter 1
setp hm2_5i25.0.encoder.02.index-invert 0
setp hm2_5i25.0.encoder.02.index-mask 0
setp hm2_5i25.0.encoder.02.index-mask-invert 0
setp hm2_5i25.0.encoder.02.scale [AXIS_5]ENCODER_SCALE
net spindle-revs => axis.5.motor-pos-fb
net spindle-index-enable <=> axis.5.index-enable
# ---setup home / limit switch signals---
net c-home-sw => axis.5.home-sw-in
net c-neg-limit => axis.5.neg-lim-sw-in
net c-pos-limit => axis.5.pos-lim-sw-in
#******************************
# connect miscellaneous signals
#******************************
# ---HALUI signals---
net joint-select-a halui.joint.0.select
net x-is-homed halui.joint.0.is-homed
net jog-x-pos halui.jog.0.plus
net jog-x-neg halui.jog.0.minus
net jog-x-analog halui.jog.0.analog
net joint-select-c halui.joint.2.select
net z-is-homed halui.joint.2.is-homed
net jog-z-pos halui.jog.2.plus
net jog-z-neg halui.jog.2.minus
net jog-z-analog halui.jog.2.analog
net jog-selected-pos halui.jog.selected.plus
net jog-selected-neg halui.jog.selected.minus
net spindle-manual-cw halui.spindle.forward
net spindle-manual-ccw halui.spindle.reverse
net spindle-manual-stop halui.spindle.stop
net machine-is-on halui.machine.is-on
net jog-speed halui.jog-speed
net MDI-mode halui.mode.is-mdi
# ---coolant signals---
net coolant-mist <= iocontrol.0.coolant-mist
net coolant-flood <= iocontrol.0.coolant-flood
# ---probe signal---
net probe-in => motion.probe-input
#sets selected-jog-incr 0.000000
# ---motion control signals---
net in-position <= motion.in-position
net machine-is-enabled <= motion.motion-enabled
# ---digital in / out signals---
# ---estop signals---
net estop-out <= iocontrol.0.user-enable-out
net estop-out => iocontrol.0.emc-enable-in
# ---manual tool change signals---
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
Please Log in or Create an account to join the conversation.
- alan_3301
- Offline
- Elite Member
- Posts: 256
- Thank you received: 33
I am going to spend some time cleaning up the hal file to make it more readable, then continue on in the hal meter to find the problem.
Please Log in or Create an account to join the conversation.
- PCW
- Away
- Moderator
- Posts: 17999
- Thank you received: 4843
So thats the smallest possible PID output step with a P term of 5000 and a encoder scale of 200 counts/degree
That also sounds really high
P= 5000 means a velocity correction of 5000 degrees per second with a 1 degree error, this cannot possibly be stable at a 1 KHz servo thread. This means a 1 degree error would cause a 5 degree correction at a 1 ms servo thread (5000 degrees/sec for 1 ms) this cant end well...
i would try again at 500 gain, if you have slow drift, this can be corrected with the I term
Please Log in or Create an account to join the conversation.
- alan_3301
- Offline
- Elite Member
- Posts: 256
- Thank you received: 33
I still need to figure out the tuning. The X and Z seeemed really easy. Just a P of 500 to get rid of the springiness, and they are rock steady and silent. The C motor is stiff at P of 40, but very noisy. I feel like it's going to need a very small window of P to find the balance. The other motors seemed to have a very wide range of acceptable P values.
Thanks again! It's very nice to have someone that supports their products so well, even for inexperienced users with basic questions.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
- Posts: 23178
- Thank you received: 4865
P gain is floating-point, it can be any value at all, so 0.11 is perfectly valid. As is 0.00000054321
Please Log in or Create an account to join the conversation.
- alan_3301
- Offline
- Elite Member
- Posts: 256
- Thank you received: 33
I will go back to degrees to see how my old settings work. Is there a simple reason this is preferable? Thanks.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
- Posts: 23178
- Thank you received: 4865
Though I had missed the fact that this is a spindle. Spindles work better scaled in revs, for tapping and speed feedback
So, if it's a spindle, don't change it to degrees, that is bad advice from an untrustworthy source.
Please Log in or Create an account to join the conversation.
- alan_3301
- Offline
- Elite Member
- Posts: 256
- Thank you received: 33
I thought I was being smart by scaling the encoder output to give around 1.8 million counts per second at max speed, as I read the 7i77 could read the encoders at 2 mhz, but it starts losing the spindle speed reading after about 250 rpms (300khz)
Default multiplexing rate withHostMot2 firmware is ClockLow / 8,or approximately 4 MHz with 5I25 or 6I25 FPGA hostinterface cards, giving a resolvable count rate of 2 MHz.
Does this mean 2Mhz split up between 6 encoder channels being 333K counts/s per channel? If that is the case I think I will set the servo drive to output 150,000 counts per rev, which should give a safe max speed of 120 rpm (60 rpm spindle speed), with 0.0024 spindle degrees per count.
Then I will get another lower count encoder for the spindle itself. I found one with 2000PPR should give me 2250 rpms at 300khz.
That would let me have c axis encoder scaled in degrees, and spindle encoder scaled in revs. Best of both right?
Thanks for the help.
Please Log in or Create an account to join the conversation.
- alan_3301
- Offline
- Elite Member
- Posts: 256
- Thank you received: 33
Sorry for the endless questions.. just trying to get it right.
Thanks again.
Please Log in or Create an account to join the conversation.