Closed Loop control

Has anyone looked into closed loop control? High end cncs use linear scales to feed position info back into the control loop to drive the servo. Those systems are expensive, but I was thinking of a way to do something similar with a magnetic rotary encoder. You could add a second belt per axis that is not driven by the motor (so it wont stretch), but is attached as close to the spindle as possible and turns a magnetic encoder. This would give you the position of the slindle very accurately. Any errors from flex in the frame, or belt stretch would be corrected for as you are measuring the spindle directly and telling the motors how to move accordingly instead of just telling te motors to move and assuming there are no errors between th motor and the tool being driven. Measuing the position is straightforward. Does anyone know if Marlin, Smoothieware or any other controller supports closed loop control yet?




Looks like it has been done. Not sure if this is ready for prime time or is more of a science experiment.

I think you’d put that into the motor controller.

I’m not sure flex is that big of a deal. If you don’t skip steps, the X,Y are plenty accurate enough. The Z would be great, if it actually measured distance to the top of the workpiece. The flex is Z is really the bigger concern.

There is a video of stepper based encoders on an MPCNC from a while back. I think he over came the programming issues buy putting a tiny arduino on each one.

I do think there is validity in this, as heffe said on the stepper is as good as it gets and much easier/safer. If we can ever get the dual endstops pushed something like this would really just make for a more reliable machine, but really a servo based machine could be a better choice. I am excited to try new hardware. If there were ever a pro version I would for something like this to be in it.

I also found this little gem, to 40hp MPCNC?

Now that I think about it his geared motors might have some massive backlash and encoder is on the side of the stack. I used something very similar from Maxxon I believe, super high quality but the huge gear stack has backlash you can’t help.


Here are a couple of closed loop servos on kickstarter. They both use magnetic encoders.

I wonder what would happen if instead of putting the encoder on the motor you put it on a separate belt and attaching it close to the spindle. It would remove the error in the system but could do strange things because of delay or overshoot. The PID might go crazy. Does anyone have much experience with this kind of thing?

The point of putting them on the steppers is assuming rigidity in the rest of the system and detecting missed steps do to some problems in the system. I think trying to account for system flex with encoders is trying to fix a hardware issue with software (and added hardware). You would end up pid tuning each axis for different materials I would think.

This article goes into great detail about closed loop control of CNCs. Linear glass scales are the most accurate because they measure the actual position and can correct for:

" thermal expansion, errors in the leadscrew thread, errors in the timing belt system driving the ballscrew, backlash, and so on."

Magnetic encoders like the ones used in the two kicskarter sevo projects are a fairly recent things. They can give you over 4000 steps per rotation and are cheap. I don’t see why you couldn’t build a poor mans linear scale with a belt, pulleys and a magnetic encoder.




The main thing is, we don’t need them. We are more than accurate enough as it is. We would just use it for missed steps and we can do that with trinamic drivers already.

What they can measure and what we can accurately cut are different things. I have a blurb about accuracy and tolerances in the FAQ’s.

Now if it was some sort of optical comparitor and corrected the actual cut, so different than dealing with runout, a dewalt router instead of a spindle, zinc coatings on EMT conduit, end mill tolerances, vibrations, chatter, Rpm.

I would much prefer a programmable RPM pid controller for the “spindles” we use.

To me this is just one area we actually don’t need to improve. The rest of the machines parts can all get a few times better before this sort of thing would even be on my radar.

Using it to switch to servos instead of steppers would be worth it as well. But right now steppers are stupid cheap and we don’t cut very fast, I can deal with “slower” rapids and accelerations to ensure no skipped steps.

It’s not about using DC motors instead of steppers, faster acceleration or detecting missed steps.

My thinking was that when you are cutting something like aluminum that requires a lot of force, the Z axis will flex a bit and and the spindle will be off a little. If there was a way to detect that error and correct for it the performance could theoretically approach that of a much stiffer machine. It’s just an idea. I don’t know if it would actually work.

Maybe think of it this way, if you are using gcode that is written poorly enough to flex your machine an encoder would just push it even harder making the problem worse.

That is why finishing passes are used.

Any real machine flex when cutting metal will destroy an endmill, if it cuts there is very little flex. We talk about it like it is huge but it really isn’t. The sort of things that mess up a cut are driving into it to hard and the endmill grabbing enough to flex the machine around. Vibrations and chatter from the bit actually taking bites of the material in a hard cut are cleaned up with a finishing pass with extremely minimal force on the cutter. A more rigid machine is harder to bend and flex when incorrect cgode is used. When the gcode is correct the machine is under much less stress that you would think.

The way flex makes a machine worse is it creates a giant spring, not actually deflecting in a cut in a way that would be correctable with an encoder.


I work with a high school robotics team and we use motors with encoders all the time. We really struggled in the past of getting them to work well for position control. A PID controller, has difficulties when moving from point A to point B, fast and accurately, at the same time.

Last year we we discovered motion profiling. A practice used in high tech robotics. Basically you define the distance, the ramp up speed, the constant velocity speed, the ramp down speed, and you calculate the position at many intermediate points all along the way. You then apply PID control to getting to each way point. The end result is vary fast movement with no overshoot, and high accuracy.

Not sure this is the what would work for what everyone is talking about here but if one were to try it, I would at least look into motion profiling to see if it would help.



I don’t think this system would bring much precision or cut quality, but it would bring quite a bit of reliability, since you wouldn’t have any missed steps anymore.

Missing steps is my only fear every single time I’m doing something with the MPCNC. Any failed job I had in the past was failed because of wrong parameter settings leading to missed steps at some point.

So, sure, I shouldn’t set wrong parameters in the first place, but whenever you try new materials, new stuff, it’s always a shot in the dark, so a more forgiving machine can only be a great help.

So, I wish such a system could be made affordable at some point.