Arduino Playground is read-only starting December 31st, 2018. For more info please look at this Forum Post

Library for Arduino
Author:  Francesco Artur Perrotti
Contact: faperrotti@hotmail.com

Stepper Robot lib

This library implements a class that takes care to synchronize two stepper motors to produce programmed motions. All methods are non-blocking and library works with unipolar or bipolar stepper motors. Advanced features were implemented for vibration reduction, energy saving and protection of control circuits.

The library intents to generate signals to ULN2003/2803 based boards or equivalent circuit to drive unipolar motors and also boards with double h-bridge to drive bipolar motors. These boards do not have the advanced features that are typically found in boards like Easy Driver or Pololu boards based on A4988. So, this library try provide a better and safe control with no hardware resources.

Features

  • Extremely precise movements.
  • Non-blocking methods.
  • Works with bipolar or unipolar motors.
  • Automatic acceleration and deceleration.
  • Allows storing movement commands in a buffer so they run in sequence.
  • Advanced capabilities for vibration control at low speeds.
  • Supports half-step and full-step mode with one or two coils.
  • Uses Timer 1 to control the pulse's timing.
  • Do not need a service function that is often called from the main loop.

Note: This version uses TimerOne library to control the timer. This library is not included on package but you can download from Timer1 page.

Download

Stepper Robot 1.02

Documentation / reference

https://code.google.com/p/stepper-robot-arduino-lib/wiki/Reference (english) https://fperrotti.wikispaces.com/Stepper+Lib+Arduino (portuguese).

Below the class as seen by the application.

 
class StepperRobot{
public:
   // setup
   void init(int startSpeed, int cruiseSpeed, int pulsesToCruise);
   void initLeftMotor(int mPin_1, int mPin_2, int mPin_3, int mPin_4);
   void initRightMotor(int mPin_1, int mPin_2, int mPin_3, int mPin_4);

   // Movements
   boolean move(char movType, int pulses);
   boolean isMoving();
   void decelStop();
   void stopNow();

   // Bufferized movements
   boolean addMove(int movType, int pulses);
   void goNow();
   void stopAndClear();

   // Config
   void turboOn();
   void turboOff();
   void halfStepOn();
   void halfStepOff();
   void setCutPercent(float initialCutPercent)
};

And here the move types implemented

 
#define mvAhead    0
#define mvBack     1
#define mvSpinL    2
#define mvSpinR    3
#define mvTurnL    4
#define mvTurnR    5
#define mvBkTurnL  6
#define mvBkTurnR  7
#define mvBrake    8

Video

A video with a simple robot testing this movements can be seen here (YouTube).

Google Code

If you want to help to improve this lib, please join the project at Google Code: https://code.google.com/p/stepper-robot-arduino-lib/

Discussion

There is a thread in forum for discussions, suggestions, bug reports, etc.

I hope you enjoy this lib.

regards,

Perrotti