"Tweaking Spindle Speed"

More
02 Jul 2015 10:15 #60328 by fc60
Greetings All,

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.

More
02 Jul 2015 17:10 - 02 Jul 2015 20:09 #60333 by ArcEye
Replied by ArcEye on topic "Tweaking Spindle Speed"
Hi

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
Last edit: 02 Jul 2015 20:09 by ArcEye.

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

More
02 Jul 2015 20:10 #60341 by andypugh
Replied by andypugh on topic "Tweaking Spindle Speed"

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.

More
04 Jul 2015 03:54 #60394 by fc60
Replied by fc60 on topic "Tweaking Spindle Speed"
Greetings All,

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.

More
04 Jul 2015 05:36 - 06 Jul 2015 20:19 #60398 by andypugh
Replied by andypugh on topic "Tweaking Spindle Speed"

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

setp pwmgen.0.pwm-freq 25.0

A PWM base frequency of 25 Hz.

setp pwmgen.0.scale 4000

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.
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.

setp pwmgen.0.offset 0.0

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.min-dc 0.01

Give zero output unless input > 0.01 (rpm)

setp pwmgen.0.max-dc 0.99

Full-scale request gives a 99% square wave out, not a 100%.

setp pwmgen.0.dither-pwm true

If the duty cycle is not an integer number of base periods then alternate between the available closest values.

addf pwmgen.make-pulses base-thread

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.update servo-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.

net spindle-pwm parport.0.pin-16-out pwmgen.0.pwm

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)
Last edit: 06 Jul 2015 20:19 by andypugh.

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

More
04 Jul 2015 05:40 #60399 by BigJohnT
Replied by BigJohnT on topic "Tweaking Spindle Speed"
Andy,

I need to add your explanation to the manual.

JT

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

More
13 Jul 2015 07:12 #60604 by fc60
Replied by fc60 on topic "Tweaking Spindle Speed"
Greetings All,

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.

More
13 Jul 2015 21:57 #60615 by andypugh
Replied by andypugh on topic "Tweaking Spindle Speed"
If you have a spindle encoder then your real answer might be closed-loop spindle speed.
If not, then Lincurve should be able to linearise your response.

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

Time to create page: 0.133 seconds
Powered by Kunena Forum