Unstable PWM motor control issue

More
14 Apr 2019 12:39 #130846 by F4br1c4t3D
Well after much messing about with scale and offset I finally got pwm spindle control working (to a degree) but now I face a new problem. Whilst the spindle speed matches (almost ~-50rpm) the commanded speed there's problems with the stability of the motor speed. There doesn't appear to be a particularly consistent pattern with the fluctuation but every so often the speed will audibly duck by 30 or so RPM then quickly recover. I don't think this is a feedback loop problem as I've not even set up closed loop properly yet (hardware is installed and signals are being received by LCNC but there's no PID loop set up yet.) so I don't think that's the issue.

Initially I thought that the pulsating speed could be as a result of a mechanical issue, but the motor behaves in the same way when completely unloaded. The motor is being controlled by an RC brushless ESC and I have also explored the possibility that the settings on the ESC could be causing the problem. It has a speed governor that attempts to stabilise the speed in response to load being applied but even with this feature off the problem persists. To further confirm that the ESC settings are not at fault here and that the motor system in general (power supply, controller, wiring etc.) are working as they should, I have run the motor from a simple RC servo tester and the speed fluctuations are not present. This narrows my problem down to the BOB, PC and my configuration in LCNC.

The BOB is your typical cheap Chinese 5 axis board with a built in relay. Not sure if it could be tainting the PWM as it passes it from the parallel port to the ESC? Everything else in the system (steppers, limit switches, encoders) seems to be operating without issue.

It seems as though the pulse train coming from the computer isn't consistent. I've no scope to test the signal that comes from the physical output on the BOB.I tried to look at the output in halscope which looked as you might expect like a short square pulse at regular intervals. It's supposed to be a 50Hz pulse varying between 1-2ms or 5-10% duty cycle which it looked like (to my novice eye at least). It did seem to be moving from left to right (drifting?) but that could just be because of how I had the scope configured (not 100% sure how it operates in honesty). This is the same signal the servo tester outputs so I'd expect it to act the same.

To Illustrate the problem, here's some terrible videos. One of the motor being controlled by LinuxCNC and the other by the servo tester:





As you can see the servo tester gives a nice consistent speed (aside from my knob twiddling) but the computer control is wobbly, for want of a better word. Interestingly when I issue M5 the motor doesn't stop immediately but seems to hold at a random speed for a few seconds before stopping, sometimes it speeds up a fair bit, but the pitch of the motor sound a lot more static in these few seconds. You can just about hear this happening over the sound of the power supply fan in the first video.

Any clues as to what could be causing my issue here?

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

More
14 Apr 2019 14:00 #130850 by PCW
The speed variation is likely a consequence of the low resolution PWM possible with software.

You might check if dither-pwm is true

If you have a 40 KHz base thread for example, you only have 40 distinct PWM values
possible between 1 and 2 ms, and if you set a PWM value between any of these distinct values, (and dither-pwm is true) the PWM generator will oscillate between the 2 bounding values (so the average PWM value is correct)

As for the odd behavior on spindle off, this is possibly because your hal file turns off the PWM at spindle off instead of setting 0 speed
The following user(s) said Thank You: F4br1c4t3D

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

More
14 Apr 2019 14:01 #130851 by pl7i92
you may consider going with a homemade pwm to 0-10V
for a reeal good signal quality
like in the PDF

i can give you the eagle files as well
i use them alot

This browser does not support PDFs. Please download the PDF to view it: Download PDF

Attachments:
The following user(s) said Thank You: F4br1c4t3D

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

More
14 Apr 2019 14:32 #130852 by F4br1c4t3D
I had tried switching dither off but the problem seems to persist Could be that I edited the wrong hal though. one is actual config and the other for quickly editing and testing without having to go through lengthy homing procedure triggering actual switches etc. I'll double check this and test again to see if it removes the wobble.

I take it turning off dither would remove the speed wobbles but I'd be left with a less than favourable speed resolution moving in increments of 62,5rpm (2500 /40) assuming my base thread frequency is 40KHz.

Assuming this is the case what are my options to move the PWM generation to hardware? How critical is a good speed resolution for threading and constant surface speed? I'm guessing 60rpm increments won't cut it? (no pun intended)

"As for the odd behavior on spindle off, this is possibly because your hal file turns off the PWM at spindle off instead of setting 0 speed"

How can I adjust my hal so that the PWM runs constantly rather than being switched on and off by M3/M5?

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

More
14 Apr 2019 14:39 #130853 by F4br1c4t3D
I don't think this circuit will be useful for me. My motor controller expects a PWM signal not an analog 0-10V signal. My BOB already has the facility to send the 0-10v signal but there's no way to interface this with my controller, unless I can somehow hack the servo tester to be controlled by it instead of the pot?

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

More
14 Apr 2019 14:41 #130854 by PCW
1. I doubt that a 60 RPM speed dither would have any real effect on threading since the Z motion is "geared" to the spindle

2. For PWM to run constantly, you would need to disconnect PWM enable in the hal file from from spindle-on, Not sure if M5 sets motions spindle speed to 0 but if not you would have to switch the PWMgens spindle speed to 0 when spindle-on is false
The following user(s) said Thank You: F4br1c4t3D

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

More
14 Apr 2019 15:10 #130855 by F4br1c4t3D
OK. Thanks, PCW. If I can get a steady speed and still achieve reasonable finish and decent threading, I'll be happy. I'll try shutting dither off and see if the wobble goes away.

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

More
14 Apr 2019 17:13 #130857 by F4br1c4t3D
Well I went to check the hal and I had already set dither to false. The wobble persists. Beginning to suspect the BOB causing problems.

Clutching at straws now but I guess I could try a different output pin on the BOB. Not holding out much hope there though.

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

More
14 Apr 2019 17:21 - 14 Apr 2019 17:21 #130858 by jmelson
OK, so this is a closed-loop speed control? You are using the software encoder component to give spindle speed, and then feeding it to a PID component to compute the right PWM? So, what you need to do is show the VELOCITY coming out of the encoder in Halscope, and see if it is very jumpy. I suspect it will be. Generally, spindle encoders have low resolution, and then they are sampled in time. This causes the detected velocity to be very noisy. If you are not using time-stamped velocity estimation, it will be even worse.

In any case, it may help greatly to run the encoder velocity through a lowpass filter to remove the fluctuations.

I have a "real" encoder on my Bridgeport, it is a pair of magnetic sensors on the spindle gear fed to a hardware encoder counter, and it was still giving very jumpy velocity until I put in a filter.

Jon
Last edit: 14 Apr 2019 17:21 by jmelson.
The following user(s) said Thank You: F4br1c4t3D

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

More
14 Apr 2019 18:44 #130865 by F4br1c4t3D
Hi Jon,

It will be closed loop, as in, the hardware is installed. But this is just running without any feedback whatsoever I have a quadrature encoder for spindle index and a slot sensor and slotted disk on the spindle shaft reading the index pulse. All of this is out of the equation at the moment since I've removed the timing belt from the motor to eliminate the mechanical side of things whilst troubleshooting.

This is just driving the motor with a PWM signal and no feedback. I'll bear your advice in mind when I'm getting my closed loop configured though. Thanks.

Moving the PWM output to a different pin made no change. Unsurprisingly.

I'm at a loss.

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

Time to create page: 0.104 seconds
Powered by Kunena Forum