Forum

Controlling a stepper motor

looking into ways to control a stepper motor from vvvv in the following setup:
motor nema-17-17hs8401, controller allegro a4988, arduino mega 2560

lacking the knowledge to custom code the arduino so i was hoping to get away with manually banging 1/16 microsteps from vl.firmata

this is not going step-precise, after a few series of steps the counter is off
stepper from vl-firmata.v4p (30.6 KB)

what would be the best option to go ahead ?

  • adapting the stepper code from vvvv+motors but no clue where the differences in code may lie
  • using the microcontroller reset periodically
  • looking into other microcontroller tweaks that might sync steps to vvvv bangs

Hi @ggml,

steppers are special and we don’t support them currently in vl.firmata.
I guess, the best way is to adapt the vvvv+motors from @kleinkariert.

Best,
Anton

should the code by @kleinkariert work out of the box for allegro a4988 ?

vvvv+motors contains a pattch, ino code and pdf

patch says to use driver a4988
pdf diagram shows how to connect driver a4988 (2 pins)
however,
ino code says it is ment for direct control of the motor (4 pins)

so it this contribution for 2pins+driver or 4pins+direct control ?

hey @ggml

i never tried this contribution, but from what i see it is indeed confusing. it is like you assumed: when using a driver chip like the one mentioned, 2 pins should suffice. only when controlling the motor directly you need 4 pins.

i’d also have a look at this library (instead of the standard stepper lib): https://www.airspayce.com/mikem/arduino/AccelStepper/
it’s quite sophisticated with its accelleration behaviour and works in all possible configurations (directly (4 pins) or with driver (2pin)).