Stepper Motor Linear Acceleration Python (raspberry pi)

2

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.

LuukS

Posted 2016-01-26T10:28:13.417

Reputation: 21

Question was closed 2016-01-26T21:12:58.770

4I'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 – 2016-01-26T11:37:29.280

1Try [raspberrypi.SE] or [electronics.SE]. – the third dimension – 2016-01-26T11:40:10.133

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 – 2016-01-26T17:08:03.073

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 – 2016-01-27T05:51:38.367

FWIW, question asked on SO: Stepper motor linear acceleration

– Greenonline – 2018-07-11T21:35:57.170

No answers