Author Topic: Brushed DC motor closed loop speed control  (Read 4247 times)

0 Members and 2 Guests are viewing this topic.

Offline MartinnTopic starter

  • Frequent Contributor
  • **
  • Posts: 316
  • Country: ch
Re: Brushed DC motor closed loop speed control
« Reply #25 on: June 12, 2024, 06:39:48 pm »
A quick try: Looks great so far, FET overheats of course, will need to find heatsink.
Out of time for today, will try tomorrow.
EDIT:
Have a 2N3055 on a heatsink still lying around. Maybe try to make a darlington out of that and replace the FET.
« Last Edit: June 12, 2024, 06:50:08 pm by Martinn »
 

Online Picuino

  • Super Contributor
  • ***
  • Posts: 1018
  • Country: es
    • Picuino web
Re: Brushed DC motor closed loop speed control
« Reply #26 on: June 12, 2024, 07:01:03 pm »
At low speeds you can decrease the power supply voltage to 12V, reducing the heat.
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3552
  • Country: nl
Re: Brushed DC motor closed loop speed control
« Reply #27 on: June 12, 2024, 11:51:52 pm »
I was a bit bored, and I took this opportunity to be a bit silly.

First I took your schematic, imported it in KiCad put resistors & capacitors and such on it. and the result looks like:



Then I did the same with the PCB, which looks like:



I have not verified it completely, partially because I can't see all tracks on the PCB, but it looks like your reverse engineering effort was quite right. I've also attached the whole KiCad project. In the PCB editor, images can be turned off, to "clean up" the view of the PCB. As far as I know you can't do that in the schematic, but you can of course delete the old imported hand drawn image.

Do note it's not "complete" (nor verified) I have not added the speed poteniometer, I only just now saw that is only on the "other" schematic.

* 2024-06-13_Motor_ZZQ161121.zip
« Last Edit: June 12, 2024, 11:54:16 pm by Doctorandus_P »
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3552
  • Country: nl
Re: Brushed DC motor closed loop speed control
« Reply #28 on: June 13, 2024, 12:12:22 am »
A quick try: Looks great so far, FET overheats of course, will need to find heatsink.

From the drawing in the picture. It looks like the posted schematic from Picuino.

If you use an P-channel FET instead of an N channel, and add the sawtooth (or triangle) generator as in the original schematic, heating of the FET is minimized. You will be back to a PWM circuit, but now with better feedback.
If you do this, then also add a freewheel diode over both the motor and the current shunt, so the current gets recirculated though the shunt when the PWM switch is "off".

With real speed measurement and PI(d) control you can get much better regulation, but if this is good enough, then it's good enough.  :P
 

Offline MartinnTopic starter

  • Frequent Contributor
  • **
  • Posts: 316
  • Country: ch
Re: Brushed DC motor closed loop speed control
« Reply #29 on: June 14, 2024, 04:27:05 pm »
OK, so I put the analog version together:
2289471-0
I also went into the workshop and made a "knob" for the motor so I can brake this by hand. Easy to make if you have a broach set for the keyway and a hydraulic press...
Performance is quite good, decent regulation also with slow rpm. However, there's a problem.
This screenshot shows the output of the current sense amplifier with the feedback removed (1k pot = open):

You can see that in this constant voltage mode there is significant current ripple. Probably due to cogging of the motor. When you close the loop, you amplify those pulses and feed them back into the drive voltage:
2289479-2
(same measurement point, current sense). As you decrease the 1k pot (increase current feedback), this gets worse to a point where the motor almost oscillates. Turning it down reduces the stiffness.
So although this works amazingly well, I think it is not a solution for milling feed speeds.

EDIT: Experimenting with embedding images. What do you think of embedding the full size or thumbnain scope plot? I gues the full size is hefty, on my 4k monitor probably OK, but smaller ones?
« Last Edit: June 14, 2024, 04:50:03 pm by Martinn »
 

Offline MartinnTopic starter

  • Frequent Contributor
  • **
  • Posts: 316
  • Country: ch
Re: Brushed DC motor closed loop speed control
« Reply #30 on: June 14, 2024, 04:30:24 pm »
I was a bit bored, and I took this opportunity to be a bit silly.
Wow! You have a serious capacity overflow! Can I contact you when I have a design that needs getting done?

I also thought about putting it in KiCad. But as I have the real thing, I'm not sure there is a point. For me a pencil sketch is sufficient.
 

Offline MartinnTopic starter

  • Frequent Contributor
  • **
  • Posts: 316
  • Country: ch
Re: Brushed DC motor closed loop speed control
« Reply #31 on: June 14, 2024, 04:47:10 pm »
The problem with the circuit you posted earlier is that the current sense resistor is only connected for a very short time at slow speeds.
Therefore you are not really sensing current, but current multiplied by duty cycle.
For it to work properly you have to place the resistor on the positive side of the supply or sense the peak current.
I also thought I could put a regular current sense amplifier inside the motor loop and feed that back into the circuit. But considering the heavy filtering they implemented (several seconds time constants), I doubt the final result would be worth the effort. My guess would be that they had problems with stability and noise and added so many farads that everything was quited down. So if you'd try to increase the control speed, probably all those issues pop up again.

With real speed measurement and PI(d) control you can get much better regulation, but if this is good enough, then it's good enough.  :P

Adding a high resolution feedback (magnet and rotaty encoder sensor) was my first thought also. However, with that much torque ripple, it's going to be difficult to maintain constant speed even then because the velocity control loop gain will vary accordingly. Funnily enough I just recently had the same problem on a customer project (small BLDC) where the torque ripple was leading to excessive set current fluctuations as the velocity PD controller tries to compensate. This is not the first time I see this issue, but for now I have gotton away by just having enough bandwidth. However, if you have the absolute rotor position, you could in theory observe the torque ripple from the current and compensate for that dynamically (using a lookup table), but I have not yet tried that.

Not sure what to do right now. Maybe I would need to try it on the mill - or try to put a stepper on there.


 

Online Picuino

  • Super Contributor
  • ***
  • Posts: 1018
  • Country: es
    • Picuino web
Re: Brushed DC motor closed loop speed control
« Reply #32 on: June 14, 2024, 06:17:51 pm »
As you decrease the 1k pot (increase current feedback), this gets worse to a point where the motor almost oscillates. Turning it down reduces the stiffness.
So although this works amazingly well, I think it is not a solution for milling feed speeds.

Note that the feedback potentiometer has only one ideal working point.
If you increase the feedback further, the motor will accelerate as you brake it (it will not run at constant speed and may eventually oscillate).
If you reduce the feedback, the motor will slow down as you brake it (and will not run at constant speed).

I don't see a problem with oscillation. If you prefer it not to be there, you can try adding a small capacitor (around 1uF) in parallel to the 100k resistor of the op amp, but it will detract from the speed of the control loop.
 

Online Picuino

  • Super Contributor
  • ***
  • Posts: 1018
  • Country: es
    • Picuino web
Re: Brushed DC motor closed loop speed control
« Reply #33 on: June 14, 2024, 06:34:40 pm »
If you try to turn the motor with your hand without power supply, you can see the motor have different torque at different positions. This is the ripple that the control try to compensate at low speed.
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3552
  • Country: nl
Re: Brushed DC motor closed loop speed control
« Reply #34 on: June 15, 2024, 01:33:39 am »
For the KiCad thing...
I'm not very organized, but things like this happen sometimes when enough planets get aligned.
It was a part of KiCad I do not use much, combined with making a bit of a case of what you can do with KiCad.
It's a bit of a shame this motor controller is not much good and not really worth replicating. Maybe someone can use it as a base to make a better motor controller...

You got an easily measurable torque ripple on your scope. My guess is that it's not cogging torque as Picuino seems to suggest, but the commutator switching between one and two motor windings, which changes the included magnetic field in the rotor. If so, then the number of pulses per revolution should be twice as big as the number of contacts on your commutator.

If you take this signal, and also it's filtered average, and put it through a comparator, it looks like a very good speed feedback signal, and can be the basis for a PI(d) regulator, either digital or with a few opamps.

I'm guessing there is not so much speed ripple nor torque ripple, but it's just a motor artifact, and it's frequency is a lot higher then the response time of the motor. But attempting to use it as a feedback signal could unleash some dragons that are hard to tame.

Not sure what to do right now. Maybe I would need to try it on the mill - or try to put a stepper on there.

You can have a look in how many changes you need to your original PCB to fully include the shunt resistor in the motor current recirculation path (Inside the freewheel diode). Leave the sawtooth generator so you still use PWM instead of linear control and swap the N-channel FET for a P-channel FET. (Beware of maximum gate voltage) Because the FET inverts, you may have to swap opamp inputs too.

With these changes your motor controller may react a lot better then it does now, and it's probably "good enough". It also is not much work, so seems worth a try. Especially because you won't have to fiddle with mounting of the motor etc.

The trouble with stepper motors is they have relatively low torque. a Long (112mm) Nema23 sized motor with controller costs around EUR80. Closed loop steppers run a lot quieter and cooler and have a higher peak torque then open loop controllers, and you buy them as a set, with no need for tuning as with servo motors. Price difference between open and closed loop steppers is so small that I wonder why open loop steppers are still being made and sold (Probably only bought by people who don't know how big the difference in usability is).
With a stepper motor, I don't know if you would need an extra transmission to get enough torque. You can buy steppers with bolted on gearbox for a reasonable price, and Nema34 sized motor is also cheaper then what you paid now for your auto-feed.  Maybe it's worth considering to sell the box you have now unmodified, and build something new based on a stepper motor.
 

Offline MartinnTopic starter

  • Frequent Contributor
  • **
  • Posts: 316
  • Country: ch
Re: Brushed DC motor closed loop speed control
« Reply #35 on: June 15, 2024, 08:44:33 am »
Did some more measurements.
Lowest reasonable feeds for a milling machine are in the order of 5-10 mm/min. Given a 4 mm leadscrew pitch that results in about 2.5 rpm (about 1% of the max 240 rpm at the output of the gearbox).
With the current setup I can get down to about 16 rpm, which is the lowest value that is reasonably stable. This gives 64 mm/min, which is well above of what I'd like to see (around 10 mm/min). BTW I added lowpass filtering in the current path, which gets rid of the oscillations.
I think it's time to call it a day. While the linear approach with optimized I*R compensation does give a significiant improvement, I don't think it is worth the effort putting it onto the machine. There's still a 7 V dropout at full speed (24 V supply is fixed), which I'd solve probably by adding a switch FET in parallel, kicking in at high speed settings. No speed control is necessary at max feed, just give the motor the full 24 V. Or maybe replace the N channel linear FET with a BJT darlington, reducing the dropout somewhat.

Regarding stepper motors: Currently I am eyeballing a NEMA 24 closed loop motor, like
https://www.omc-stepperonline.com/closed-loop-stepper-motor?mfp=184-frame-size-mm[Nema%2024%20(60%20x%2060)]
which might have enough torque to drive the spindle directly.

 

Offline fourtytwo42

  • Super Contributor
  • ***
  • Posts: 1194
  • Country: gb
  • Interested in all things green/ECO NOT political
Re: Brushed DC motor closed loop speed control
« Reply #36 on: June 15, 2024, 02:25:25 pm »
It's a shame to give up but I know the feeling!

Here is a scope shot of the back emf of a small motor during the PWM off time, a high side switch is used to make the emf ground referenced for simplicity.
A recovery time is required after the PWM switches off to allow the field to collapse and you can see that where the emf is negative.
I used an MPU both to generate the PWM, measure the emf & do the control loop, I think that kind of control would be hard in pure analogue.

That's a very nice 14? pole motor, I was working with just 5 poles although your target speed of just 19rpm (~4 poles/sec) sounds a bit hard if I am reading it right ?
Current is proportional to torque, back emf is a much better indicator of velocity, so if you want constant speed back emf is the way to go if you have an MPU to hand  :)

On steppers I did a fairly large (14") telescope drive with them unfortunately the gearbox & motor size was pre-ordained and I had terrible trouble reaching the maximum speed required in the slew even using velocity profiles without misstepping, absolute position accuracy was required without feedback  :palm: I wished I had a servo motor with optical feedback for the job  ;)

My final radical suggestion for you is get a motor with twice the reduction ratio and drive it with twice the voltage during the slew (which I assume is short duration and low duty cycle)  :wtf:
« Last Edit: June 15, 2024, 02:52:20 pm by fourtytwo42 »
 

Offline IanB

  • Super Contributor
  • ***
  • Posts: 12015
  • Country: us
Re: Brushed DC motor closed loop speed control
« Reply #37 on: June 15, 2024, 03:01:38 pm »
Lowest reasonable feeds for a milling machine are in the order of 5-10 mm/min. Given a 4 mm leadscrew pitch that results in about 2.5 rpm (about 1% of the max 240 rpm at the output of the gearbox).

At the other end of the scale, is 1000 mm/min a reasonable feed rate? Maybe some mechanical gearing would be appropriate to match the motor speed to the desired range of feed rates?

 

Online Picuino

  • Super Contributor
  • ***
  • Posts: 1018
  • Country: es
    • Picuino web
Re: Brushed DC motor closed loop speed control
« Reply #38 on: June 15, 2024, 03:13:41 pm »
Maintaining a speed of 1% of nominal speed should not be too much difficult.
I don't understand why the control you tested doesn't work well.
Of course the analog version dissipates too much heat, but it should serve as a proof of concept to keep the motor running at 1% of nominal speed with no variation under load.

EDIT:
You can tune the feedback (1k pot) by checking with the scope that the ripple current of the feedback loop maintains a constant frequency despite braking the motor.

I am setting up a version of the digital control loop. I want to see for myself the results with this type of control.
I just need to solder and connect the differential amplifier MCP6N11-10 to sense the current.
« Last Edit: June 15, 2024, 10:21:01 pm by Picuino »
 

Online Picuino

  • Super Contributor
  • ***
  • Posts: 1018
  • Country: es
    • Picuino web
Re: Brushed DC motor closed loop speed control
« Reply #39 on: June 15, 2024, 06:50:26 pm »
I already have the PCB with correction included (a ground wire was missing in the previous version).


EDIT:
I change the PWM output to D10, associated to Timer1 which has higher resolution.
« Last Edit: June 16, 2024, 11:01:12 am by Picuino »
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3552
  • Country: nl
Re: Brushed DC motor closed loop speed control
« Reply #40 on: June 15, 2024, 10:02:29 pm »
I'd say that 64mm/min is slow enough. It's similar to this video:



You've already got the power feed, your speed controller is simple to finish with this electronic improvement, and unless you want to sell it (and build a new one) there is not much reason to simply bolt it to your machine and start using it. This gives you some real life experience, which gives you a better feeling of what you really need. You can always revisit the project later when you find an improvement is needed.

Also, if you build something with a stepper motor, I suggest you put in some gears or a timing belt transmission, even if you want to start with a 1:1 transmission ratio.
First, it gives you more room for motor placement, and you can keep the handwheel in place. Second, If you already got a transmission, it's easy to adjust if you decide later you want more speed or more torque.

 

Online Picuino

  • Super Contributor
  • ***
  • Posts: 1018
  • Country: es
    • Picuino web
Re: Brushed DC motor closed loop speed control
« Reply #41 on: June 16, 2024, 11:07:48 am »
Testing the board.
Switching ON takes approximately 200ns to 300ns. Sufficient.

Switching OFF is much worse and takes about 6us. This is due to how long it takes the NPN to switch after being saturated and how long it takes the mosfet to switch off with a simple 1000 Ohm resistor.
I will have to be careful to use a low switching frequency so that the transistor does not get too hot.
 

Offline MartinnTopic starter

  • Frequent Contributor
  • **
  • Posts: 316
  • Country: ch
Re: Brushed DC motor closed loop speed control
« Reply #42 on: June 16, 2024, 04:46:06 pm »
I'd say that 64mm/min is slow enough. It's similar to this video:
I have not been able to find out what the leadscrew pitch of the SX3L is, might be 2 mm instead of the 4 mm of my SX4. The feed shown in the video is OK for a roughing cut, but for a finishing cut with a flycutter one would definitely go slower. Normally on a hobby mill you don't want to push it; better take it easy than to break the cutter and ruin the part.

At the other end of the scale, is 1000 mm/min a reasonable feed rate? Maybe some mechanical gearing would be appropriate to match the motor speed to the desired range of feed rates?
Max feed while milling is mostly not relevant (we are not doing HSC here, although Stefan suggests a HSC like strategy for manual milling also )
It's more about moving the table quickly. The SX4 has 450 mm X travel, at the 240 rpm of the powerfeed, this gives 960 mm/min, so it takes roughly half a minute to traverse the table fully. I would not mind it to be faster, but with powerfeeds there is always a chance of crashing into things, milling or not.

You've already got the power feed, your speed controller is simple to finish with this electronic improvement, and unless you want to sell it (and build a new one) there is not much reason to simply bolt it to your machine and start using it.
I would sell it right away. But the SX4 is relatively rare, so the probability of finding someone who pays a decent price (after possibly reading our thread) is near zero. At least it has a halfway decent clutch mechanism for the feed unit, that I can reuse even if I switch to a stepper.

Regarding the improved circuit by Picuino: I have it on the breadboard only. For actually using it, I'd have to do something about the 7 V dropout, make a halfway decent PCB, find a heatsink that fits and put it all together.
It would be definitely an improvement over the current unit, but I don't see a sufficient effort vs. reward.

BTW when I said 16 rpm that is the output after the 1:7.5 gearbox. At the motor this would be 120 rpm, 7% of its rated speed.

Regarding stepper and direct drive: Given the available choices of stepper motors, I don't think it is necessary to add a belt transmission. The DC motor nameplate says 0.186 Nm which is 1.4 Nm after the gearbox. I measured the torque you need to break the axis loose at about 1.2 Nm. Given the stiffness of this (still as far as mills go) rather lightweight milling machine, not much more will be necessary for milling.
NEMA24 closed loop steppers https://www.omc-stepperonline.com/closed-loop-stepper-motor?mfp=184-frame-size-mm[Nema%2024%20(60%20x%2060)] should do that, although not with a huge margin. I'd start with one of those (fortunately, the x leadscrew axis is 58 mm below the table surface, so there is plenty of room for a NEMA24 motor (30 mm from axis to housing).

It's a shame to give up but I know the feeling!
I'm not giving up. If this would be a paid customer project, the I'd happily invest in more advanced control strategies, count commutation pulses and put all into some STM32 project.
But as all I want now is get the mill going, I try to assess which option gives me the best return for my invested spare time. And as I am already considering putting a stepper motor on the Z axis (it is currently a reversible 20 rpm 60 W geared AC induction motor), which would mean I would already have 90% of the necessary infrastructure (power supply, housing, pulse generator), thinking of a stepper for X seems a more powerful option. It will enable arbitrarily low feeds together with much faster (dangerous!) jog feeds.

But hey, @Doctorandus_P, as you seem to have abundant free time - if you come up with a design I can order as assembled PCB from JLCPCB (I can help with selecting the components, if you find that boring), I'll order it and see how it works on my machine!
 

Offline H.O

  • Frequent Contributor
  • **
  • Posts: 835
  • Country: se
Re: Brushed DC motor closed loop speed control
« Reply #43 on: June 16, 2024, 05:53:56 pm »
I have a couple of Advanced Motion Control 30A8 servo drives (datasheet link) collecting dust.
Among the different operating modes are IxR which is what you've been trying here. For fine velocity control nothing will beat tachometer or high resolution encoder feedback but a well tuned IxR loop should give you decent performance.

Cover the shipping cost and I'll send you one. Drop me a PM if interested.     
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3552
  • Country: nl
Re: Brushed DC motor closed loop speed control
« Reply #44 on: June 16, 2024, 09:27:45 pm »
I've reached about the limit of the time I want to spend on someone else's project.  :P

What you can do, is integrate your breadboard IR compensation into the the project I posted, maybe add a uC (encoder, PI, whatever) and order that.

But if you want to put a stepper on both X and Z axis, I'd say, also put one on the Y-axis and you're pretty close to CNC. GRBL is a simple DIY controller, and the GRBL forks have mostly merged together in the GRBLhal project. Smoothie board may also be an option, but it's been years since I last looked into that. LinuxCNC has more options, but is also more complex.
 

Online jbb

  • Super Contributor
  • ***
  • Posts: 1183
  • Country: nz
Re: Brushed DC motor closed loop speed control
« Reply #45 on: June 17, 2024, 12:36:55 am »
I think, you can improve the MOSFET turn off quite a bit by adding 3 more pieces as shown.

When drive transistor Q2 turns on, the MOSFET is turned on via D2 and R3.

When drive transistor Q2 turns off:
- D2 is reverse biased
- Q3 is switched on by R2
- MOSFET is turned off by Q3 and R8

This allows for a faster turn off.
 
 

Offline MartinnTopic starter

  • Frequent Contributor
  • **
  • Posts: 316
  • Country: ch
Re: Brushed DC motor closed loop speed control
« Reply #46 on: June 17, 2024, 10:11:36 am »
But if you want to put a stepper on both X and Z axis, I'd say, also put one on the Y-axis and you're pretty close to CNC.
That's an entirely different can of worms, more a barrel of worms actually. Certainly a multi year project given the spare time I have and not something I am looking for right now.
 

Online Picuino

  • Super Contributor
  • ***
  • Posts: 1018
  • Country: es
    • Picuino web
Re: Brushed DC motor closed loop speed control
« Reply #47 on: June 17, 2024, 11:05:32 am »
After some testing with the digital version of the PWM control with current compensation, although not yet optimized, the performance is not as good as I expected.
The motor oscillates at low rpm when I try to brake it.

I thought the result was going to be better because the results I got some time ago with the back-emf control were very good. In this case they are not.
The back-emf control is really very good, but the digital control with current compensation is not so good.


EDIT:
I am going to try to add back-emf control to the circuit I already have set up to see if I can make an accurate control at low speeds. In the other tests I did, I used an H-bridge for back-emf control. In this case I am going to use a simple p-mosfet for control in only one direction of rotation. I hope the control will improve.
« Last Edit: June 17, 2024, 11:09:19 am by Picuino »
 

Offline Doctorandus_P

  • Super Contributor
  • ***
  • Posts: 3552
  • Country: nl
Re: Brushed DC motor closed loop speed control
« Reply #48 on: June 17, 2024, 02:37:38 pm »
EDIT:
I am going to try to add back-emf control to the circuit I already have set up to see if I can make an accurate control at low speeds.

The IR compensation already has gain, so you probably have to reduce gain of back EMF loop. I'm not sure whether it makes sense to do both of these. You're adding complexity but without a big chance for significant improvements. Either of these systems work, but they have similar limitations. If you want "proper" speed control you will need better speed feedback in the form of for example an encoder.

On top of that, results will be dependent on the exact motor used. It's not clear to me how these experiments from Picuino are helping Martinn.
 

Online Picuino

  • Super Contributor
  • ***
  • Posts: 1018
  • Country: es
    • Picuino web
Re: Brushed DC motor closed loop speed control
« Reply #49 on: June 21, 2024, 03:31:32 pm »
I have changed the schematic and soldered on the PCB two resistors to measure the back-EMF.

I have also added a capacitor to the base of the NPN transistor with the intention of accelerating its turn-off (I couldn't do much more in the little space I have left on the PCB).

Now it's time to make the program and test if the back-EMF control is good enough.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf