Can someone help me setting up my spindle pwm (and soft-start)?

More
22 Oct 2023 12:47 - 22 Oct 2023 12:56 #283499 by phew
Hi,

I am very new to LCNC and currently trying to figure out how to get my spindle to the correct RPM using a cheap china parport bob:
 

What I've got so far and this seems to be somewhat working, is what I copied from a stepconf-generated .hal file:
loadrt pwmgen output_type=1

addf pwmgen.make-pulses base-thread
addf pwmgen.update servo-thread

net spindle-cmd-rpm => pwmgen.0.value
net spindle-on <= spindle.0.on => pwmgen.0.enable
net spindle-pwm <= pwmgen.0.pwm
setp pwmgen.0.pwm-freq 8.0
setp pwmgen.0.scale 24000
setp pwmgen.0.offset -0.1
setp pwmgen.0.dither-pwm true
net spindle-cmd-rpm     <= spindle.0.speed-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-pwm     => parport.0.pin-01-out
net spindle-on      => parport.0.pin-17-out

Do not mind if the values set in this config are odd, I am kinda lost on how to approach this so I played around with the values and checked the output voltage using a multimeter.

My spindle has 9000 rpm minimum and 24000 rpm maximum. I am planning on using a relay for spindle direction, meaning I would like to have 1% speed to to generate the voltage that is about 9000 rpm for my spindle and 100% to generate the voltage that is about 24000 rpm, but I have no idea how to achieve that.

Using the configuration above, I go to the MDI tab and put the spindle in forward at 50% rpm using M03 S12000, this results in ~5.25V on the multimeter. That should be about right. But if I put the spindle in reverse using M04 S12000, the Voltage drops to ~3.27V, when it should actually stay around 5V for half rpm. Also, if I am using M03 S8000 the measured output voltage goes up to ~7.14V. for my understanding, the higher the voltage the more rpm, why would S8000 have a higher voltage than S12000?

Also, starting the machine the multimeter shows slightly above 10V. If I start the spindle using the "spindle clockwise"-button (I am using axis), the voltage drops down to basically no spindle rpm. If I press the "[+]"-button the voltage changes, but in very small steps. I would like it to be 5% or 10% steps.

I figured I must have really messed up at some point, trying to get my patchwork-config to work.

Also the spindle seems to fire up very abruptly and I found the LinuxCNC Spindle Control Example talking about a spindle-speed ramp. However, all the new information about LCNC is currently a bit overwhelming and the learning curve appears to be quite steep.

Can you guys help me out getting the spindle speed control set up with a ramp/soft-start, if possible?

Regards
Attachments:
Last edit: 22 Oct 2023 12:56 by phew. Reason: attached full .hal and .ini files, fixed code tags that got broken after editing

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

More
22 Oct 2023 17:45 - 22 Oct 2023 17:47 #283519 by phew
I just realized I posted in the wrong section, sorry about that. Could someone be so kind and move the topic?

I got the pwmgen working now (I believe), I used the example from the Spindle Control Example page and modified my .hal file until I had no more errors when trying to start the machine.

However, the RPM shown on the display of the VFD shows very different RPM than what I set the spindle to.

Using M03 S12000, which should give me about 12000 RPM,shows 18600 on the VFD display.

The current .hal setup I am working with (excluding the loadrt, addf) looks like

net spindle-speed-cmd spindle.0.speed-out => pwmgen.0.value
net spindle-on spindle.0.on => pwmgen.0.enable
net spindle-pwm pwmgen.0.pwm => parport.0.pin-01-out
setp parport.0.pin-01-out-invert 1
setp pwmgen.0.scale 24000
setp pwmgen.0.dither-pwm true

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

How do I adjust the pwm to better match the real RPM?
Last edit: 22 Oct 2023 17:47 by phew. Reason: typos

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

More
23 Oct 2023 00:30 #283551 by tommylight
Test at least 3 to 5 different speeds, write down the results, see if they change linearly or randomly, then you have 3 solutions:
-using "lincurve" component included with LinuxCNC, see docs
-adjust scaling if the result is linear change
-use offset if the result is linear after a certain point
--
Never used that type of BOB, so i wonder how linear is the 0-10V output.

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

More
23 Oct 2023 18:29 - 23 Oct 2023 18:42 #283631 by phew
Hi tommylight,

thank you, I've done some testing and drew a few graphs.

Note: I ran the tests using pwmgen.0.min-dc 0.24 which results in ~9000rpm on the VFD display.

vdc:



rpm:



curr-dc:



From scimming the LINCURVE page my understanding is that I just map the values to what I need them to be, like in this example .
Other than that, the generated vdc between ~S12000 and ~S22000 appears to be quite linear. I haven't dug too deep into pwmgen.N.offset yet but I assume it can be used to shift the pwm starting point to the left and right so that only the linear part is being projected?

Is one of these solutions to be favored and if so, why?
Attachments:
Last edit: 23 Oct 2023 18:42 by phew. Reason: fixed broken attachment tags

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

More
23 Oct 2023 22:02 #283640 by tommylight
Did you check what is the allowed minimum speed of the spindle motor?
Air cooled ones do not like to run under 8000RPM, unless they have forced air cooling provided by another fan.
Seems like "lincurve" will be best for your case, and yes it is that easy.
The following user(s) said Thank You: phew

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

More
23 Oct 2023 22:12 #283641 by phew
Yes, its an air cooled one. The minimum speed is 9000rpm.
Awesome, I will try it out as soon as I find some spare time.

Appreciate the help, thank you.
The following user(s) said Thank You: tommylight

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

More
31 Oct 2023 21:00 #284218 by phew
It took me almost two hours to figure out how set up lincurve correctly but now it is working as intended!

Thanks again!

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

Time to create page: 0.128 seconds
Powered by Kunena Forum