<p>[For now] most of the open source 3d printer firmware written for Arduino-based hardware. This means you can just download the source and look through the relevant pieces of code.</p>

<p><a href="https://github.com/MarlinFirmware/Marlin" rel="nofollow noreferrer">Marlin</a> is the most obvious example.</p>

CC BY-SA 3.0
2017-03-10T12:02:03.190Z
2017-03-10T12:02:03.190Z
Mikhail Z
<p>A stepper motor is different from a typical electric motor. Instead of being "on" or "off", or running a some approximate variable speed, the controller sends a series of pulses to drive the motor one step at a time. This can be driven forward or backwards.</p>

<p>Based on how the motor and machine is designed, the machine will move a tiny amount. If for example, one step moves , say 0.1mm. If you send 150 pulses in the forward direction, the machine will move 15.0mm If you then send another 8 pulses in the reverse direction, the machine will be 14.2mm from the starting point.</p>

<p>To know the absolute position, you need to establish the starting point. Most printers have limit switches at their "home" position. To initialize the position, drive the motor until it hits the switch, and then set position as zero.</p>

<p>Then count the pulses up and down as you send them, you will will keep track of the machine's position.</p>

CC BY-SA 3.0
2017-03-10T20:34:29.693Z
2017-03-10T20:34:29.693Z
mbmcavoy
<p>I'm building an automatic warehouse system using three NEMA 17 stepper motor. </p>

<p>My problem is to move the motors with precision, since I do not have any kind of encoder on the motor and so I cannot know the position of the axes. I thought that the system could be similar to a 3D printer, since neither 3d printers have encoder on the motor. </p>

<p>Where can I find a sketch for Arduino of a 3D printer, to understand how they work? How do they move with such precision without any kind of sensor?</p>

CC BY-SA 3.0
2017-03-09T18:30:01.190Z
Hi Luca, have you tried http://arduino.stackexchange.com/ ? Unfortunately this is not a 3d printer so we cannot help..
MakerModder
CC BY-SA 3.0
2017-03-09T20:14:50.543Z
A better title for this question would be "How does a stepper know its position without feedback from an encoder?". However, I'm not sure if this is on-topic here.
Tom van der Zanden
<diy-3d-printer><arduino-mega-2650>
Arduino 3D printer sketch
Luca Daidone
# Arduino 3D printer sketch

(Asked by: username_0 on 2017-03-09)

I'm building an automatic warehouse system using three NEMA 17 stepper motor.

My problem is to move the motors with precision, since I do not have any kind of encoder on the motor and so I cannot know the position of the axes. I thought that the system could be similar to a 3D printer, since neither 3d printers have encoder on the motor.

Where can I find a sketch for Arduino of a 3D printer, to understand how they work? How do they move with such precision without any kind of sensor?

**Tags:** diy-3d-printer, arduino-mega-2650
> **Comments:**
> **username_1**: Hi Luca, have you tried http://arduino.stackexchange.com/ ? Unfortunately this is not a 3d printer so we cannot help..  
> **username_2**: A better title for this question would be "How does a stepper know its position without feedback from an encoder?". However, I'm not sure if this is on-topic here.  

---

## 2 answers

### Answer by username_3 on 2017-03-10. Score: 1 | Accepted answer

[For now] most of the open source 3d printer firmware written for Arduino-based hardware. This means you can just download the source and look through the relevant pieces of code.

[Marlin](https://github.com/MarlinFirmware/Marlin) is the most obvious example.


---

### Answer by username_4 on 2017-03-10. Score: 0

A stepper motor is different from a typical electric motor. Instead of being "on" or "off", or running a some approximate variable speed, the controller sends a series of pulses to drive the motor one step at a time. This can be driven forward or backwards.

Based on how the motor and machine is designed, the machine will move a tiny amount. If for example, one step moves , say 0.1mm. If you send 150 pulses in the forward direction, the machine will move 15.0mm If you then send another 8 pulses in the reverse direction, the machine will be 14.2mm from the starting point.

To know the absolute position, you need to establish the starting point. Most printers have limit switches at their "home" position. To initialize the position, drive the motor until it hits the switch, and then set position as zero.

Then count the pulses up and down as you send them, you will will keep track of the machine's position.


---

