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.

Tormod Haugene
  • 3,947
  • 2
  • 20
  • 40
LuukS
  • 21
  • 1
  • 2
  • 4
    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 Jan 26 '16 at 11:37
  • 1
    Try [raspberrypi.SE] or [electronics.SE]. – the third dimension Jan 26 '16 at 11:40
  • See also http://stackoverflow.com/questions/34319469/stepper-motor-lineair-acceleration-python/34322201#34322201 – TextGeek Jan 26 '16 at 15:11
  • 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 Jan 26 '16 at 17:08
  • 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 Jan 27 '16 at 05:51
  • FWIW, question asked on SO: [Stepper motor linear acceleration](https://stackoverflow.com/questions/34319469/stepper-motor-lineair-acceleration-python) – Greenonline Jul 11 '18 at 21:35

0 Answers0