Change your stepper by a servo DC motor on Prusa i3 x-axis

by misan, published

Change your stepper by a servo DC motor on Prusa i3 x-axis by misan Jan 1, 2015
0 Share
Download All Files

Thing Apps Enabled

Order This Printed View All Apps



Liked By

View All

Give a Shout Out

If you print this Thing and display it in public proudly give attribution by printing and displaying this tag.

Print Thing Tag

Thing Statistics

4941Views 416Downloads Found in 3D Printer Accessories


I am studying the choices of using DC motors instead of steppers. This is my first example and I needed to attach the motor to an existing printer, this part did it.

You can see the servo working before being installed in the printer in the next video: https://www.youtube.com/watch?v=jB6carTGRn8


This is the software I am running on an additional Arduino UNO: https://www.youmagine.com/designs/dc-motor-closed-loop-control-software

And here it is the first print:

More from 3D Printer Accessories

view more

All Apps

3D Print your file with 3D Hubs, the world’s largest online marketplace for 3D printing services.

App Info Launch App

Auto-magically prepare your 3D models for 3D printing. A cloud based 3D models Preparing and Healing solution for 3D Printing, MakePrintable provides features for model repairing, wall thickness...

App Info Launch App

Kiri:Moto is an integrated cloud-based slicer and tool-path generator for 3D Printing, CAM / CNC and Laser cutting. *** 3D printing mode provides model slicing and GCode output using built-in...

App Info Launch App
KiriMoto Thing App

With 3D Slash, you can edit 3d models like a stonecutter. A unique interface: as fun as a building game! The perfect tool for non-designers and children to create in 3D.

App Info Launch App

Print through a distributed network of 3D printing enthusiasts from across the US, at a fraction of the cost of the competitors. We want to change the world for the better through technology, an...

App Info Launch App

Quickly Scale, Mirror or Cut your 3D Models

App Info Launch App

3D Print a wide range of designs with Treatstock. Easy to use tools to get the perfect result. The global 3D printing network that connects you with high-quality and fast working print services nea...

App Info Launch App

Excellent idea. I was thinking about something like this.
Here are my questions/proposals:

  1. what pulley do you use for the motor? It sure does not look like GT2 or something similar...
  2. as the link to Aliexpress no longer works, can you, perhaps, share the specs of the motor? Like torque, voltage, ... I am wondering if a smaller DC motor like from salvaged inkjet printer can also do this work
  3. how do you solve the static position? Can the motor hold some position as servo does? Would some sort of gear/transmission be better for this? (e.g. worm gear)
  4. my first idea was to wastly increase the number of steps per mm to provide better "resolution input" to the decoding arduino. However you suggest to change it to 31.18 from my current value (100). Do you think increasing the number of steps would help the target arduino to provide more accurate signal?
  5. I thought about moving the encoder part to the other side of the axes - so I count only real-life movement, not movement ofthe motor shaft. With this approach I can more or less compensate for any skipped steps due to pulley vs. belt slips on the motor side. It would mean I will have to make some type of pulley-like wheel on the other side of the belt, but that should in general not be a big problem. What do you think?
  6. Final thought - instead of measuring the shaft or the wheel, my idea was to use optical sensor from PS/2 mouse and measure the direct movement of the belt and provide this as the closed loop info for the arduino. You already made I2C code for the AMS sensors, so this should not be huge difference. Is it, in your oppinion, feasible?
    Thanks again for sharing this!
Apr 22, 2017 - Modified Apr 22, 2017
Kadah - in reply to rklauco

6: A rotary or linear optical encoder from an old inkjet printer would be a better option. Most HP ones will have one of each and possibly one or two additional rotary ones if they have a built in scanner.

The first build of my printer used most of the printhead motion assembly for its X axis, making use of the linear optical encoder. This did work, but the minimum movement resolution was pretty bad. This lead to essentially backlash, but whenever it stopped moving. Printhead DC motion is good at knowing absolute position and controlled movement speed, but not good at moving short distances.

I planned to revisit this later using a geared DC motor instead when I finally manage to acquire a GT2 drive pulley with a 6mm bore.

Hi Kadah,
You make an interesting point: measuring the linear output instead of the rotary shaft makes more sense to remove any backslash the mechanism could add. Inkjet printers use the optical pattern mostly to fire the dots and only loosely for position and speed control, as the head does long swings from side to side.

From you comment I gather the resolution, while quite fine is not good enough for precise positioning (though I would say 0.1mm accuracy is ok for FDM 3D printing). When you mentioned backslash (which you should have none) it brings the notion of motor dead-band to my mind. My code does not handle that but any real system is going to have one, so you might want to add some compensation for that to any non-null control action.

My main fears with geared motors are: backslash (if using motor shaft encoder), noise and short life span. Let us know how it goes.

The direct drive motor I was using simply didn't have enough poles for that level of positioning. If I turned up the Kp to insane levels, it helped a little for somewhat smaller movements (around 10 encoder pulses at best), but any corrective or sudden long movements (which really shouldn't happen when dealing with step input) were unstable and violent.

On geared motors, you could attach the rotary encoder to the belt drive pulley. 3d printed pulley cap magnet holder? A salvaged optical rotary encoder would work too, but those tend to be rather wide (the high res ones I have are at least 60mm).

The linear encoder on the 2 inkjets I salvaged I estimated to be 150 lines per inch, which worked out to just over 5.9 lines per mm.

One improvement I was planning to make to the DC servo code was to scale the encoder pulses per step. I think would have worked better if one step was the minimum movement that is possible. At 5.9 lines per mm and 4 encoder pluses per line, that came up to 23.622 steps per mm, or around 0.0423 mm per step, which was entirely impossible for my motor. I think the minimum I was able to get was maybe around 0.2mm (I really need to get a dial indicator).

The DC gear motor I was going to test more with is rated at 300RPM. I did some initial testing using a rubber tire for a belt pulley (this did not work, belt did not track well) before the extra stepper motor was able to be delivered and 300RPM may be too fast. I think my estimate for a good speed was around 250, but only 200 and 300 were readily available for order.

Very interesting.

Yes encoder on the pulley/output shaft will take care of gear backslash.

Geared motor will be slower and with less acceleration but motor will operate at higher RPM and it might work better (mostly due to more output torque).

Please let us know how it goes with the geared motor.

Hi rklauco,

1- motor I used came with MXL pulleys but those can be replaced by the ones of your choice (but then the part may need a redesign)
2- Asking datasheets on Aliexpress is kind of a lost cause, they do not have a clue what they are selling most of the time http://es.aliexpress.com/store/product/DC-3V-6V-12V-encoder-speed-motor-Worm-gear-motor-AB-phase-888-Free-shipping-1604/909696_1925658956.html?spm=2114.04010208.3.307.higsZQ&ws_ab_test=searchweb201556_1,searchweb201644_5_505_506_503_504_301_10020_502_10001_10002_10017_10010_10005_10006_10011_10003_10021_10004_10013_10022_10009_10008_10018_10019,searchweb201560_5,searchweb1451318400_-1,searchweb1451318411_6451&btsid=30ba4b94-9577-4440-a78a-b82d3112aa7f
3- a closed-loop motor is a servo. If you tuned it well it will hold position. A gear set can increase output torque.
4- that entirely depends on the encoder avaiable on the shaft, the number of teeth and pitch of the pulley and whether or not you use a gear set.
5- that sounds like a good idea, though delay may make it more difficult to tune or get stable. Let me know of it goes if you try it, please. It will be a good idea if you use a geared motor too.
6- that was mentioned in reprap forums and G+ but some people claim it won't work. I have not tested myself but it seemed to me it could work. However mouses might lose steps without us noticing as we do not expect to provide a high accuracy, as we use the visual feedback on the computer screen. I won't be surprised it could work, but my guess is that processing power needed to work at high speed might not be available in common optical mouse chips. If you go for it and get good results, please let us know.

Great work. but...
whenever I want to compile the script, I get an error:

servostrapv02.ino:20:32: fatal error: PinChangeIntConfig.h: No such file or directory
compilation terminated.

maybe you can help me.

many greetings

Thanks zelos113, please note I am using a couple of libraries here. That means these libraries need to be installed http://arduino.cc/en/Guide/Libraries

If not, an error is triggered when compiling the code as Arduino does not know anything about that library.

Feb 24, 2015 - Modified Feb 24, 2015
zelos113 - in reply to misan

Hey Misan,
Thanks for you really fast Reply.

Can you tell me which libraries i need?

And can you give me please an actual link to the Motor?

Thanks a lot and have a nice day

Thank you a lot. Now it Works.
Can you maybe provide your Config.h from Marlin? Just for example.

I did only change the steps/mm on the axis I replaced the motor by a servo (X & Y in my case). The new steps/mm was 31.18steps/mm (though the word steps now means encoder lines) but that number was for the first version of the encoder, I guess now it should double that. You can change that in Configuration.h but I do use M92 command to do it from pronterface and M500 to store the changes in EEPROM (that only works if you have it enabled in your firmware to start with).

Hola Misan,

Thanks you soo much for your Help and Time.
How do you Calculate the Stepperstick current on the Ramps? Like with a Stepper Motor?
Like here: Imax(mA) x (0,4 Rs = Vref ( A) ?

And can you Maybe tell me more or send mi a link to understand more the Gains?
What about this concept of DC Motors in a Delta Tower? Do you already think about this?
Muchas Gracias,
Que tengas un Buen Dia.

Exactly, voltage the potentiometer is proportional to the current through the motor windings. 0.4V is usually more than ok.

Have a look at this: http://brettbeauregard.com/blog/2011/04/improving-the-beginners-pid-introduction/

I do have several deltas and I think this can be used too, I just did not have the time to try it out, but it should work ok (though current version may be a bit rough yet leading to not having better looking parts than with steppers).

Feb 25, 2015 - Modified Feb 25, 2015
zelos113 - in reply to misan

Thank you for the Informations and the Link. It's very helpful for me.
now I wired up all as like you but I can't control the motor. When I connect in pronterface, all fine... but when I click on move manually x axis right 10 steps the motor starts and turn permanently till I cut of the usb cable from the arduino.move manually x axis to the Left does not work. Do you have any idea about this?
Do you put 12V on the L298N Module? On The Photo you do it but in the schematics not?!
Have a nice day

Please note you may have the motor power backwards (so motor will turn the wrong way and never will reach the intended destination as it is not getting closer but farther away from destination). Swap motor cables to see if that fixes it.

Yes I do use 12V for the L298 module.

I see! You are right! Big improvement!

Jan 2, 2015 - Modified Jan 2, 2015

Where is the benefit? Higher precision?

Closed-loop means it will gracefully recover from any bump (no missed steps).

where did you find the servo motor

Sorry guy but the link above is no longer pointing to the motors I used.

Nope. That looks like spees only. Not position encoder.