2
$\begingroup$

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.

$\endgroup$
6
  • 4
    $\begingroup$ 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. $\endgroup$ Commented Jan 26, 2016 at 11:37
  • 1
    $\begingroup$ Try Raspberry Pi or Electrical Engineering. $\endgroup$ Commented Jan 26, 2016 at 11:40
  • $\begingroup$ See also stackoverflow.com/questions/34319469/… $\endgroup$
    – TextGeek
    Commented Jan 26, 2016 at 15:11
  • $\begingroup$ 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! $\endgroup$
    – LuukS
    Commented Jan 26, 2016 at 17:08
  • $\begingroup$ 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. $\endgroup$ Commented Jan 27, 2016 at 5:51

0

Browse other questions tagged .