Spindle PID control not woring

More
11 Dec 2023 17:06 #287867 by Bassblaster
Hello community,
there is a problem on my Lathe, where I am not able to get the PID closed loop spindle speed control to work. I think something is messed up in my hal file, because whatever PID values I change in the .ini file, there is no change in the spindle behaviour. I used the Pncconf to get a basic hal and ini. The encoder works and when I command a speed of 1500rpm, it shows around 1900rpm when I check out the hal inspector. Somehow the loop is not closed? Maybe the feedback is somehow not connected? I attached my .HAL and .ini file, maybe somebody can spot the error? I tried to find it, using different halfiles from other people, but no luck so far. I am a beginner, so thank you in advance!
Attachments:

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

More
11 Dec 2023 17:41 #287871 by PCW
Replied by PCW on topic Spindle PID control not woring
The PID has been bypassed with this net command:

net spindle-vel-cmd-rpm-abs => hm2_7i96.0.pwmgen.00.value

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

More
13 Dec 2023 16:36 #288054 by Bassblaster
Thank you for your answer. I suppose there must be some variable instead of net spindle-vel-cmd-rpm-abs which is not the commanded speed but rather the speed after scale and PID? I tried:
net spindle-speed-abs => hm2_7i96.0.pwmgen.00.value
But that didn't work out, the VfD did not get any signal. Is my thought process correct? Is there another variable which contains my desired speed with the PID feedback?

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

More
13 Dec 2023 18:16 #288061 by PCW
Replied by PCW on topic Spindle PID control not woring
Currently the PID output pid.s.output is routed through a scale component
to the spindle-output signal. I have no idea if this is desired or
correct but that is currently where the PID output is routed:
net spindle-pid-out pid.s.output => scale.gear.in
net gear-ratio ratio_select.out-f => scale.gear.gain
setp ratio_select.in00 0.000667
setp ratio_select.in01 0.000167
net gear-select-a => ratio_select.sel0
net spindle-output <= scale.gear.out


If this is correct, you would need to connect the PWM value pin to
spindle-output

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

More
13 Dec 2023 21:06 - 13 Dec 2023 21:10 #288076 by Mecanix
*.HAL
loadrt [KINS]KINEMATICS
... ....

loadrt abs count=1
loadrt scale count=1
loadrt near
loadrt pid num_chan=1
loadrt sum2 count=1

addf [HMOT](CARD0).read          servo-thread
addf motion-command-handler        servo-thread
addf motion-controller            servo-thread
addf abs.0                 servo-thread
addf scale.0                 servo-thread
addf near.0                 servo-thread
addf pid.0.do-pid-calcs         servo-thread
addf sum2.0                 servo-thread
addf [HMOT](CARD0).write         servo-thread

# --- SPINDLE-CW ---
net spindle-cw  =>     [HMOT](CARD0).ssr.00.out-01

# --- SPINDLE-CCW ---
net spindle-ccw  =>     [HMOT](CARD0).ssr.00.out-02

########################################################################
### PWM SPINDLE (CLOSED LOOP)
########################################################################
setp pid.0.Pgain     0
setp pid.0.Igain     2
setp pid.0.Dgain     0
setp pid.0.FF0         0
setp pid.0.FF1         0
setp pid.0.bias          0
setp pid.0.deadband      5
setp pid.0.maxerrorI     100
setp pid.0.maxerror     0
setp pid.0.maxoutput    2000
setp pid.0.error-previous-target    true

net spindle-cmd-rpm => hm2_7i96.0.pwmgen.00.value
net spindle-on <= spindle.0.on => hm2_7i96.0.pwmgen.00.enable => pid.0.enable

setp hm2_7i96.0.pwmgen.00.scale [SPINDLE_0]MAX_OUTPUT
    
net spindle-cmd-rpm     <= sum2.0.out
net spindle-cmd-rpm-abs <= spindle.0.speed-out-abs
net spindle-cmd-rps     <= spindle.0.speed-out-rps
net spindle-cmd-rps-abs <= spindle.0.speed-out-rps-abs
net spindle-at-speed    => spindle.0.at-speed
net spindle-cw        <=  spindle.0.forward
net spindle-ccw        <=  spindle.0.reverse

setp [HMOT](CARD0).encoder.00.position-scale [SPINDLE_0]ENCODER_SCALE
setp [HMOT](CARD0).encoder.00.x4-mode 1
setp scale.0.gain 60
net spindle-position [HMOT](CARD0).encoder.00.position => spindle.0.revs
net spindle-velocity-feedback-rps [HMOT](CARD0).encoder.00.velocity => scale.0.in
net spindle-index-enable [HMOT](CARD0).encoder.00.index-enable <=> spindle.0.index-enable

net pid_feedback pid.0.feedback <= spindle.0.speed-in <= scale.0.out
net pid_command pid.0.command <= spindle.0.speed-out => sum2.0.in0
net pid_output pid.0.output => sum2.0.in1

setp near.0.scale    1.1
net spindle-cmd-rps    =>  near.0.in1
net spindle-velocity-feedback-rps    =>  near.0.in2
net spindle-at-speed    <=  near.0.out


pyvcp_option.hal
net pid_feedback    pyvcp.spindle-speed
net spindle-at-speed    => pyvcp.spindle-at-speed-led
 
Last edit: 13 Dec 2023 21:10 by Mecanix.

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

More
28 Dec 2023 17:07 - 28 Dec 2023 17:09 #289266 by Bassblaster
As of today, I got the spindle control working by modifiing:
  • Instead of the scale factors 0.0000..., I used 1, effectively bypassing the gear, then the pindle spun up using:
  • net spindle-output => hm2_7i96.0.pwmgen.00.value
  • The feedback from the encoder was not used, so I used:
    • net spindle-vel-fb-rpm <= hm2_7i96.0.encoder.00.velocity-rpm
    • then I replaced the spindle-vel-fb-rps everywhere in the .hal file to spindle-vel-fb-rpm
    • I had to replace net spindle-vel-cmd-rpm-abs => pid.s.feedback so that net spindle-vel-cmd-rpm => pid.s.feedback, so that reverse also works

      However, I am now faving a new problem, where when I use e,g, G95 G96 D1500 S200 F0.04 I would expect a feedrate of 0.04mm per revoliution. However, the feedrate is approximately 60 times faster than I am commanding. I am not quiet sure how this is possible... everything should be in rpm...
      I attachedmy current .hal and .ini files.Anybody got an idea as to what the error could be?
Attachments:
Last edit: 28 Dec 2023 17:09 by Bassblaster.

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

More
28 Dec 2023 19:19 #289274 by tommylight
spammer booted.

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

Time to create page: 0.098 seconds
Powered by Kunena Forum