# Closed-loop stepper motors

I am thinking to use closed-loop stepper motors to prevent step loss and make the machine more accurate. What options (preferably low cost) are there for:

stepper motor + driver + encoder + microcontoller

Is building it from scratch worth it? E.g. Arduino Mega 2560 + RAMPS 1.4/1.5/1.6 + stepper motors (e.g. NEMA17) + drivers (e.g. A4988, DRV8825) + encoders (e.g. AS5047P, AS5047D, AS5048A, TLE5012B) + microcontrollers (e.g. STM32).

• The RAMPS setup is completely outdated anyway. BTT offers a complete setup for closed loop steppers: de.aliexpress.com/i/33000419800.html However, I think the benefits lie more with CNCs. If you lose steps - even if they're corrected soon after - you'll still have artifacts in the print from the other axes that kept moving. Just use drivers that make losing steps a lot less likely in the first place, e.g. TMC5160s, and make sure you mechanics work well.
– towe
Feb 27 '20 at 9:54

A number of options exist, but keep in mind that cost will be a limiting factor.

(Small sidenote: cost depends on persective, financial cost does not equal mental cost. The tradeoff between buy or make depends also on your willingness to persist when things don't work right away.)

Before you start: make sure that your printer has enough space to accomodate bigger motors.

So, what options are there?

1. Change your current configuration. If you are losing steps, it could very well be that it can be fixed in firmware.

• Pro: No budget and nothing to lose.
• Con: No shiny closed loop system. (Is that bad though?) Possibly need to configure and compile your own firmware.
2. MacGyver / DIY solution based on low lever components

• Pro: Probably as cheap as you'll get depending on how you choose your components. Might be an interesting learning experience, not to mention the satisfaction afterwards. This could be the smallest build size you'll see in all the options.
• Con: You'll need a decent amount of engineering and debugging. Might be tricky to mount the encoders.
3. Same as 1, but now consider using of the shelf stepper motors with integrated encoders.

• Pro: Most robust option on a budget in my opinion due to the single mechanical piece (motor + encoder).
• Con: Integrated encoders have a considerable cost and are large compared to their vanila versions.
• Pro: No need to worry about driver configurations too much. Just plug in the numbers or set the dip switches. Very conveinient solution. Pretty much plug and play.
• Con: This will already be challenging on a budget. Making a wrong mix and match might lead to unpredictable results such as drives going in overcurrent. (Which, believe me, is very frustrating for your application!)
4. If we are allowed to consider servo motors: ClearPath-SD series (Or any alternative for that matter!) I'm just including this for completeness.

• Pro: Performance wise a clear winner on pretty much any relevant level.
• Con: You'll need a big budget!

Bottomline: You'll probably want to give the first option a go before spending money. Next stop, you might want to take the second option (you already did research on different specific low level components), and if you have time to spare I'd go with that as well. If you are also on a budget timewise, I'd definively suggest to take the third option with existing driver boards.

The other options are more cost heavy and become real options in produciton environments, where downtime is also costsing money.

As to the microcontroller, take whatever you have available. Just know that more computational power will allow you to output steps faster and will allow for smoother movements. Lot's to talk about there as well!

So, I am one of those who has implemented this on my big scale heavily modified cr-10 S5.

Why?

Well with bigger prints, the risk of crashing into itself because of a small blob is very real. Possibly ruining a 100$worth of filament and missing deadlines. (We are using this professionally.) Blobs will happen, especially if you run low cost filaments and PETG, which is the only sane option for functional bigger prints from a cost perspective. We are using the BTT system S42B on all axis and it works well. A blob is now just a small distraction which can be polished away but the remaining print is still dimensionally correct. However, it is not a trivial task to actually implement. To make this work one needs a printer main board allowing for external stepper drivers, like SKR E3 DIP,SKR V1.4,SKR V1.4 Turbo and so on. Also there one needs to tune the PID:s for the system in use which is not super simple. If you are truly an expert and do big prints, I really think this is a must have upgrade. On the other hand if one are only printing smaller parts on a hobby scale this will not be a worth while upgrade. I am not talking about the money involved, the pcbs are just 14$/pcs but the work needed with new cabling pid-tuning marlin-digging and so on. For us it is just amazing to not have 30% failures any more, du to the inevitable blobs sometimes appearing in bigger prints.

• I don't see the relevance for the question asked
– FarO
Jun 12 '20 at 12:31

I've implemented a closed-loop system about 25 years ago on an 8 x 32 erosion table scanning it at one cm resolution using laser triangulation. It took 120 hours to scan the surface. Most of the time was spent waiting seven seconds for the system to stop shaking. I put shaft encoders on the X, Y, & Z shafts, not the stepper motors. I wanted to sure I got the movement of the camera.

In the end, I settled on moving to a goal with a 1/10 mm tolerance and added any error into the move to the next goal. There was a sphere of confusion of the location of the camera of more than 2/10 mm. Moving back and forth to make up for a missed step at the cost of nearly 10 seconds a move could add days to a run. We were well past the end of the table's life.