PWM feedback?

More
13 May 2017 12:05 #93137 by caio
PWM feedback? was created by caio
hello guys,
on my cnc router i connected the spindle in closed loop configuration.
i'm using a VFD with a 0-24000 rpm spindle. linuxcnc control rpm through 0-10v signal.
for feedback i used an hall sensor than make 1 ppr.
it works quite well, but over 18k rpm the feedback isn't read properly.
so i'm thinking to use a microcontroller to convert pulses into pwm signal.
i searched a lot on internet, but i'm not sure if linuxcnc can read pwm from parallel port.
does can it do it? is there specific hal component for that?
if not, can you suggest some alternatives?
thanks

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

More
13 May 2017 13:45 #93139 by PCW
Replied by PCW on topic PWM feedback?
Maybe a simpler solution is just to widen the slot so the Hall pulse is longer
a 50% duty cycle pulse would optimum

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

More
13 May 2017 17:50 #93142 by caio
Replied by caio on topic PWM feedback?
Sounds strange linuxcnc can't read pwm....
anyway, to enlarge the slot (there's no slot, but a little magnet) is not so easy to do, because the sensor is integrated into the spindle, moreover i dont think a bigger duty cycle can solve the issue. my main problem is a 35k ns base thread.
but i had a new idea just now: i could build an hardware scale component to decrease the sensor pulses frequency.
do you think it might work?

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

More
13 May 2017 18:28 #93143 by tommylight
Replied by tommylight on topic PWM feedback?
Base thread is all good, PCW is right to recomend longer pulses as it looks like whatever is sending signals to paraport has issues at higher RPM, most probably the hal sensor. A quick fix could be to add a transistor between the hal sensor and paraport with a resistor to invert the pulses.
18000 RPM is 300 pulses per second, so paraport should have no problems counting that, i can count 65000 of them per second on 2 computers i have.

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

More
13 May 2017 18:43 #93146 by caio
Replied by caio on topic PWM feedback?

A quick fix could be to add a transistor between the hal sensor and paraport with a resistor to invert the pulses.


hi,
having a 95% duty cycle is not the same issue than 5%?
if i invert the pin in software configuration, don't i achieve the same result?

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

More
13 May 2017 21:20 #93150 by tommylight
Replied by tommylight on topic PWM feedback?
Most probably but worth a try at a 20 cent cost and a bit of time.
Changing it in software is not the same thing, although you should try that. Something in that setup is causing signals from hal sensor to fall below the required treshhold for paraport.

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

More
14 May 2017 03:07 #93170 by PCW
Replied by PCW on topic PWM feedback?
I think the issue is just duty cycle (too short of a pulse to reliably detect with a 35 usec sampling rate)
It could also be that the Hall effect sensor is not fast enough

A simple flip-flop will give you 50% duty cycle at 1/2 the speed so if the Hall
effect device is fast enough that might be a simple hardware solution

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

More
14 May 2017 18:52 #93191 by caio
Replied by caio on topic PWM feedback?
i made some try with an optical sensor and an half disk on the spindle's chuck to have a perfect 50% duty cycle, but i got the same result.
so i used halscope to check signals: the feedback don't seems to have problems, also signal from hall sensor seems ok, but maybe i found the problem.
when rpm go over 18k the pwm output becomes very unstable, the spindle speed oscillate a lot and it can't go over 21k.
now i'm supposing to have a wrong software configuration, but i don't find the bottleneck.
this is my closed loop configuration, found on the wiki , with minimal changes to fit my hw.
# --------------------------------------------------
#   Closed Loop Spindle Control
# --------------------------------------------------
    # Initialize the encoder (spindle)
        loadrt encoder num_chan=1
        addf encoder.update-counters base-thread
        addf encoder.capture-position servo-thread
        setp encoder.0.position-scale 1
        setp encoder.0.counter-mode 1

    # Initialize the PID 
        loadrt pid num_chan=1
        addf pid.0.do-pid-calcs servo-thread
        setp pid.0.Pgain 0
        setp pid.0.Igain 1
        setp pid.0.Dgain 1
        setp pid.0.maxoutput 24000

    # Initialize the pwmgen
        loadrt pwmgen output_type=0
        addf pwmgen.update servo-thread
        addf pwmgen.make-pulses base-thread
        setp pwmgen.0.pwm-freq 1000.0
        setp pwmgen.0.min-dc 0.18        
        setp pwmgen.0.scale 24000
        setp pwmgen.0.dither-pwm true

    # Initialize the scale
    # (This is used to scale the encoder pulse to RPM)
    # (In my case, i have 1 ppr so it is scaled by 60)
        loadrt scale count=1
        addf scale.0 servo-thread
        setp scale.0.gain 60

    # Initialize the sum2
        loadrt sum2 count=1
        addf sum2.0 servo-thread

    # Attach the motion.spindle-on to enable the pwmgen and the pid
        net spindle-on motion.spindle-on => pwmgen.0.enable => pid.0.enable

    # Attach the encoder to the parallel port pin
#setp parport.0.pin-10-in-invert 1
        net parport_10_in         parport.0.pin-10-in-not => encoder.0.phase-A => encoder.0.phase-Z

    # Attach the encoder to the motion and the scale
        net spindle_rev_count     encoder.0.position => motion.spindle-revs
        net spindle_index_enable  encoder.0.index-enable <=> motion.spindle-index-enable
        net encoder_raw_velocity  encoder.0.velocity => scale.0.in

    # Attach the pid to the scale, motion, and sum
        net pid_feedback          pid.0.feedback <= motion.spindle-speed-in <= scale.0.out
        net pid_command           pid.0.command  <= motion.spindle-speed-out => sum2.0.in0
        net pid_output            pid.0.output   => sum2.0.in1

    # Attach the pwmgen to the sum and the parallel port
        net pwmgen_value          pwmgen.0.value <= sum2.0.out
	setp parport.0.pin-01-out-invert 1
        net pwmgen_out            pwmgen.0.pwm   => parport.0.pin-01-out

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

More
14 May 2017 19:05 #93192 by tommylight
Replied by tommylight on topic PWM feedback?
Can you do a hal scope of pin 10 at max speed?

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

More
14 May 2017 19:11 #93193 by PCW
Replied by PCW on topic PWM feedback?
The instability/oscillation could be a tuning issue

For a velocity loop you generally want P and I and FF0
You set FF0 first to get as accurate RPM tracking as possible
( PID control with FF0 only is open loop ) and only then do you
add P and I
The following user(s) said Thank You: tommylight

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

Time to create page: 0.299 seconds
Powered by Kunena Forum