A Command-Line Stepper Library with All the Frills

When you already know exactly where and how you’d like your motor to behave, a code-compile-flash-run-debug cycle can work just fine. But if you want to play around with a stepper motor, there’s nothing like a live interface. [BrendaEM]’s RDL is a generic stepper motor driver environment that you can flash into an Arduino. RDL talks to your computer or cell phone over serial, and can command a stepper-driver IC to move the motor in three modes: rotary, divisions of a circle, and linear. (Hence the acronumical name.) Best of all, the entire system is interactive. Have a peek at the video below.

The software has quite a range of capabilities. Typing “?” gets you a list of commands, typing “@” tells you where the motor thinks it is, and “h” moves the motor back to its home position. Rotating by turns, degrees, or to a particular position are simple. It can also read from an analog joystick, which will control the rotation speed forward and backward in real time.

Division mode carves the pie up into a number of slices, and the motor spins to these particular locations. Twelve, or sixty, divisions gives you a clock, for instance. Acceleration and deceleration profiles are built in, but tweakable. You can change microstepping on the fly, and tweak many parameters of the drive, and then save all of the results to EEPROM. If you’re playing around with a new motor, and don’t know how quickly it can accelerate, or what speeds it’s capable of, nothing beats playing around with it interactively.

Right now, there’s not much documentation aside from the code itself and the attached video, but actually that looks like all you’d need to get started. So if you’re looking to replicate Hackaday’s [Moritz Walter]’s excellent stepper-driver shootout, a tool like this is just the ticket.

30 thoughts on “A Command-Line Stepper Library with All the Frills

        1. If you squint (with your imaginary eye, think Mad Eye Moody), sinusoidal *is* exponential.

          On a more practical note, you want curves which lead from one still-stand (i.e. zero derivative) to another, and there exponential lose (they have no zero derivatives, not in the real realm) and sinusoidals win.

          If you want continuous derivatives up to arbitrary orders (from/to stillstand), as has been mentioned downthread, check the bump function[1]. For interesting alternatives (e.g. linearly changing acceleration) there are clothoids [2], [3].

          But sinusoidal is fine here.

          [1] https://en.wikipedia.org/wiki/Bump_function
          [2] https://en.wikipedia.org/wiki/Euler_spiral
          [3] https://en.wikipedia.org/wiki/Vertical_loop

    1. Hi,

      Properly tuned, sinusoidal acceleration should be smoother than linear acceleration in most cases.

      I was talking to a mathematician this week, who mentioned another which would be better yet, but the code would be slower to execute.

  1. I worked in a very simple class to drive steppers with Raspberry Pi via commandline (backend made in python), the class only move the motor in steps (you specify the target steps), any one have interest in this? to upload some info

  2. I have a box full of commercial stepper servos like this. They have an ascii protocol and modbus. Also support sinusoidal acceleration. There’s a scripting support, so they can run small programs independently. But they are not perfect, there are some limitattion. I’m waiting for spare parts and i’m planning on either enhancing them (or atleast few of them) somehow (would probably have to recreate the program) or replacing the controller completely.

  3. Thanks! I’ve got a bunch of Arduinos and stepper driver boards to go with them. This should be very handy for testing. In general I prefer forth for this sort of task, but I’ve not messed with a forth for the Arduino boards yet.

      1. Thanks you : ) Though, seeing that my main computer is off for repair, I am focusing on tracking down bugs and use cases from feedback. I should find some local Arduino community around here and ask for testing help. Well, I did the best I could.

  4. please don’t be offended @BrendaEM but I had a little test with this software and it is buggy AF.

    arduinoide serial monitor, putty, termite … all the same (RDL V2 , arduino nano v3)
    -motor start stop a few steps in random time
    -menu items not showing up, or blank space
    -setendat writes to setstartat eeprom

    and no writen manual (videomanual for half hour? really?)

    so maybe it works for you, but not a rapid tool for public, grbl FTW (time and machine safety)

  5. The manual is in the comments is the beginning of the sketch, ss far as setup. It has to be matched to your hardware to work.

    There are no menus in RDL. It is a command line helper program. Would you not knowbthat if you saw the video?

    As far as setendat, I will double check it. I fixed that, but perhaps, dropbox versioning had problems.

    In V1 of RDL, I made 2 wrong asumptions about how people would hook up their hardware.

  6. Off the top of my head, I am not seeing how the two Ends could be swapped. I will look at it soon.

    // Set Start At / Set End At
    else if ( command == “setendat” || command == “setstartat” )
    // Stash Variable so line_input Can Be Used.
    command_copy = command;

    if ( command_copy == “setendat”)
    Serial.print (F (“RDL\\setendat [” ) );
    Serial.print ( setting.limit_end );
    Serial.print (F (“RDL\\setstartat [” ) );
    Serial.print ( setting.limit_start );

    // Line Input
    line_input (“]: “);

    location_requested = command.toFloat();
    if ( location_requested range_movement_high )
    Serial.println ( msg_error_limitrange );
    if ( command_copy == “setendat”)
    setting.limit_end = location_requested;
    setting.limit_start = location_requested;

    Serial.println ( msg_locationset );

    // Write to EEPROM
    EEPROM.put ( 0, setting );
    Serial.println ( msg_eeprom_wrote );
    command = command_done;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s