<p>I am working on a Python code (below) that accelerates a stepper motor until it reaches a specific amount of steps.</p>

<pre><code>for s in range (steps):
if s &lt; accelerationsteps:
    lateststep = self.onestep(direction, stepstyle)
    time.sleep(s_per_s)
    s_per_s = s_per_s - ((astart - aend) / accelerationsteps)
</code></pre>

<p>s_per_s = time in between each step</p>

<p>astart = starting speed in second/step (for example 0.5)</p>

<p>aend = speed at which the acceleration should stop (for example 0.05)</p>

<p>accelerationsteps = amount of steps over which the acceleration should happen</p>

<p>The problem is that the velocity increases in <strong>step per second per step</strong> instead of <strong>step per second per second</strong>, and is therefore increased exponentially instead of linear. I have found <a href="http://www.atmel.com/images/doc8017.pdf" rel="nofollow" title="article">this</a> article that explains in mathematical terms how one can achieve a linear increase with a stepper motor but I have not managed to translate that into my python code.</p>

<p>I would highly appreciate it if someone could help me with this and I think it would be very useful for people using steppers on the Raspberry Pi in general (I have only found a solution for the Arduino <a href="http://www.airspayce.com/mikem/arduino/AccelStepper/" rel="nofollow" title="Accelstepper">here</a></p>

<p>Thank you very much in advance.</p>

CC BY-SA 4.0
2018-07-11T21:35:57.170Z
FWIW, question asked on SO: [Stepper motor linear acceleration](https://stackoverflow.com/questions/34319469/stepper-motor-lineair-acceleration-python)
Greenonline
CC BY-SA 3.0
2016-01-26T11:37:29.280Z
I'm voting to close this question as off-topic because "*using steppers on the Raspberry Pi in general*" is not within the scope of this site.
the third dimension
CC BY-SA 3.0
2016-01-26T11:40:10.133Z
Try [raspberrypi.SE] or [electronics.SE].
the third dimension
CC BY-SA 3.0
2016-01-26T15:11:41.930Z
See also http://stackoverflow.com/questions/34319469/stepper-motor-lineair-acceleration-python/34322201#34322201
TextGeek
CC BY-SA 3.0
2016-01-26T17:08:03.073Z
Thank you for the comments, sorry I should have posted a link to the original question. Someone advised me to ask this question here. I'll have a look at the Raspberry Pi or Electrical Engineering sites. Cheers!
LuukS
CC BY-SA 3.0
2016-01-27T05:51:38.367Z
There are no good 3d printer controllers running directly on the Pi, but for Python implementation of stepper acceleration control, you may want to look at the Redeem code for Replicape.
Ryan Carlyle
<stepper><motor><acceleration><python><raspberry-pi>
Stepper Motor Linear Acceleration Python (raspberry pi)
LuukS
# Stepper Motor Linear Acceleration Python (raspberry pi)

(Asked by: username_0 on 2016-01-26)

I am working on a Python code (below) that accelerates a stepper motor until it reaches a specific amount of steps.
for s in range (steps):
if s < accelerationsteps:
    lateststep = self.onestep(direction, stepstyle)
    time.sleep(s_per_s)
    s_per_s = s_per_s - ((astart - aend) / accelerationsteps)

s_per_s = time in between each step
astart = starting speed in second/step (for example 0.5)
aend = speed at which the acceleration should stop (for example 0.05)
accelerationsteps = amount of steps over which the acceleration should happen
The problem is that the velocity increases in step per second per step instead of step per second per second, and is therefore increased exponentially instead of linear. I have found this article that explains in mathematical terms how one can achieve a linear increase with a stepper motor but I have not managed to translate that into my python code.
I would highly appreciate it if someone could help me with this and I think it would be very useful for people using steppers on the Raspberry Pi in general (I have only found a solution for the Arduino here
Thank you very much in advance.

**Tags:** stepper, motor, acceleration, python, raspberry-pi
> **Comments:**
> **username_2**: I'm voting to close this question as off-topic because "*using steppers on the Raspberry Pi in general*" is not within the scope of this site.  
> **username_2**: Try [raspberrypi.SE] or [electronics.SE].  
> **username_3**: See also http://stackoverflow.com/questions/34319469/stepper-motor-lineair-acceleration-python/34322201#34322201  
> **username_0**: Thank you for the comments, sorry I should have posted a link to the original question. Someone advised me to ask this question here. I'll have a look at the Raspberry Pi or Electrical Engineering sites. Cheers!  
> **username_4**: There are no good 3d printer controllers running directly on the Pi, but for Python implementation of stepper acceleration control, you may want to look at the Redeem code for Replicape.  
> **username_1**: FWIW, question asked on SO: [Stepper motor linear acceleration](https://stackoverflow.com/questions/34319469/stepper-motor-lineair-acceleration-python)  

---

## 0 answers

