Hi all

Can you help me for better PID tunning i'm unsure about the gain setting.

But the most question is there a way to force waiting spindle near or 
axactly at 0rpm before changing direction reverse/forward ?

If you see something strange i really like to have some checking lol.

Br

parts of my hal file :
#####################################################################
# Spindel VFD closed loop with PID LOWPASS NEAR SCALE
#####################################################################

newinst pid pid-s                   # used for closed loop spindle
newinst lowpass lp-s-fb
newinst near near-s-fb              # used for spindle at speed
newinst scale scale-spindle-rpm     # used for display RPM to user

# maxerror is related to the Igain (max value possible to add by pid = 
Igain x maxerrorI)
setp pid-s.maxerrorI 30
setp pid-s.Pgain .01
setp pid-s.Igain 1
setp pid-s.Dgain 0
setp pid-s.bias 0
setp pid-s.FF0 1
setp pid-s.FF1 0
setp pid-s.FF2 0
setp pid-s.deadband 0
setp pid-s.maxoutput 60

setp near-s-fb.scale 1.01        # 1.01 Allow 1% / 1.1 Allow 10% for speed 
cmd vs real
setp lp-s-fb.gain 0.005


# --- Spindle encoder
setp hpg.encoder.00.chan.00.scale 400                     # counts per 
revolution
setp hpg.encoder.00.chan.00.filter 1                      # Currently 
unsupported, included for compatability with hm2. ????  
setp hpg.encoder.00.chan.00.index-mask 1                  # Currently 
unsupported, included for compatability with hm2. ????  
                                                          # disable encoder 
index as it is not working in pru encoder (finally seems to be ok)
#setp hpg.encoder.00.chan.00.counter-mode 0               # Quadrature mode 
AB default

net spindle-index-enable motion.spindle-index-enable <=> 
hpg.encoder.00.chan.00.index-enable pid-s.index-enable # need testing

# ---Spindle VFD closed loop with PID and compensation
net spindle-pos hpg.encoder.00.chan.00.position => motion.spindle-revs      
                     # report our revolution count to the motion controller
     
net spindle-vel-fb hpg.encoder.00.chan.00.velocity => lp-s-fb.in 
pid-s.feedback                  # report encoder speed to pid and speed 
filter input

net spindle-vel-fb-lp lp-s-fb.out => near-s-fb.in2  motion.spindle-speed-in 
scale-spindle-rpm.in # report speed filtered to motion controller + scale 
input
                                                                            
                     # +report speed filtered to near component  = Yes/No 
allowed with 1% difference

net spindle-at-speed near-s-fb.out => motion.spindle-at-speed              
                      # connect the near output to motion spindle-at-speed 
= Yes/No
setp scale-spindle-rpm.gain 60                                              
                     # scale filtered speed RPSx60 = asked RPM 
net spindle-vel-rpm scale-spindle-rpm.out                                  
                      # create hal for user display asked RPM connected 
with scale



# ---"PWM 24v to opto-PNP to 0/5V" driven by pru pwmgen for now connected 
to speed potentiometer
# ---setup spindle control signals and soft start---
newinst limit2 lim-s-speed

setp lim-s-speed.min -3000
setp lim-s-speed.max 3000
setp lim-s-speed.maxv 12
setp hpg.pwmgen.00.out.00.scale 60
setp hpg.pwmgen.00.pwm_period 10000000                              # spec 
du controler ACRF16

net spindle.is-on motion.spindle-on hpg.pwmgen.00.out.00.enable     # 
active pwmgen only when spindle is on from motion 

net spindle-vel-cmd-rps motion.spindle-speed-out-rps lim-s-speed.in 
near-s-fb.in1
net spindle-vel-cmd-rps-lim lim-s-speed.out => pid-s.command
net spindle-output pid-s.output => hpg.pwmgen.00.out.00.value

net spindle-vel-cmd-rps-abs motion.spindle-speed-out-rps-abs => 
comp-s-cmd.in1
net spindle-vel-cmd <= motion.spindle-speed-out
net spindle-vel-cmd-rpm-abs <= motion.spindle-speed-out-abs

net spindle.is-on => pid-s.enable fur.do-6                     # output pin 
for enable VFD
net spindle.runs-reverse motion.spindle-reverse => fur.do-7    # output pin 
for reverse direction
#####################################################################


# THREADS

addf lp-s-fb servo-thread
addf near-s-fb servo-thread
#addf comp-s-cmd slow-thread          #servo-thread
addf lim-s-speed servo-thread
addf pid-s.do-pid-calcs servo-thread
addf scale-spindle-rpm slow-thread


-- 
website: http://www.machinekit.io blog: http://blog.machinekit.io github: 
https://github.com/machinekit
--- 
You received this message because you are subscribed to the Google Groups 
"Machinekit" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/machinekit/cf4872d6-8bbe-4da2-972a-8334826bb04c%40googlegroups.com.

Reply via email to