need help adding PID to advanced spindle config

More
30 Jun 2019 19:35 #138247 by 3D-Master
Hello,

i have a Spindle config from someone else (Talla83) and need some changes in order for it to work for me. Unfortunately he doesnt have time atm thats why I am asking here.

The problem is, the config is designed for servo controllers (which have an PID) but i have a simple H-Bridge so Linuxcnc needs to do the PID.

Atm it behaves like this:

M3/M4 will start the Spindle but the rpm is not even remotely close to reach Target RPM because of missing PID

Spindle orientation does have a PID but in order to get the full PID output (strength) i have to set the MAX_OUTPUT in SPINDLE_9 to maximum RPM, which results in way to fast orienting of the spindle (Target orienting rpm is 100 rpm. If i set the MAX_OUTPUT to 100, the spindle wont even turn on)

i have noticed, that sometimes when orienting the spindle, it spins fast but then wont stop at the index signal but slowly come to a stop.

Rigid tapping works without a problem

also i would like to have two seperate PID parameters in the INI, one for normal M3/M4 work and the other for orienting the spindle.

i have uploaded my ini and hal file. The spindle config in the hal file starts at line 350 and in the ini it is at the bottom.

any help is apreciated
Attachments:

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

More
30 Jun 2019 20:10 #138253 by pl7i92
hi
whatsastem did you install and what version are you using sems you are at 2.7.x
#********************
# 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 = 7500.0
ENCODER_SCALE = 4000.0
#OUTPUT_SCALE = -7640
OUTPUT_SCALE = -7500
OUTPUT_MIN_LIMIT = -7500
OUTPUT_MAX_LIMIT = 7500


[SPINDLE_0]
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 = 7500.0
ENCODER_SCALE = 4000.0
#OUTPUT_SCALE = -7640
OUTPUT_SCALE = -7500
OUTPUT_MIN_LIMIT = -7500
OUTPUT_MAX_LIMIT = 7500
in hal
#*******************
#  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

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 mux2.0.in0

#======orient-pid---start

setp   pid.o.Pgain     [SPINDLE_0]P
setp   pid.o.Igain     [SPINDLE_0]I
setp   pid.o.Dgain     [SPINDLE_0]D
setp   pid.o.bias      [SPINDLE_0]BIAS
setp   pid.o.FF0       [SPINDLE_0]FF0
setp   pid.o.FF1       [SPINDLE_0]FF1
setp   pid.o.FF2       [SPINDLE_0]FF2
setp   pid.o.deadband  [SPINDLE_0]DEADBAND
setp   pid.o.maxoutput [SPINDLE_0]MAX_OUTPUT
setp   pid.o.error-previous-target true
net spindle-index-enable       <=> pid.o.index-enable

net orient-angle spindle.0.orient-angle orient.0.angle
net orient-mode spindle.0.orient-mode   orient.0.mode
net spindle-orient spindle.0.orient  orient.0.enable pid.o.enable mux2.0.sel
net spindle-in-pos orient.0.is-oriented spindle.0.is-oriented
net spindle-revs orient.0.position pid.o.feedback
net orient-command orient.0.command pid.o.command
net spindle-output2 pid.o.output mux2.0.in1

and if yu use the pwm outs to the 7i80
# ---PWM Generator signals/setup---

setp   hm2_7i92.0.7i77.0.1.analogout4-scalemax  [SPINDLE_9]OUTPUT_SCALE
setp   hm2_7i92.0.7i77.0.1.analogout4-minlim    [SPINDLE_9]OUTPUT_MIN_LIMIT
setp   hm2_7i92.0.7i77.0.1.analogout4-maxlim    [SPINDLE_9]OUTPUT_MAX_LIMIT

net spindle-output      => hm2_7i92.0.7i77.0.1.analogout4
#net spindle-enable      => hm2_7i92.0.7i77.0.1.spinena

# ---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 gearchoice.0.speed-command   <=  spindle.0.speed-out
net spindle-vel-cmd-rpm-abs    <=  spindle.0.speed-out-abs
net spindle-enable      gearchoice.0.spindle-on  <=  spindle.0.on
net spindle-cw                 <=  spindle.0.forward
net spindle-ccw                <=  spindle.0.reverse
net spindle-brake       gearchoice.0.brake-enable   <=  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
is the hbridge a closed loop controller
as it seams not what encoder are you using
its old but usefull
www.vdwalle.com/Norte/Spindle%20Orientation.html

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

More
30 Jun 2019 20:37 #138255 by 3D-Master
Sorry, i am using Linuxcnc 2.7.14 on Debian

is the hbridge a closed loop controller
as it seams not what encoder are you using


no it is just a plain H-Bridge, controlled with PWM and DIR signals. The Spindle Encoder is plugged into the 7i52s sixth (05) encoder terminals so its fully closed loop

its old but usefull
www.vdwalle.com/Norte/Spindle%20Orientation.html


thanks, i will have a look at it

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

More
30 Jun 2019 20:42 #138256 by 3D-Master
something i forgot to mention is, the spindle config will always ramp up/down when you, for example, run the spindle at 5000 rpm and then want to orient the spindle. It will just ramp down until it a specified time has passed and then orient the spindle, or reverse the direction

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

More
01 Jul 2019 04:33 #138284 by PCW
At the minimum the tuning seems very odd to me

For the normal spindle in velocity mode I would use only FF0 and P and I, and only add I when you are quite close to correct velocity following.
(FF0 only is pure open loop voltage mode with a PWM driven servo motor)
So for this mode I would get the spindle speed as accurate as possible over the
full speed range with just FF0 and then add feedback with some P (as much as it
stable) and then some I

For position mode you use As much D&P (more D allows more P) as is stable then
adjust FF1 for minimum following error vs velocity. Then finally add as much I as is stable

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

Time to create page: 0.297 seconds
Powered by Kunena Forum