Brushed DC motor closed loop speed control - Page 1
Forum section: electronics / projects

author: Martinn
author_rank: Frequent Contributor
timestamp: June 09, 2024, 05:11:27 pm
content: Hi all,I just bought a powerfeed unit for my millhttps://www.paulimot.de/Maschinen/Maschinenzubehoer/Vorschubmotoren/1121/Vorschubmotor-X-Achse-fuer-SIEG-SX4which it not really fantastic. Slowest feeds are too fast for milling and speed stability is poor - not sure if it has feedback at all. So I'm thinking of adding a closed loop speed controller (or simply replace the motor with a stepper, but this is not what I'd like to discuss here). The motor is a 24 V brushed DC with 1800 rpm and 1:7.5 reduction gear. No encoder or feedback. The original electronics does some PWM and overload limiting, see PCB photo (LM324, power transistor IRF540. I work on motion and motor control professionally, I just never came across a brushed motor, so I'm asking here if someone has experience with controlling brushed DC motors.Specifically, I am wondering if closed loop speed control with decent stiffness can be achieved down to a few rpm. This is critical, as it defines the chip load of a milling cutter. Faster speeds (up to 1800 rpm) are for moving the table only and are not critical.As the motor is now, the only option to get feedback from it would be via back EMF sensing. Not sure how well this would work with the brushes. I guess I would not bother with it.I think that without a decent encoder, stable low speed performance will be difficult to achieve. Simplest method I could think of would be to add a magnet at the end of the shaft (drill threaded hole in shaft) and put a AS5047 on axis. I have used this sensor for other control projects and it is great when you need high resolution, but only moderate accuracy. Ideal for speed estimation. System options would be going for an STM32 (cascaded PI current and PI velocity control loops), finding a controller chip (Trinamic has some nice ones) or maybe even improving the existing analog control.Not sure if I am trying to beat a dead horse here.(and an expensive one at € 383 btw)Has anyone experience with decent quality (stiffness/dynamic range) control of small brushed DC motors?Thanks, Martin

author: IanB
author_rank: Super Contributor
timestamp: June 09, 2024, 05:46:49 pm
content: No direct experience, but I think speed regulation of brushed DC motors is best done with PWM.To control the speed, I think you would need an encoder on the output shaft and a feedback loop to adjust the PWM duty cycle.My guess is you would have to experiment and see what you can achieve.

author: fourtytwo42
author_rank: Super Contributor
timestamp: June 09, 2024, 07:15:54 pm
content: There are three sensorless methods I have used,One is a current compensated constant voltage, that is the voltage increases by a small amount with increasing current to compensate for Rm.Another is to AC couple and low pass filter the commutation voltage and count the frequency.And finally I have tried PWM sampling the back emf during switch off time.All of course are not as good as a mechanical sensor.I am guessing that pcb only implements constant voltage OTH the heatsink is quite small so maybe it's a PWM output but with no feedback.

author: Zero999
author_rank: Super Contributor
timestamp: June 09, 2024, 07:34:59 pm
content: It's not something I've done before.How precise does it need to be?If precision is important, then how about a PLL controller?https://www.ti.com/lit/an/slua085/slua085.pdf

author: Martinn
author_rank: Frequent Contributor
timestamp: June 09, 2024, 07:36:38 pm
content: Quote from: fourtytwo42 on June 09, 2024, 07:15:54 pmGreat idea! Did that work? Probably pretty messy I'd think?Quote from: fourtytwo42 on June 09, 2024, 07:15:54 pmThat would be the straightforward way, I wonder how well that works with the commutation noise?Quote from: fourtytwo42 on June 09, 2024, 07:15:54 pmYes, it's PWM, you can hear it (few hundred Hz).So how was your success rate with those methods?

author: Martinn
author_rank: Frequent Contributor
timestamp: June 09, 2024, 07:42:42 pm
content: Quote from: Zero999 on June 09, 2024, 07:34:59 pmIt does not need to be precise. Setpoint is from a simple pot anyway. Maybe +-20% at low RPM would be totally fine.I'm more concerned about practical issues. How well can you get current control to work with the switching of the brushes? After all it's massively varying impedance and resistance.Also, stick-slip or generally friction from the commutator could be nasty.If it would be a brushless motor, we'd be back in well established practise. Adding an encoder would make even position control straightforward. Sensorless operation is more difficult, but also possible (probably not for a few rpm).It's the brushed motor thing that makes me wonder.

author: amyk
author_rank: Super Contributor
timestamp: June 09, 2024, 08:02:06 pm
content: Look at treadmill motor controllers. They're much higher voltage than your application but they use brushed DC motors too.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 09, 2024, 11:05:56 pm
content: Brushed motors can be quite easily controlled to about 10% of their max PWM, and with some proper tuning to 3% of their maximum RPM or even lower, but there are a bunch of limitations.First the control algorithm has to be quicker then the time constant of the motor, and you will need a reasonable resolution encoder to get enough speed resolution quick enough at low RPM.Slip-stick is a bit of a problem, but as long as the motor is moving, static friction and motor load are also important factors. I have made a controller for a heavy movie screen and when unrolling it I had to use different PI parameters then for rolling it up.Your commutator does not have many contacts. This will result in some torque ripple, and this will also degrade the controlability of the motor a bit.If you can manage to add a flywheel to the motor to increase it's inertia, it's also easier to control at lower speed.Motor torque is determined by motor current. For short periods you can overload DC motors significantly (2x nominal torque is quite normal) but you can't increase torque as with mechanical transmissions.But overall, with feedback, you can get much better control over your motor, and it is not very difficult to do. You just need some microcontroller FET + FET driver, and the feedback electronics (Hall sensor + magnet). It's a doable project and quite a fun to get to know PID loops and how to do them in software. But it probably will cost you days or weeks of your free time the first time you do it. if that is OK with you, then go for it.PWM frequency does not matter much. At low RPM, a low PWM frequency (few hundred Hz) is even advantageous. You have to put some effort in the FET driver, because the FET has to switch quick enough. If you connect it directly to a pin of your microcontroller (often used for DC loads) It will not switch quick enough and will overheat because of the many switching cycles of PWM control.

author: schmitt trigger
author_rank: Super Contributor
timestamp: June 09, 2024, 11:36:08 pm
content: If you would like to use the back-emf method, just be aware that some motors spark a lot (read: create a lot of noise), more so under load.As others have mentioned, the voltage sample should be taken during the PWM’s off time. Even so, the voltage won’t be a straight line but a wobbly one. Most likely you may have to add analog filtering and/or software averaging.

author: fourtytwo42
author_rank: Super Contributor
timestamp: June 10, 2024, 09:57:30 am
content: Quote from: Martinn on June 09, 2024, 07:36:38 pmThe problem is the commutation spikes are similar to brush noise and in my case (model railway) noise from the rolling wheel contact so I would rate it the least successful method.Quote from: Martinn on June 09, 2024, 07:36:38 pmThe commutation noise is easy to remove as it is impulse in nature, the two problems are settling time after turning off the mosfet and ripple that needs removing by a sliding average or similar filter. This was the most successful method, implemented in a small micro-controller.Quote from: Martinn on June 09, 2024, 07:36:38 pmSo equivalent to constant voltage with no feedbackI never got the Rm compensation method to work stably, it would either not work (motor slowed with increasing load) or go nut's (immediately go to maximum rpm), possibly with additional filtering and hours of tinkering it might work but I prefer something more repeatable. I believe it has been used for some audio turntables but they have a heavy flywheel and almost constant load.

author: Picuino
author_rank: Super Contributor
timestamp: June 10, 2024, 11:13:04 am
content: The method of measuring EMF voltage works surprisingly well at low revolutions. It is able to keep the motor stopped or at very low speed even though you try to turn it in both directions. The problem is that it is complex to implement.Switching sensing is also difficult to achieve.If you don't want very high accuracy, supply current compensation is the simplest thing to implement and good enough. You can even get the motor to speed up a bit when you try to brake it, it depends on the setting you make.

author: Picuino
author_rank: Super Contributor
timestamp: June 10, 2024, 11:21:26 am
content: If you decide to control it with back EMF, you can take a look at how some brushless motor controllers do it.A normal control with a single transistor and a freewheel diode is not enough, because it takes a long time to reduce the current through the diode. The ideal is an H-bridge, which can be connected so that the current is reduced quickly and then the back-emf measurement can be made. This ensures that the motor will be without power for as little time as possible.

author: Martinn
author_rank: Frequent Contributor
timestamp: June 10, 2024, 05:21:53 pm
content: Thanks a lot for the very interesting answers! (I love motor control).Regarding commutation peaks sensing, I found a few interesting references:https://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ApplicationNotes/ApplicationNotes/Sensorless-Position-Control-of-Brushed-DC-Motor-Using-Ripple-Counting-Technique-00003049A.pdfhttps://www.ti.com/lit/ta/sszt984/sszt984.pdfhttps://www.ti.com/tool/TIDA-01421reference design including schematicSensorless position feedback appears to be interesting for automotive, like memorizing seat positions. But it's also quite tricky to get to work, it seems.And while I really enjoy designing around motors, I typically work with BLDC/FOC and this is just a personal side project. And truth be told I mainly want this powerfeed to work - not make a half year project out of it (although it sounds fun). Main problem with collector pulse counting could be the large dynamic range, 1 - 1800 rpm would be a nice target.With luck there are geared steppers that might just fit:https://www.omc-stepperonline.com/nema-23-stepper-motor-bipolar-l-76mm-w-gear-ratio-10-1-spur-gearbox-23hs30-2804s-sg10On top, they also make a controllerhttps://www.omc-stepperonline.com/integrated-stepper-motor-controller-1-5-4a-12-40vdc-for-nema-17-23-24-stepper-motor-isc04which can directly be controlled via a potentiometer, so I wouldn't have to design a pulse generator.

author: Picuino
author_rank: Super Contributor
timestamp: June 10, 2024, 05:33:37 pm
content: I think it's better to keep the DC motor. It's going to have more torque throughout the speed range and it's going to be more powerful for the same size.Plus you don't need precise control of POSITION, just SPEED, which is much simpler and can be easily achieved with a DC motor with supply current compensation.

author: Picuino
author_rank: Super Contributor
timestamp: June 10, 2024, 05:43:39 pm
content: That motor has approximately 3.7 ohms of armature resistance (you can measure it with a multimeter and tell us if this is the case).Therefore, you only have to add 3.7 volts in the power supply for each ampere consumed, and the motor will run at constant speed.

author: Martinn
author_rank: Frequent Contributor
timestamp: June 10, 2024, 07:06:40 pm
content: Quote from: Picuino on June 10, 2024, 05:43:39 pmMultimeter says 4.3 ohms.But would you think that you can reliably run the motor at say 10 rpm? It is rated at 1800 rpm at 24 V, which would give 130 mV @ 10 rpm. I doubt you can control the voltage precisely enough to get that dynamic range.What dynamic range do you think is realistic for a brushed motor? I am only aware of this for capstan drives on tape decks (or maybe turntables), which are constant speed.You are right that with a stepper it is more difficult to retain high speed at high rpm. To some degree one can counter that with a low inductance motor and a high supply voltage. Ideally I'd keep the existing 24 V supply though. The geared motor I linked earlier probably won't be able to achieve the necessary speed (like 300 rpm), more likely it would be direct drive with a NEMA24 like thishttps://www.omc-stepperonline.com/s-series-nema-24-bipolar-1-8deg-4-2nm-594-77oz-in-4-2a-60x60x100mm-4-wires-24hs40-4204sMain advantage of a stepper would be that it is relatively easy to achieve arbitrarily slow speeds. With my last mill powerfeedhttps://forum.zerspanungsbude.net/viewtopic.php?t=50489#p607066i settled for a speed resolution of 0.01 mm/s, which required a 64 bit position accumulator in the step generation, but was otherwise straightforward. The total effort I put in this design was however gigantic, and this time I am aiming for something simpler.

author: Picuino
author_rank: Super Contributor
timestamp: June 10, 2024, 07:29:49 pm
content: I don't know the limits of current compensated control, but properly adjusted it can achieve relatively slow constant speeds. In reality the motor will be supplied with higher voltage than 0.13V, because the voltage will increase with the supply current. You can test it with a simple analog control.According to my tests, the back-emf control can indeed achieve those speeds without problem (from 10 rpm, one revolution every 6 seconds, up to 1800 rpm).

author: Picuino
author_rank: Super Contributor
timestamp: June 10, 2024, 07:52:09 pm
content: You can try this.EDIT:10k Pot = Speed control1k Pot = Current feedback controlQuote from: Martinn on June 10, 2024, 07:06:40 pmIs the resistance of the cables already subtracted?

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 10, 2024, 08:40:29 pm
content: Quote from: Picuino on June 10, 2024, 07:52:09 pmI am guessing something similar is already implemented.There are a few power resistors near the FET and diode. LM434 has 4 opamps and I see two adjustment pots.Maybe you can improve it by changing the pots, but start with some reverse engineering to figure out what the potentiometer do.

author: Zero999
author_rank: Super Contributor
timestamp: June 11, 2024, 07:54:53 am
content: Quote from: Picuino on June 10, 2024, 07:52:09 pmUsing an N-channel source follower like that will require a 5V or more higher voltage power supply to the op-amp, than the motor. It also appears to be a linear controller, which will dissipate a lot of power.

author: Picuino
author_rank: Super Contributor
timestamp: June 11, 2024, 08:56:26 am
content: Digital version.

author: Martinn
author_rank: Frequent Contributor
timestamp: June 12, 2024, 04:52:25 pm
content: Quote from: Doctorandus_P on June 10, 2024, 08:40:29 pmHere we go.A bit messy, not sure if 100% accurate, but the overall principle is clear.Opamp 3 is a triangle generator, 420 Hz.OP 1 is a comparator, generating a PWM based on the velocity pot.Power FET has a 82 mR shunt for current sensing.OP2 compares the current sense value and triggers the SCR, which displays "overload" and clamps the PWM setpoint to 0.The OFF switch also sets the PWM setpoint to 0 and resets the SCRAnd now it comes, Opamp 4 feeds the amplified current signal back to the PWM setpoint (via the 100 k resistor between output 4 and + input 1).If you hold the shaft (which is pretty difficult without mill attached to it), you can provoke a slight current rise.But the problem is the poor low speed performance. The motor starts to rotate at 5% PWM DC, but torque is pretty low and you can easily stall it by hand. PWM then rises with in a few seconds to 6% where you need a firmer grasp, but would still not advance the mill table. Only when you advance the speed knob further the motor turns with reasonable torque, but then it is far too fast for milling.Not sure if this can be tuned to acceptable performance. Obvious start would be the 100 k current compensating resistor, I'll try to reduce that and see how this goes. What worries me a bit is that this circuit is peppered with filter caps. Obviously they are fitghting PWM noise, but still it looks a bit excessive.EDIT changing this resistor did not help much...

author: Martinn
author_rank: Frequent Contributor
timestamp: June 12, 2024, 04:57:11 pm
content: Quote from: Picuino on June 10, 2024, 07:52:09 pmThanks! Looks interesting. I wonder if the opamp feedback (10k) could be from the motor instead of the FET gate? This way the opamp would remove the GS threshold.My parts bin should be sufficient to try this out...Resistance is with cables. But I would expect the motor resistance anyway to vary significantly depending on rotor position.

author: Picuino
author_rank: Super Contributor
timestamp: June 12, 2024, 05:15:13 pm
content: 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.That is the reason for using a P mosfet in the digital circuit with PWM that I posted earlier.EDIT:In addition, the sensed current should not be filtered too much, because then the control loop does not have enough speed to be able to respond to sudden current changes / motor torque changes.With a good control circuit, it should work much better.

author: Picuino
author_rank: Super Contributor
timestamp: June 12, 2024, 05:22:03 pm
content: Quote from: Martinn on June 12, 2024, 04:57:11 pmYes, it could work better.Anyway the FET resistance can be added to the motor resistance and compensated with the 1K potentiometer.

author: Martinn
author_rank: Frequent Contributor
timestamp: June 12, 2024, 06:39:48 pm
content: 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.

author: Picuino
author_rank: Super Contributor
timestamp: June 12, 2024, 07:01:03 pm
content: At low speeds you can decrease the power supply voltage to 12V, reducing the heat.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 12, 2024, 11:51:52 pm
content: 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

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 13, 2024, 12:12:22 am
content: Quote from: Martinn on June 12, 2024, 06:39:48 pmFrom 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.

author: Martinn
author_rank: Frequent Contributor
timestamp: June 14, 2024, 04:27:05 pm
content: OK, so I put the analog version together: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:(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?

author: Martinn
author_rank: Frequent Contributor
timestamp: June 14, 2024, 04:30:24 pm
content: Quote from: Doctorandus_P on June 12, 2024, 11:51:52 pmWow! 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.

author: Martinn
author_rank: Frequent Contributor
timestamp: June 14, 2024, 04:47:10 pm
content: Quote from: Picuino on June 12, 2024, 05:15:13 pmI 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.Quote from: Doctorandus_P on June 13, 2024, 12:12:22 amAdding 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.

author: Picuino
author_rank: Super Contributor
timestamp: June 14, 2024, 06:17:51 pm
content: Quote from: Martinn on June 14, 2024, 04:27:05 pmNote 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.

author: Picuino
author_rank: Super Contributor
timestamp: June 14, 2024, 06:34:40 pm
content: 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.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 15, 2024, 01:33:39 am
content: 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.Quote from: Martinn on June 14, 2024, 04:47:10 pmYou 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.

author: Martinn
author_rank: Frequent Contributor
timestamp: June 15, 2024, 08:44:33 am
content: 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, likehttps://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.

author: fourtytwo42
author_rank: Super Contributor
timestamp: June 15, 2024, 02:25:25 pm
content: 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 handOn 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 feedbackI wished I had a servo motor with optical feedback for the jobMy 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)

author: IanB
author_rank: Super Contributor
timestamp: June 15, 2024, 03:01:38 pm
content: Quote from: Martinn on June 15, 2024, 08:44:33 amAt 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?

author: Picuino
author_rank: Super Contributor
timestamp: June 15, 2024, 03:13:41 pm
content: 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.

author: Picuino
author_rank: Super Contributor
timestamp: June 15, 2024, 06:50:26 pm
content: 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.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 15, 2024, 10:02:29 pm
content: 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.

author: Picuino
author_rank: Super Contributor
timestamp: June 16, 2024, 11:07:48 am
content: 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.

author: Martinn
author_rank: Frequent Contributor
timestamp: June 16, 2024, 04:46:06 pm
content: Quote from: Doctorandus_P on June 15, 2024, 10:02:29 pmI 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.Quote from: IanB on June 15, 2024, 03:01:38 pmMax 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.Quote from: Doctorandus_P on June 15, 2024, 10:02:29 pmI 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 steppershttps://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).Quote from: fourtytwo42 on June 15, 2024, 02:25:25 pmI'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!

author: H.O
author_rank: Frequent Contributor
timestamp: June 16, 2024, 05:53:56 pm
content: 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 loopshouldgive you decent performance.Cover the shipping cost and I'll send you one. Drop me a PM if interested.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 16, 2024, 09:27:45 pm
content: I've reached about the limit of the time I want to spend on someone else's project.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.

author: jbb
author_rank: Super Contributor
timestamp: June 17, 2024, 12:36:55 am
content: 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 R8This allows for a faster turn off.

author: Martinn
author_rank: Frequent Contributor
timestamp: June 17, 2024, 10:11:36 am
content: Quote from: Doctorandus_P on June 16, 2024, 09:27:45 pmThat'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.

author: Picuino
author_rank: Super Contributor
timestamp: June 17, 2024, 11:05:32 am
content: 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.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 17, 2024, 02:37:38 pm
content: Quote from: Picuino on June 17, 2024, 11:05:32 amThe 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.

author: Picuino
author_rank: Super Contributor
timestamp: June 21, 2024, 03:31:32 pm
content: 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.

author: Picuino
author_rank: Super Contributor
timestamp: June 21, 2024, 03:41:06 pm
content: By now the switch-off of the mosfet has improved a lot. It has been reduced from 6us to 1.5us. It is still high, but it is not going to cause worrying heating of the mosfet.

author: Picuino
author_rank: Super Contributor
timestamp: June 22, 2024, 10:20:13 am
content: With the back-emf control the motor rotates precisely at the reference speed, even at speeds below 1% of the nominal speed.I post also the program used with Arduino (with PID control not well tuned).I am not using current measurement, nor do I need to.Code:const int PIN_PWM = 10;const int PIN_CURRENT = A0;const int PIN_EMF = A1;const int PWM_MAX = 2000;volatile int motor_speed;volatile int motor_voltage;volatile char timer1_compb;int emf;int error = 0;int error_old = 0;int PID_control = 0;int PID_proportional = 0;int PID_derivative = 0;int PID_integral = 0;int PID_kp = 100;int PID_kd = PID_kp / 2;int PID_ki = PID_kp / 2;void setup() {pinMode(PIN_PWM, OUTPUT);timer1_setup();}void loop() {motor_voltage = 100;motor_speed = 10;while(1) {delay(18);for(timer1_compb = 0; timer1_compb == 0;); // Wait for end of PWM pulseDDRB &= ~(1 << (PIN_PWM-8)); // Set PIN PWM as inputdelayMicroseconds(1500); // Wait disipate motor currentemf = analogRead(PIN_EMF); // Read back-emf voltage// PIDerror = motor_speed - emf;PID_proportional = PID_kp * error;PID_derivative = PID_kd * (error - error_old);PID_integral += PID_ki * error;if (PID_integral < -PWM_MAX)PID_integral = -PWM_MAX;if (PID_integral > PWM_MAX*16)PID_integral = PWM_MAX*16;motor_voltage = (PID_proportional + PID_integral + PID_derivative)/16;if (motor_voltage < 0)motor_voltage = 0;if (motor_voltage >= PWM_MAX)motor_voltage = PWM_MAX-1;error_old = error;OCR1B = motor_voltage;// Activate timer1 PWMtimer1_setup();}}void timer1_setup(void) {// Fast PWM top at OCR2ATCCR1A = bit (WGM10) | bit (WGM11) | bit (COM1B1); // fast PWM, clear OC1B on compareTCCR1B = bit (WGM12) | bit (WGM13) | 0b010; // fast PWM, prescaler = 4TIMSK1 |= 0b00000100; // Set OCIE1B to 1 -> compare matchOCR1A = PWM_MAX - 1;TCNT1 = OCR1A - 1;DDRB |= (1 << (PIN_PWM-8)); // Set PIN PWM as output}ISR(TIMER1_COMPB_vect) {timer1_compb = 1; // End of PWM positive Pulse}

author: Picuino
author_rank: Super Contributor
timestamp: June 22, 2024, 06:18:57 pm
content: With a program that displays various internal values, the operation of the controller can be better checked better:Code:const int PIN_PWM = 10;const int PIN_CURRENT = A0;const int PIN_EMF = A1;const int PWM_MAX = 2000;volatile int motor_speed;volatile int motor_voltage;volatile char timer1_compb;int emf;int error = 0;int error_old = 0;int PID_control = 0;int PID_proportional = 0;int PID_derivative = 0;int PID_integral = 0;int PID_kp = 10;int PID_ki = 5;int PID_kd = 10;void setup() {Serial.begin(115200);pinMode(PIN_PWM, OUTPUT);timer1_setup();}void loop() {motor_voltage = 100;motor_speed = 30;while (1) {Serial.print(emf);Serial.print("\t");Serial.print(PID_proportional);Serial.print("\t");Serial.print(PID_integral);Serial.print("\t");Serial.print(PID_derivative);Serial.println();delay(10);for (timer1_compb = 0; timer1_compb == 0;); // Wait for end of PWM pulseDDRB &= ~(1 << (PIN_PWM - 8)); // Set PIN PWM as inputdelayMicroseconds(1500); // Wait disipate motor currentemf = analogRead(PIN_EMF); // Read back-emf voltage// PIDerror = motor_speed - emf;PID_proportional = PID_kp * error;PID_derivative = PID_kd * (error - error_old);PID_integral += PID_ki * error;if (PID_integral < -PWM_MAX * 8)PID_integral = -PWM_MAX * 8;if (PID_integral > PWM_MAX * 8)PID_integral = PWM_MAX * 8;motor_voltage = (PID_proportional + PID_integral + PID_derivative) / 8;if (motor_voltage < 0)motor_voltage = 0;if (motor_voltage >= PWM_MAX)motor_voltage = PWM_MAX - 1;error_old = error;OCR1B = motor_voltage;// Activate timer1 PWMtimer1_setup();}}void timer1_setup(void) {// Fast PWM top at OCR2ATCCR1A = bit (WGM10) | bit (WGM11) | bit (COM1B1); // fast PWM, clear OC1B on compareTCCR1B = bit (WGM12) | bit (WGM13) | 0b010; // fast PWM, prescaler = 4TIMSK1 |= 0b00000100; // Set OCIE1B to 1 -> compare matchOCR1A = PWM_MAX - 1;TCNT1 = OCR1A - 1;DDRB |= (1 << (PIN_PWM - 8)); // Set PIN PWM as output}ISR(TIMER1_COMPB_vect) {timer1_compb = 1; // End of PWM positive Pulse}I have checked that there is a small speed error. The more the motor shaft is braked, the faster it turns. It should be compensated so that higher values of the integral component reduce the measured back-emf value a little. Since I don't have any actual shaft speed meter or any method to accurately brake the shaft, I leave that job to someone else who wants to make further progress on the subject.The conclusion I have reached is that back-emf control of speed is superior to current compensation control.It remains to be checked how the two controls behave acting simultaneously, because at low revolutions the back-emf control has a certain oscillation that it would be desirable to eliminate and possibly it can be achieved with a combined control.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 24, 2024, 04:24:30 pm
content: Oscillations are likely due to a not very well adjusted PID controller. I don't know how much experience you have with those, but they can be finicky to learn to set them up properly. Another possibility is that you simply do not have enough resolution to measure the back EMF properly at low speed. I guess it's not going to be (much) better when using both algorithms.It is useful to measure the motor current. You can use it for overload protection (also note that short overloads (up to about 200% or 300% of the nominal motor current) can be acceptable, but the motor will overheat over time. With a uC you can keep track of the motor current, and extrapolate motor temperature (with temperature decay when current is lower) These will be rough estimates, but you can get a lot more torque out of your motor for short durations, compared with a hard cut off with the comparator as soon as the motor current exceeds a limit.For your software...I don't like "arduino programming". One thing that looks suspicious is to call timer1_setup() repeatedly inside your while loop. And why have a while(1) loop at all? The silly arduino thing already does this in the loop() function.I am also not sure whether your detection of the end of the PWM pulse works, and why are you switching the PWM pin to input?Also very arduino are software delay loops. Any ISR's during such a delay will increase the delay, and this will have an influence on the timing of the PID loops. The I and D parts of a PID are timing sensitive, and timing variation will decrease it's accuracy.You have measured mosfet switch time (as long as the thing does not get too hot then it's OK) so I assume you have an oscilloscope. You can use an arduino pin, set it to an output, set it when an ADC conversion starts, and clear it again when it finishes. This lets you verify the sampling with the back EMF voltage so you can see whether you are measuring a stable back EMF voltage. It's a simple but useful debugging trick.I started programming long before arduino, and would use another approach.1. Have a timer tick ISR that starts an ADC conversion.2. When ADC conversion is complete, run the PID loop and start a single PWM pulse.This guarantees consistent timing for an accurate PID loop, and it leaves your main loop completely free to do regular tasks such as handling user I/O. It is more work to set up, as you need to know more details about your microcontroller, but once set up properly the software is not much more complex.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 24, 2024, 05:10:54 pm
content: Another Idea:You can add another voltage "divider" to measure the back EMF, but in this case use a resistor, and either a zener to GND or a skottky diode to Vcc. This gives you a 5x higher resolution to measure low back EMF and may improve PID accuracy for low RPM.And another thing I forgot to ask:How low can you go now with your RPM in comparison to your other methods? How far are you from your desired goal?

author: Picuino
author_rank: Super Contributor
timestamp: June 24, 2024, 06:06:43 pm
content: Quote from: Doctorandus_P on June 24, 2024, 04:24:30 pmI am not sure what the oscillations are due to. The PID I think is fine tuned. I will try to post the results returned by the microcontroller to see if they show anything I am not seeing.Quote from: Doctorandus_P on June 24, 2024, 04:24:30 pmTrue, but I'm used to creating my own while(1) which usually takes much less time to cycle than the Arduino's loop().Quote from: Doctorandus_P on June 24, 2024, 04:24:30 pmThe interruption starts just when the PWM pulse ends. The interrupt sets a variable which is then sampled by polling in the main loop.Once the PWM pulse ends, it waits for the motor current to reduce to zero and the back-emf voltage is measured. The PWM duty cycle is recalculated and then Timer1 is reset to start another PWM pulse at this exact moment.Quote from: Doctorandus_P on June 24, 2024, 04:24:30 pmYes, it is true. I just hope the times don't vary too much from cycle to cycle. The error cannot be very large (I estimate that there can be a maximum error of 5%).Quote from: Doctorandus_P on June 24, 2024, 04:24:30 pmI am going to try it.Quote from: Doctorandus_P on June 24, 2024, 04:24:30 pmFor now I was just testing the ability to control the motor with a simple program.

author: Picuino
author_rank: Super Contributor
timestamp: June 24, 2024, 06:16:35 pm
content: Quote from: Doctorandus_P on June 24, 2024, 05:10:54 pmMy goal (actually Martinn's) was to achieve a speed of 1% of nominal with stability.In a 24-volt motor, which typically has about 12-18 volts back-emf at rated operation, that means maintaining a back-emf voltage of about 150mV.After the voltage divider this voltage become 27mV, about 5-6 ADC points with ADC reference voltage at 5V.(If I lower the ADC reference voltage to 1.1 volts, then that would be about 25 ADC points).

author: Picuino
author_rank: Super Contributor
timestamp: June 24, 2024, 06:47:20 pm
content: New program more verbose. Cycle time = 10ms:Code:const int PIN_PWM = 10;const int PIN_CURRENT = A0;const int PIN_EMF = A1;const int PWM_MAX = 2000;const int PWM_SCALE = 4;volatile int motor_speed;volatile int motor_voltage;volatile char timer1_compb;int emf;int error = 0;int error_old = 0;int PID_control = 0;int PID_proportional = 0;int PID_derivative = 0;int PID_integral = 0;int PID_kp = 25;int PID_ki = 10;int PID_kd = 10;void setup() {Serial.begin(115200);pinMode(PIN_PWM, OUTPUT);timer1_setup();}void loop() {motor_voltage = 100;motor_speed = 5;Serial.print("emf\tP\tI\tD\tmillis\n");while (1) {Serial.print(emf);Serial.print("\t");Serial.print(PID_proportional);Serial.print("\t");Serial.print(PID_integral);Serial.print("\t");Serial.print(PID_derivative);Serial.print("\t");Serial.print(millis());Serial.println();delay(7);for (timer1_compb = 0; timer1_compb == 0;); // Wait for end of PWM pulseDDRB &= ~(1 << (PIN_PWM - 8)); // Set PIN PWM as inputdelayMicroseconds(1500); // Wait disipate motor currentemf = analogRead(PIN_EMF); // Read back-emf voltage// PIDerror = motor_speed - emf;PID_proportional = PID_kp * error;PID_derivative = PID_kd * (error - error_old);PID_integral += PID_ki * error;if (PID_integral < -PWM_MAX * PWM_SCALE)PID_integral = -PWM_MAX * PWM_SCALE;if (PID_integral > PWM_MAX * PWM_SCALE)PID_integral = PWM_MAX * PWM_SCALE;motor_voltage = (PID_proportional + PID_integral + PID_derivative) / PWM_SCALE;if (motor_voltage < 0)motor_voltage = 0;if (motor_voltage >= PWM_MAX)motor_voltage = PWM_MAX - 1;error_old = error;OCR1B = motor_voltage;// Activate timer1 PWMtimer1_setup();}}void timer1_setup(void) {// Fast PWM top at OCR2ATCCR1A = bit (WGM10) | bit (WGM11) | bit (COM1B1); // fast PWM, clear OC1B on compareTCCR1B = bit (WGM12) | bit (WGM13) | 0b010; // fast PWM, prescaler = 4TIMSK1 |= 0b00000100; // Set OCIE1B to 1 -> compare matchOCR1A = PWM_MAX - 1;TCNT1 = OCR1A - 1;DDRB |= (1 << (PIN_PWM - 8)); // Set PIN PWM as output}ISR(TIMER1_COMPB_vect) {timer1_compb = 1; // End of PWM positive Pulse}Output of the program incrementing the brake from nothing to high brake:Code:emfPIDmillis00000012550503301251000430125150053012520006201252500710125300081275330-209111003701010111004100110012546010120012551001301100550-10140425560-301498-75530-4015910-125480-201687-50460301799-100420-2018813-200340-4019814-225250-102078-752206021750220302270125270502361100310-102460125360102560125410026601254600275275490-2028550490-302948-75460-3030410-125410-203148-753802032311-150320-3033314-225230-303439-100190503534252005036227523020371110027010381012532010391012537004010125420041001254700420275500-20430425510-204408-75480-4044910-125430-204598-754002046810-125350-2047914-225260-4048813-200180104977-501606050727519050517110023010527012528010536012533005460125380055601254300565275460-2057550460-305848-75430-3059410-125380-206048-753502061411-150290-3062313-200210-206338-751805064342519040652350210106620125260306710125310068101253600691012541007010125460071001255100720350530-307306-25520-3074010-125470-4074910-12542007597-504003076911-150340-4077915-250240-4078811-150180407976-251705080711002105081701252601082701253100836012536008450125410085601254600865275490-2087527552008848-75490-608949-100450-1090410-125400-109149-1003601092314-225270-5093311-15021030943425220709523502401096201252903097101253400982012539009910125440010011100480-101010275510-1010206-25500-40103010-125450-4010409-1004101010497-5039020105811-150330-40106915-250230-40107811-1501704010885017060109727520030110701252502011171100290-10112701253401011360125390011451100430-101156425440-3011657-50420-3011758-75390-1011849-100350-1011957-5033020120412-175260-50121412-175190012237-501705012323501904012432752201012520125270201262012532001271012537001282012542001291012547001301350490-30131050490-20131910-125440-5013308-754102013398-75380013499-100340-10135814-225250-50136912-1751802013786-251706013883501903013970125240301406012529001417012534001426012539001436012544001445275470-201456350490-10146510-125440-7014759-1004001014849-100360014959-1003200150413-200240-40151410-12519030152342520060153227523020154301252802015521100320-10156201253701015710125420015820125470015910125520016001100560-10161050560-4016198-75530-30163010-125480-2016397-5046030164910-125410-30165814-225320-40166913-2002401016786-2523070168842524020169701252904017070125340017170125390017260125440017361100480-101745425490-3017566-25480-2017659-100440-3017758-754101017848-753800179512-175310-40180412-175240018145024070182342525010183227528020184301253302018520125380018620125430018710125480018821100520-101891275550-1019018-75520-60191010-125470-2019218-754402019307-5042010193914-225330-70194913-2002501019587-5023060196942524030197811002803019880125330101997012538002007012543002017012548002026350500-302036425510-10204510-125460-6020567-504403020659-100400-2020759-1003600208412-175290-3020957-5027050210435029040211335031002123012536030213201254100214301254600215201255100216201255600217101256100218250610-5021919-100570-40220110-125520-1022107-5050030222110-125450-30223014-225360-40224010-1253104022496-25300402258350320302269110036020227801254101022880125460022970125510023080125560023170125610023276-25600-6023366-255900234710-125540-4023567-5052030236612-175450-50237511-1503901023857-5037040239542538030240435040010241411004402024230125490102434012554002443012559002453275620-20246250620-30247211-150560-6024827-505404024928-75510-1025019-100470-10251113-200390-4025218-753605025306-2535020254035037030254901254203025601100460-10256901255101025790125560025886-25550-6025986-25540026088-75510-2026186-255002026278-75470-20263712-175400-4026477-503805026575038020266642539010267501254404026851100480-1026950125530102705012558002714012563002724425640-4027349-100600-5027448-755701027538-75540027637-5052010277213-200440-6027839-1004004027927-503802028023504004028112754301028210125480202831012553002840012558002850012563002860275660-2028706-25650-40287910-125600-4028897-505803028989-100540-20290912-175470-3029189-10043030292850430402937350450202948110049020295701255401029670125590029760125640029850125690029960125740030068-75710-8030157-506901030259-100650-2030356-2564030304414-225550-80305412-1754802030636-254706030746-2546003083110050050309301255501031020125600031120125650031221100690-1031326-25680-5031418-75650-2031517-506301031618-75600-10317112-175530-4031809-10049030319050490403200504900320911005304032191100570032280125620103238012567003248012572003258425730-4032678-75700-4032778-75670032878-75640032977-5062010330614-225530-7033168-755006033257-504801033362755105033451100550103355012560010336401256500337501257000338401257500339410-125700-10034036-2569040341410-125640-4034236-2563040343313-200550-703442505508034527-50530-203462275560503471012561020348101256600349001257100350101257600351001258100352050810-50352911-150750-6035396-2574050355010-125690-40355910-1256400356912-175570-203578505707035886-25560-10359801256106036070125660036170125710036270125760036370125810036460125860036569-100820-9036666-258103036769-100770-3036858-7574010369513-200660-503705506608037157-50640-20372435066040373401257103037430125760037530125810037636-25800-6037739-100760-3037827-507402037927-507200380211-150660-40381210-1256101038217-5059030383142560030384127563020385101256802038600125730038700125780038796-25770-6038907-50750-1038996-257401039098-75710-2039188-756800392911-150620-3039383506408039487-50620-403957012567070396801257200397701257700398701258200399601258700400618-325740-18040160125790180402617-300670-17040357-50650100404511-150590-40405535061080406550610-204074012566050408401257100409301257600410401258100411301258600412301259100413210-125860-10041437-508403041529-100800-20416210-125750-10417110-1257000418250700504191507000420001257505042100125800042200125850042300125900042401100940-10424911-150880-100425935090080426911-150840-8042796-2583050428816-275720-10042985072011043078-75690-30431801257408043270125790043370125840043460125890043571100930-10436610-125880-90437642589060438510-125840-6043969-1008001044059-10076004415507604044245076004434012581050444401258600445401259100446350910-5044738-75880-3044837-508601044937-508400450210-125790-30451210-125740045216-2573040453250730104541012578050455101258300456001258800457101259300458001259800459015-250880-15046000125930150461016-275820-16046205082011046298-75790-30463835081050464801258603046580125910046680125960046770125101004687012510600469813-200980-13047073501000100471713-200920-10047267-5090060473713-200820-60474635084010047566-25830-304765012588060477501259300478501259800479501251030048040125108004814012511300482412-1751060-1204834425107080484313-200990-9048539-1009504048647-509302048736-25920104883012597060489201251020049026-251010-6049126-251000049229-100960-30493142597050494114-225880-10049516-258708049618-75840-20497035086050498001259103049890125960050000125101005009501010-5050198-75980-305028509803050399-100940-4050488-75910105058509103050675091005078012596050508701251010050970125106005107012511100511615-2501010-150512701251060150513617-300940-1705146425950130515513-200870-90516601259201305175425930-4051850125980405194012510300520401251080052140125113005224012511800523314-2251090-140524301251140140525414-2251050-14052636-2510408052739-1001000-305282012510509052930125110005302012511500531201251200053217-501180-7053315011802053417-501160-2053516-25115010536115-2501050-905370275108013053818-751050-60539001251100805400012511500540901251200054209-1001160-905429275119070543914-2251100-12054496-2510908054585010901054688-751060-30547801251110805488012511600549701251210055087-501190-7055177-501170055277-5011500553610-1251100-3055479-10010601055560125111090556611-1501050-11055760125110011055850125115005596012512000560512-1751130-120561511001170110562415-2501070-140563535010901205644012511403056549-1001100-90566301251150905673012512000568301251250056930125130005703012513500571221-4001190-210572301251240210573211-1501180-11057429-100114020575142511505057620125120040577101251250057810125130005791012513500580014-2251260-140581101251310140582016-2751200-160583001251250160583901251300058507-501280-7058600125133070586916-2751220-160587901251270160588915-2501170-1505899350119012059080125124030591814-2251150-14059280125120014059380125125005948012513000595715-2501200-150596701251250150597711-1501190-110598701251240110599601251290060060125134006016012513900602625-5001190-250603601251240250604517-3001120-170605501251170170606501251220060750125127006084012513200609410-1251270-1006105275130080611411-1501240-9061247-50122040613301251270706144012513200615301251370061636-251360-60617242513702061826-251360-2061936-2513500620214-2251260-8062120125131014062210125136006232012514100624113-2001330-130625101251380130626111-1501320-11062707-50130040628101251350706290012514000630012-1751330-120631001251380120632016-2751270-16063302751300140633918-3251170-160634901251220180635901251270063690125132006378012513700638817-3001250-1706398012513001706408012513500641816-2751240-1606427012512901606437012513400644701251390064570125144006466012514900647610-1251440-10064876-25143040649611-1501370-5065068-7513403065150125139080652511-1501330-1106536012513801106545012514300655501251480065647-501460-7065758-751430-10658401251480806594012515300660419-3501390-1906614012514401906624012514900663318-3251360-180664301251410180665320-3751260-20066630125131020066730125136006682012514100669213-2001330-130670301251380130671210-1251330-10067225013305067310125138050674214-2251290-140675101251340140676101251390067700125144006780012514900679123-4501310-230680001251360230681016-2751250-160681901251300160683001251350068390125140006849012514500685813-2001370-1306868012514201306879012514700688824-4751280-2406898012513302406907012513800691801251430069280125148006937012515300694714-2251440-140695701251490140696712-1751420-120697750142070698611-1501360-6069960125141011070060125146007016012515100702512-1751440-120703501251490120704621-4001330-21070550125138021070650125143007074501430-5070850125148050709416-2751370-160710401251420160711416-2751310-1607123012513601607134012514100714313-2001330-1307153012513801307162012514300717320-3751280-2007183012513302007192012513800720212-1751310-1207212012513601207222012514100723101251460072410125151007251501510-50726115-2501410-100727101251460150728020-3751310-2007290012513602007301012514100731001251460073200125151007329012515600734017-3001440-1707350012514901707359012515400736916-2751430-1607378012514801607389012515300739816-2751420-160740801251470160741813-2001390-1307428012514401307438012514900744716-2751380-1607457012514301607467012514800747715-2501380-150748701251430150749601251480075060125153007516012515800752625-5001380-250753601251430250754510-1251380-10075563501400707565012514503075750125150007584012515500759516-2751440-1607605012514901607614012515400762422-4251370-2207634012514202207644012514700765301251520076630125157007673012516200768313-2001540-1307693012515901307703012516400771222-4251470-22077230125152022077320125157007742012516200775110-1251570-100776101251620100777216-2751510-1607781012515601607791012516100780014-2251520-140781101251570140782117-3001450-17078301100149016078400125154010784919-3501400-1907860012514501907870012515000787914-2251410-1407889012514601407899012515100790917-3001390-1707919012514401707928012514900793901251540079480125159007958012516400796820-3751490-200797701251540200798818-3251410-180799701251460180800701251510080160125156008027012516100803712-1751540-120804601251590120805619-3501450-190806701251500190807601251550080860125160008095012516500810520-3751500-2008116012515502008125012516000813521-4001440-21081440125149021081550125154008164012515900817413-2001510-1308184012515601308194012516100820421-4001450-210821401251500210822301251550082330125160008243012516500825323-4501470-2308263012515202308272012515700828318-3251440-18082920125149018083020125154008311012515900832210-1251540-100833201251590100834120-3751440-200835101251490200836001251540083710125159008380012516400839010-1251590-100840001251640100841013-2001560-1308420012516101308430012516600843916-2751550-1608450012516001608459012516500846916-2751540-1608479012515901608488012516400849913-2001560-1308508012516101308518012516600852816-2751550-1608538012516001608548012516500855723-4501470-2308567012515202308578012515700858711-1501510-1108597012515601108606012516100861612-1751540-12086270125159012086360125164008646012516900865521-4001530-2108666012515802108676012516300868519-3501490-19086950125154019087050125159008715012516400872411001680-10873420-3751530-190874401251580200875401251630087640125168008773012517300878322-4251560-2208794012516102208803012516600881324-4751470-24088230125152024088330125157008843012516200885214-2251530-1408862012515801408872012516300888220-3751480-200889201251530200890101251580089110125163008921012516800893125-5001480-2508941012515302508950012515800896115-2501480-150897101251530150898001251580089900125163008999012516800901015-2501580-15090200125163015090290125168009039012517300904917-3001610-1709059012516601709069012517100907822-4251540-22090890125159022090980125164009108012516900911811001730-10912717-3001610-1609138012516601709147012517100915718-3251580-1809167012516301809177012516800918725-5001480-25091970125153025092060125158009217012516300922614-2251540-1409236012515901409245012516400925523-4501460-2309266012515102309275012515600928501251610092940125166009305012517100931524-4751520-2409324012515702409334012516200934416-2751510-16093540125156016093640125161009373012516600938318-3251530-180939401251580180940301251630094130125168009422012517300943322-4251560-2209443012516102209452012516600946222-4251490-220947201251540220948201251590094910125164009501012516900951119-3501550-19095210125160019095310125165009540012517000955017-3001580-1709561012516301709570012516800958024-4751490-240959001251540240960001251590096100125164009619012516900962919-3501550-1909639012516001909649012516500965918-3251520-18096680125157018096780125162009688012516700969812-1751600-1209708012516501209717012517000972822-4251530-22097380125158022097470125163009757012516800976616-2751570-1609777012516201609787012516700979620-3751520-20098060125157020098160125162009826012516700983512-1751600-120984501251650120985621-4001490-21098650125154021098750125159009884012516400989424-4751450-2409905012515002409914012515500992416-2751440-160993401251490160994401251540099540125159009963012516400997323-4501460-23099840125151023099930125156001000318-3251430-180100120125148018010022012515300100320125158001004211-1501520-11010052012515701101006118-3251440-18010072012514901801008101251540010091012515900101000125164001011024-4751450-2401012101251500240101300125155001014020-3751400-2001015001251450200101600125150001017011-1501440-1101017901251490110101890125154001019921-4001380-21010209012514302101021901251480010228012515300102380125158001024824-4751390-2401025801251440240102670125149001027716-2751380-160102880125143016010297012514800103070125153001031614-2251440-14010327012514901401033714-2251400-14010346012514501401035601251500010365012515500103760125160001038617-3001480-17010395012515301701040522-4251360-22010415012514102201042501251460010434012515100104440125156001045516-2751450-1601046401251500160104740125155001048322-4251380-220104930125143022010504012514800105130125153001052319-3501390-1901053201251440190105430125149001055221-4001330-210105620125138021010572012514300105820125148001059218-3251350-18010602012514001801061101251450010620012515000106310125155001064116-2751440-1601065001251490160106600125154001067021-4001380-2101068001251430210106900125148001069901251530010710012515800107190125163001072916-2751520-1601073901251570160107480125162001075918-3251490-1801076901251540180107780125159001078819-3501450-1901079801251500190108080125155001081723-4501370-23010827012514202301083801251470010847012515200108570125157001086619-3501430-1901087601251480190108860125153001089615-2501430-150109060125148015010915012515300109260125158001093524-4751390-2401094501251440240109550125149001096417-3001370-17010975012514201701098401251470010994012515200110030125157001101420-3751420-2001102401251470200110330125152001104310-1251470-1001105401251520100110630125157001107314-2251480-14011082012515301401109220-3751380-200111030125143020011112012514800111210125153001113113-2001450-1301114201251500130111510125155001116121-4001390-21011171012514402101118101251490011191012515400112000125159001121024-4751400-2401122001251450240112300125150001124024-4751310-240112490125136024011259012514100112690125146001127916-2751350-1601128901251400160112980125145001130916-2751340-1601131801251390160113280125144001133701251490011347012515400113586-251530-601136714-2251440-80113778-751410601138601251460801139717-3001340-17011407012513901701141601251440011426012514900114360125154001144612-1751470-12011456012515201201146520-3751370-20011475012514202001148501251470011495012515200115040125157001151421-4001410-2101152501251460210115340125151001154424-4751320-24011553012513702401156401251420011573012514700115830125152001159215-2501420-1501160201251470150116130125152001162223-4501340-23011632012513902301164101251440011652012514900116620125154001167122-4251370-2201168101251420220116910125147001170124-4751280-2401171101251330240117200125138001173001251430011740012514800117500125153001175919-3501390-1901176901251440190117800125149001178921-4001330-210117990125138021011808012514300118190125148001182810-1251430-1001183801251480100118484251490-401185719-3501350-150118680125140019011877012514500118870125150001189713-2001420-13011907012514701301191716-2751360-1601192601251410160119360125146001194514-2251370-14011956012514201401196617-3001300-17011975012513501701198516-2751240-1601199501251290160120057-501270-7012014012513207012024012513700120358-751340-801204410-1251290-20120548-751260201206301251310801207315-2501210-150120830125126015012093012513100121020125136001211201251410012123012514600121320125151001214228-5751280-28012152012513302801216221-4001170-2101217201251220210121810125127001219101251320012200012513700122110125142001222016-2751310-16012230012513601601223918-3251230-1801225001251280180122600125133001226913-2001250-13012279012513001301228918-3251170-18012299012512201801230811-1501160-1101231810-125111010123270125116010012338012512100123479-1001170-90123574251180501236711-1501120-7012377501120601238712-1751050-701239635010709012406501070-20124160125112050124260125117001243512-1751100-120124458-751070401245412-1751000-401246513-200920-101247510-12587030124848-758402012493350860501250450860-2012513425870101252318-325740-1401253310-125690801254220-375540-1001255318-325410201256212-17534060125712753701001258127540001259101254502012601012550001261050500-50126206-25490-101263011-150430-50126407-5041040126498-75380-101265812-175310-401266815-250210-30126789-100170601268850170401269711002104012707012526010127170125310012726012536001273601254100127451100450-1012755425460-30127656-25450-20127758-75420-20127849-100380-10127948-75350101280413-200270-501281412-17520010128236-2519060128323502103012843350230012852012528030128620125330012871012538001288101254300128911100470-1012901275500-10129108-75470-60129198-7544001293010-125390-20129396-25380401294912-175310-601295814-225220-201296811-150160301297842517070129873501901012997012524030130060125290013017012534001302601253900130361100430-1013045275460-10130567-50440-50130659-100400-20130759-1003600130848-75330101309311-150270-301310412-175200-10131137-5018050131234251903013132275220201314311002601013152012531010131620125360013171012541001318001254600131911100500-1013200275530-10132106-25520-4013219

author: Picuino
author_rank: Super Contributor
timestamp: June 24, 2024, 07:33:33 pm
content: The motor is too fast. The DC motor has little inertia coupled to the shaft and is faster than the control system.

author: Picuino
author_rank: Super Contributor
timestamp: June 25, 2024, 08:40:50 am
content: Plot of dc motor position over time, estimated from the sum of the measured back-emf voltages.Green = Expected positionRed = measured position

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 28, 2024, 11:15:49 am
content: This:Quote from: Picuino on June 24, 2024, 06:16:35 pmSo with one count of difference of the ADC, you get a 20% change of the input signal to your PID algorithm. You're running out of resolution of your control system here, and can't expect it to do much better.The motor being faster as the control algorithm also does not help. You could add intertia or switch to a higher PWM frequency, but you're probably in the region where much more effort is not going to improve overall performance much. But if you think it's fun, you can of course see how far you can push it.

author: Picuino
author_rank: Super Contributor
timestamp: June 28, 2024, 11:54:19 am
content: ADC resolution is not the problem. I have changed the reference voltage to INTERNAL (1.1v) and now, with 5 times more ADC resolution, the problem remains. The motor is too fast.I'm going to try sticking a weight with enough inertia on the shaft to see if it improves control.

author: Picuino
author_rank: Super Contributor
timestamp: June 28, 2024, 12:15:27 pm
content: Results by adding inertia to the axis.The reference is at 20 points of the ADC with reference voltage of 1.1v (22mV emf). That corresponds in my motor to about 60rpm.Code:emfPIDmillis0000006002020033060040043060060053060080062060010007206001200810600140092060016001010600180011106002000120060022001311570239-1014010300249-901501860251-8015922-60249-4016921-30248101792002481018919302491019818602511020818602530218200253-2022722-60251-2023722-60249024622-60247025721-3024610266200246102762002460285200246029418602482030516120252203151515025710324141802631033314180269034415150274-1035315150279036316120283-103721790286-103821860288-10392179029110402179029404111860296-1042121-30295-3043122-60293-1044121-30292104502002921045920029204702002920479193029310489186029510498161202992050813210306305181127031520528103003251053712240333-2054716120337-405571930338-3056721-30337-2057621-30336058620033610595200336060521-30335-1061522-60333-1062424-120329-2063422-603272064421-303261065422-60324-1066322-60322067322-60320068321-3031910693200319107021790322307121418032830721132103351073215150340-207411860342-307511930343-10760200343-1077020034307801930344107891930345079919303460808200346-1081921-30345-108281930346208381930347084721-30346-2085821-30345086720034510876186034720886141803534089711270362309068360374309155450389309250600409509350600429094510300439-10095531-330428-21096439-570409-8097438-5403911098434-4203774099332-36036520100329-27035630101227-21034920102225-15034420103223-9034120104220034130105116120345401061132103523010711321035901080132103660109015150371-2010991790374-2011101930375-201119200375-101129200375011381860377201148179038010115817903830116817903860117716120390101187151503951011971790398-20120722-60396-50121624-120392-20122622-603902012352003902012451790393301255141803993012651321040610127414180412-1012851790415-3012941930416-20130321-30415-20131321-304140132322-60412-10133324-120408-20134223-9040510135222-6040310136122-604010137222-603990138121-3039810139121-303970140022-60395-101411193039630142016120400301430151504051014391790408-2014481930409-20145921-30408-20146821-304070147822-60405-10148722-604030149822-604010150722-603990151721-3039810152621-303970153722-60395-10154623-90392-10155624-120388-10156523-9038510157521-303842015851790387401594151503922016041418039810161316120402-201624200402-40163322-60400-20164323-90397-10165223-903940166222-6039210167221-3039110168222-60389-10169124-120385-20170123-9038210171123-903790172023-903760173023-903730173923-903700175022-60368101759200368201769193036910177818603711017881930372-101798193037301808200373-10181721-30372-10182721-303710183722-60369-10184721-3036810185622-60366-10186622-603640187522-603620188522-603600189523-90357-10190425-150352-20191425-1503470192423-9034420193421-303432019431860345301953161203492019631515035410197315150359019821860361-301992200361-20200122-60359-20201121-303581020212003581020302003580204022-60356-20205023-90353-10206024-120349-10206924-1203450207924-1203410208824-1203370209924-1203330210823-9033010211722-60328102127200328202137186033020214717903331021561790336021661860338-1021761860340021861860342021951930343-102205200343-1022142003430222421-30342-10223422-60340-10224422-603380225321-303371022632003371022732003370228222-60335-20229222-603330230120033320231217903363023211515034120233114180347102340141803530235115150358-1023601860360-302370200360-20237921-30359-10239021-303580239921-303570240822-60355-10241822-603530242723-90350-10243823-903470244722-6034510245721-3034410246622-60342-10247723-90339-10248622-6033710249620033720250518603392025151515034430252515150349025341790352-2025441930353-202553193035402564193035502573193035602583193035702592200357-10260322-60355-20261222-603530262221-30352102631200352102641193035310265121-30352-20266121-3035102670193035220267915150357402690122403653026999330376302709642039030271810300400-4027281790403-70273823-90400-60274824-120396-10275723-9039310276722-6039110277721-3039010278721-303890279621-303880280621-303870281622-60385-10282623-90382-10283523-903790284422-6037710285421-30376102864186037830287416120382202883141803882028931418039402903141804000291315150405-1029221860407-302932200407-20294121-30406-1029522004061029612004060297120040602980193040710299118604091030001790412103010161204161030191930417-30303022-60415-30303922-60413030482004132030581860415203067161204192030781515042410308716120428-1030971860430-203106200430-203117200430031262004300313621-30429-10314522-60427-10315522-604250316522-604230317522-604210318422-604190319423-90416-10320424-120412-10321423-9040910322321-30408203233193040920324317904122032521790415032621930416-20327121-30415-20328121-304140329121-304130330122-60411-10331022-604090332022-604070333022-604050334022-604030334922-604010335923-90398-10336824-120394-10337923-9039110338821-303902033971860392303407151503973034171321040420342715150409-203436200409-50344623-90406-30345623-904030346623-904000347523-903970348522-6039510349422-603930350523-90390-10351423-903870352423-903840353323-903810354324-120377-10355324-1203730356223-9037010357221-30369203581200369103592193037010360118603721036111860374036201930375-103631200375-10364021-30374-10365022-60372-10365922-603700366822-603680367923-90365-10368822-6036310369822-603610370724-120357-20371825-150352-10372724-12034810373723-9034510374620034530375717903483037661515035320377616120357-1037851790360-1037951930361-20380521-30360-20381421-303590382421-303580383321-303570384421-303560385322-60354-10386323-90351-10387223-903480388324-120344-10389224-1203400390223-9033710391122-6033510392022-603330393122-603310394021-30330103950193033120395918603331039701860335039791860337039891860339039981860341040081930342-104018200342-1040282003420403721-30341-10404722-60339-10405722-603370406621-303361040762003361040852003360409621-30335-10410521-30334041152003341041241790337304134141803433041441321035010415414180356-10416316120360-2041731860362-204183200362-20419221-30361-10420221-303600421121-303590422122-60357-10423122-603550424123-90352-10425023-903490426022-6034710427022-603450428022-603430428923-90340-10429922-6033810430820033820431818603402043281515034530433715150350043471790353-2043571930354-20436719303550437619303560438619303570439619303580440619303590441521-30358-20442523-90355-20443422-6035310444521-3035210445420035210446321-30351-1044732003511044831790354304493151503592045021224036730451293303783045214480394504532060041440454106004340455110300444-100456129-270435-190457139-570416-100458138-54039810459035-45038330459932-36037130461030-30036120461926-18035540462924-12035120463823-9034810464721-303472046581860349304667151503543046771224036230468611270371104697112703800470614180386-3047161860388-40472521-30387-30473621-3038604745200386104755193038710476419303880477419303890478418603911047941790394104803161203981048131860400-20482321-30399-30483322-60397-104842193039830485116120402304861151504071048711418041310488115150418-10489016120422-1049001860424-204910200424-20492021-30423-10492922-60421-10493922-604190494822-604170495922-604150496822-604130497823-90410-10498724-120406-10499823-9040310500722-6040110501620040120502618604032050361612040720504616120411050551860413-205065200413-20507421-30412-10508522-60410-10509422-604080510422-604060511322-604040512422-604020513321-3040110514321-304000515221-303990516123-90396-20517225-150391-20518223-9038820519121-303872052001860389305211151503943052201418040010523016120404-205239200404-40525022-60402-20525923-90399-10526923-903960527822-6039410528822-603920529823-90389-10530823-903860531723-903830532624-120379-10533723-9037610534624-120372-10535623-9036910536522-60367105376200367205385193036810539517903712054041790374054141930375-20542421-30374-20543422-60372-10544322-603700545222-603680546322-603660547222-603640548223-90361-10549123-903580550123-903550551123-903520552123-903490553023-903460554021-30345205550193034620556017903492055691515035420557915150359055881860361-305598200361-20560821-30360-10561721-303590562721-303580563721-303570564721-303560565622-60354-10566624-120350-20567625-150345-10568624-12034110569523-9033810570422-6033610571423-90333-10572423-903300573421-30329205743193033020575318603321057631860334057731860336057821860338057921860340058011860342058121930343-105821200343-1058302003430584021-30342-10585022-60340-10586022-603380586921-3033710587921-303360588921-303350589921-303340590821-303330591819303342059271790337205938151503422059471321034920595714180355-10596616120359-2059771930360-305986200360-10599521-30359-10600521-303580601421-303570602522-60355-10603423-90352-10604423-903490605322-6034710606422-603450607322-603430608323-90340-10609223-9033706102EDIT:I have not been able to avoid the speed oscillation despite trying to tune the PID with higher derivative gain.Perhaps another control system would be better, one based on the internal model of the dc motor.

author: khach
author_rank: Contributor
timestamp: June 28, 2024, 12:18:37 pm
content: What about microchip appnotehttps://ww1.microchip.com/downloads/aemDocuments/documents/OTH/ApplicationNotes/ApplicationNotes/Sensorless-Position-Control-of-Brushed-DC-Motor-Using-Ripple-Counting-Technique-00003049A.pdfwith commutator ripple feedback?

author: Picuino
author_rank: Super Contributor
timestamp: June 28, 2024, 12:21:21 pm
content: I think the back-emf voltage measurement gives realistic motor speed feedback and is simpler to implement.The problem is in the control system. With Ripple Counting Technique the problem would be similar.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: June 28, 2024, 12:58:00 pm
content: Increasing derivative gain is making your system more stable. It's use is to make the motor respond faster, but how can you expect that to work if your control algorithm is already slower then your motor response time? As a minimum, your PID algorithm should run at 4x the speed of the motor response time and 10x is more comfortable.But why do you think the motor response time is faster then the PID algorithm in the first place?I see a sampling time of around 10ms (With a lot of Jitter, that is not good as I wrote before) and I see an oscillation with a period of around 12 samples, i.e. 120ms.Also, derivative term is for increasing response time. This is not important for a power feed motor. It's likely better to not use this at all in this case.Another suspicious pat is that both the P and D terms are multiples of 10.

author: Postal2
author_rank: Frequent Contributor
timestamp: June 28, 2024, 01:11:48 pm
content: Quote from: Martinn on June 09, 2024, 05:11:27 pmYou can open any schematics of VCR from 1980's (70's ?) and use solution from it. Top loading VCR, as I remember.

author: Picuino
author_rank: Super Contributor
timestamp: June 28, 2024, 04:45:16 pm
content: I just realized that this low speed, low friction control has a major problem because it isnonlinear.Accelerating the motor is very simple, just give it more current by increasing the PWM cycle, but no matter how much you reduce the PWM cycle at any time you can not brake the motor. For that we depend on the external friction. When the external friction is low, we have a nonlinear control that cannot be controlled as a traditional PID.That is probably the reason why in the result of a few posts ago the "jerky" dc motor operation was reduced when the shaft brake was increased.I am going to try to implement another type of control, a model based control, which I think can become more accurate.

author: Postal2
author_rank: Frequent Contributor
timestamp: June 28, 2024, 05:10:10 pm
content: Are you generally familiar with DC motor controllers in VCRs? Do your research before writing anything.http://www.ids-elektronik.de/159.pdf

author: Picuino
author_rank: Super Contributor
timestamp: June 29, 2024, 08:33:32 am
content: Sorry, I have researched and read that datasheet (the English translated version) and did not understand how to apply it to the dc motor control.Do you have any document explaining the issue?

author: Postal2
author_rank: Frequent Contributor
timestamp: June 29, 2024, 11:49:53 am
content: Quote from: Picuino on June 29, 2024, 08:33:32 amI have it, but in russian. I think the first thing to understand is that a speed sensor (FG) is definitely needed.

author: Martinn
author_rank: Frequent Contributor
timestamp: June 30, 2024, 07:29:34 am
content: Quote from: H.O on June 16, 2024, 05:53:56 pmSo the servo amplifier has arrived (thanks), some info on the unit:More details in the manual (link above).For Doctorandus_P here's the PCB imageUnfortunately all markings are sanded off. As the four power MOSFETs are soldered from the bottom and bolted to the case, I can't show an image of the bottom side.- Martin

author: H.O
author_rank: Frequent Contributor
timestamp: June 30, 2024, 09:30:32 am
content: Here's an image of the underside.MOSFETs are IRFP150.

author: Picuino
author_rank: Super Contributor
timestamp: June 30, 2024, 10:29:47 am
content: Quote from: Postal2 on June 29, 2024, 11:49:53 amWith the back-emf control system, the speed sensor is the dc motor itself, which acts as the motor and also acts as the tachometer when the current drops to zero. This system has the disadvantage of having to disconnect the motor from the power supply several times per second, so it cannot be continuously connected to 24V. But that matters little at low speeds.The control I am implementing right now has the motor connected to the power supply via PWM for 8 milliseconds and disconnected for 2 milliseconds (20% of the time). This means that at most I can deliver 19V to the motor when I set the PWM control to 100%.During the time the motor is off, it simply acts as a tachometer delivering a voltage proportional to the speed the motor is at that moment (dc motor acts as speed sensor).

author: Postal2
author_rank: Frequent Contributor
timestamp: June 30, 2024, 01:39:24 pm
content: Quote from: Picuino on June 30, 2024, 10:29:47 amOkay.Quote from: khach on June 28, 2024, 12:18:37 pmBeautifully packaged incompetence.

author: Martinn
author_rank: Frequent Contributor
timestamp: June 30, 2024, 03:58:54 pm
content: Quote from: Martinn on June 15, 2024, 08:44:33 amPlayed a bit with the 30A8. Tried out different modes - current, voltage, IR compensation.And I have to say this thing just... works. Out of the box with default values performance is already decent. For IR compensation I tried different compensation values (try to find R8 on the PCB) and you quickly find the one that is just right.While there is not much to adjust overall, what they have as defaults is clearly very well designed.So what did I get? With IR tuned and loop gain quite a bit below oscillation, lowest usable speed seems about 12 s/rev (after gearbox) or 5 rpm, resulting in 20 mm/min feed. Not quite as low as I'd like, but 3x lower than the previous analog implementation.It looks like I have to come up with a mechanically sound way to integrate the amplifier to the feed unit. It is many times too large to fit into the original housing, so I'll have to 3d print something.

author: Martinn
author_rank: Frequent Contributor
timestamp: August 21, 2024, 06:34:42 pm
content: Quote from: H.O on June 16, 2024, 05:53:56 pm3D printed an adaptor housing and connected the amplifier to the motor!And it works! Velocity control loop is slightly unstable at low feeds, but I don't have easy access to measurement tools or other instrumentation in my workshop (anyway near the mill it's constantly full of chips), so most likely it will stay that way.At some time a stepper feed on all axes might come, but certainly not this year.Thanks again! Martin

author: H.O
author_rank: Frequent Contributor
timestamp: August 21, 2024, 08:06:34 pm
content: You're welcome, I'm glad it worked out allright even if it's not perfect.And this is without any sort of feedback. If you'd put a good old tachometer on the motor you'd have much better low speed control.Anyway, thanks for the update!