"Tweaking Spindle Speed"
Progress continues with my Smithy CNC1240 machine.
Today, I measured and charted spindle speeds.
The columns are "Programmed Speed", RPM measured with a digital tachometer, and the RPM indicated on the VFD drive unit.
The VFD and tachometer agree quite closely.
The Programmed speed is off about 20% at RPM under 1000. i.e. S500 M03 produces an actual RPM of 400.
Since most of my work is hard metal, the RPM range I an concerned with is from 300-1500 RPM.
I recall seeing an opportunity to "adjust" my spindle speed inside StepConf. However, my machine was hard coded without StepConf.
What lines in the HAL file should I be looking at to "tweak" the programmed RPM to match actual RPM?
With kind regards,
David
Please Log in or Create an account to join the conversation.
I have a similar problem on my lathe where the 0-10v signal to the GEC speed controller is supplied from a velocity stepgen and a pulse to analog converter.
The resulting mismatch between commanded and actual speed is resolved using a scale component
From the .hal file
loadrt scale
# Use a scale module for offset and scaling of the stepgen
# Offset and scale are determined by first calculating and testing
#
setp scale.0.in 0
setp scale.0.gain 1.26 # GIVES TRUE 600 RPM in M4
setp scale.0.offset 0
addf scale.0 servo-thread
# Connect spindle speed to scaler
net spindle-cmd motion.spindle-speed-out => scale.0.in
# Connect scaler output to stepgen velocity
net spindle-freq <= scale.0.out => stepgen.4.velocity-cmd
If you find that changing gear ratios affects the overall scaling, you can adjust the scaling using
halcmd setp scale.0.gain NNN
I have a M code which takes a number between 1 and 4 and sets the scale according to which pulley ratio is in use
regards
Please Log in or Create an account to join the conversation.
What lines in the HAL file should I be looking at to "tweak" the programmed RPM to match actual RPM?
If the error is non-linear then the HAL "lincurve" component can probably help.
www.linuxcnc.org/docs/html/man/man9/lincurve.9.html
Please Log in or Create an account to join the conversation.
Sadly, the previous comments have me more baffled than ever.
I did tinker with the HAL file and modified two lines...
setp pwmgen.0.scale 4000
setp pwmgen.0.offset 0.0
I inserted numbers from the StepConf Spindle page and things did happen. The spindle turns much faster than the commanded S-value.
I researched the HAL user manual and did not learn much about pwmgen.
Perhaps someone can give me a layman's explanation of the following lines I copied from my HAL file?
I suspect a modification of the two previous pwmgen lines will bring my command speed and actual closer together.
loadrt pwmgen output_type=1
setp pwmgen.0.pwm-freq 25.0
setp pwmgen.0.scale 4000
setp pwmgen.0.offset 0.0
setp pwmgen.0.min-dc 0.01
setp pwmgen.0.max-dc 0.99
setp pwmgen.0.dither-pwm true
addf pwmgen.make-pulses base-thread
addf pwmgen.update servo-thread
net spindle-pwm parport.0.pin-16-out pwmgen.0.pwm
Cheers,
Dave
Please Log in or Create an account to join the conversation.
Perhaps someone can give me a layman's explanation of the following lines I copied from my HAL file?
loadrt pwmgen output_type=1
Loads a pwmgen component, ie a little software module that has an "output" that switches between true and false in a "pwm-like" manner. This output is connected to a physical IO pin.
output_type = 1 means that it has a PWM output and a direction output, as described in the manual page: www.linuxcnc.org/docs/html/man/man9/pwmgen.9.html
A PWM base frequency of 25 Hz.setp pwmgen.0.pwm-freq 25.0
If the input value passed to the component is 4000 then it will be 100% duty-cycle (always on). If the value is 2000 then it will be a 50% 25Hz square wave.setp pwmgen.0.scale 4000
So, (leaving out a few steps in the chain) a spindle command of 4000 or more will give full RPM at the spindle. This is probably the line you need to pay most attention to.
An input value of zero will have an output of zero. If you wanted an input of zero to give non-zero output duty cycle, change this.setp pwmgen.0.offset 0.0
Give zero output unless input > 0.01 (rpm)setp pwmgen.0.min-dc 0.01
Full-scale request gives a 99% square wave out, not a 100%.setp pwmgen.0.max-dc 0.99
If the duty cycle is not an integer number of base periods then alternate between the available closest values.setp pwmgen.0.dither-pwm true
Make the software component run at the base-period rate. If this is 50,000nS then every 50uS the module decides if it is time to change the state of the output. At 50% duty cycle and 25Hz PWM frequency this means that the output changes state every (1 / 25) seconds / 50uS * 50% = 400 iterations. This also means that you have a 800 possible duty cycle values (without dithering)addf pwmgen.make-pulses base-thread
This is a second function of the module that does the more complicated mathematics to work out how many base-periods the output should be high for, and how many it should be low for.addf pwmgen.update servo-thread
Connect the output value of the pwmgen to a physical output pin and call that signal net "spindle-pwn" in case you need to access the value elsewhere in the HAL file. (to connect to a meter, for example)net spindle-pwm parport.0.pin-16-out pwmgen.0.pwm
Please Log in or Create an account to join the conversation.
I need to add your explanation to the manual.
JT
Please Log in or Create an account to join the conversation.
Annoyed by the spindle running faster than commanded, I "tinkered" with the HAL file.
The old value was...
setp pwmgen.0.offset 0.0
I altered it to read...
setp pwmgen.0.offset -0.018
The new value has closed the gap with the lower speeds that I need most for the tool steels I machine. About 2000 RPM, the actual values are slightly less than commanded.
Cheers,
Dave
Please Log in or Create an account to join the conversation.
If not, then Lincurve should be able to linearise your response.
Please Log in or Create an account to join the conversation.