Page 1 of 1

Stepper motor module

Posted: Tue Mar 07, 2017 7:24 am
by filipmar.mf
Hi,
there is my module for Stepper motor driven by Adafruit Easy driver.
https://github.com/Euter2/MicroPython/b ... stepper.py

Your feedback is welcome ;)

Re: Stepper motor module

Posted: Fri Aug 25, 2017 1:42 pm
by sjp770
Looks good, is there doco on how to use it? I'm still new to micropython.

Re: Stepper motor module

Posted: Mon Aug 28, 2017 7:29 am
by pythoncoder
That's a useful driver. For anyone puzzled (as I was) Easy Driver is this nice piece of hardware: https://www.sparkfun.com/products/12779.

An asynchronous version of the driver would be an interesting project. It could use a timer interrupt or uasyncio to achieve nonblocking behaviour. The drawback would be a substantially lower maximum step rate, especially on the ESP8266.

Re: Stepper motor module

Posted: Thu Aug 31, 2017 3:09 am
by sjp770
My driver is a more common Polou A4988, (https://www.pololu.com/product/1182) Any idea if it would work with this or if there is a way to control it yet?

Re: Stepper motor module

Posted: Fri Sep 01, 2017 11:03 pm
by dbc
The drawback would be a substantially lower maximum step rate, especially on the ESP826
Yes, well, say you are using a common 200 steps/rev motor, and 1/4 microstepping, and two edges per step, or 1600 edges to generate per revolution. The OP's code has a 20 uSec minimum time between edges. At 20 uSec minimum time between edges, that is 32 mSec per revolution, or 1875 RPM, which is pretty zippy. (Feel free to look for errors in my math..) So I don't think a slower step rate is a problem for many applications.

Related, since motors have real mass, you can't make them go from 0 RPM to a fast step rate all in one go. It might be nice to add some kind of acceleration ramp parameter to the API.

Re: Stepper motor module

Posted: Mon Dec 04, 2017 7:48 am
by OutoftheBOTS_
Usually most people will use a A4988 or a DRV8825 for controlling small to median stepper motors.
The A4988 was the classic used by most 3dprinters and smaller CNC machines until the DRV8825 came alone with better specs (smaller micro-stepping and higher current) and now is very standard. Both drivers r chopper drivers(constant current driver).

To get good acceleration torque you need to use a chopper driver (standard with all CNC machine)

To get a smooth rotation rather than a chunky stepping motion you need micro stepping the smaller the better usually.

Both these drivers have a step pin and a direction pin. U set the direction pin to high or low for direction of stepping and pulse the step pin to make it take a step. You can drive the step pin with a PWM freq to get a certain speed and you adjust the freq to adjust the speed of the stepping, you will need a counter that counts the pulses if you want to know the rotation amount.

Re: Stepper motor module

Posted: Fri Jun 08, 2018 8:22 am
by pidou46
Hello,

My understanding is that it's impractical to drive the step pulse of a stepper driver (A4988, DRV8825, ect...) directly with an esp (8266 or 32) because of RTOS and Micropython latency.

What do you think of: https://github.com/lhartmann/esp8266_reprap

Instead of connect directly the pins from the esp to the driver, it use a register shifter (74HC595) drived through I2S.

Is this achievable with micropython, does it will allow similar stepper RPM ?

Re: Stepper motor module

Posted: Fri Jun 08, 2018 12:19 pm
by mattyt
My understanding is that it's impractical to drive the step pulse of a stepper driver (A4988, DRV8825, ect...) directly with an esp (8266 or 32) because of RTOS and Micropython latency.
I don't believe this is true on the ESP32 as the PWM is HW-driven using the LEDC module. It should be very accurate. Relvant code is in esp32/machine_pwm.c.

Can anyone confirm? I personally haven't looked at the output on an oscilloscope...

By the way, if you're prepared to stray off mainline MicroPython, the Loboris ESP32 port offers a few other PWM features.