Skip to content
Maslov Nikita edited this page Jan 6, 2014 · 19 revisions

Note that library use one pre-declared object, StepperDriver (it looks like usage of Serial in Arduino).

Functions

void init ()

Run this function once in the setup(). It performs initialization of hardware timer.

Arguments: No arguments.

Return value: Nothing.

Example:

void setup() {
  StepperDriver.init();
}

axis_t newAxis (int step, int dir, [int enable])

Creates new axis which uses pins from arguments list. Returns the index of newly registered axis, you need to save it for control.

Arguments:

  • int step: number of pin where STEP signal for axis is connected;
  • int dir: number of pin where DIR signal is connected;
  • int enable (optional): number of pin where ENABLE signal is connected (if driver has it).

_Return value: axis_t, index of registered axis.

Example:

axis_t my_motor;

void setup() {
  StepperDriver.init();
  my_motor = StepperDriver.newAxis(1, 2, 3);
}

void enable (axis_t axis)

Enable the axis on driver level (if driver has an ENABLE channel for the axis).

Arguments: axis_t axis - index of axis to enable.

Return value: Nothing.

Example:

axis_t my_motor;

void setup() {
  ... /* initialization */
  StepperDriver.enable(my_motor);
}

void disable (axis_t axis)

Disable the axis on driver level (if driver has an ENABLE channel for the axis).

Arguments: axis_t axis - index of axis to disable.

Return value: Nothing.

Example:

axis_t my_motor;

... /* initialization */

void loop() {
  ... /* some profitful work */
  if (need_to_disable)
    StepperDriver.disable(my_motor);
}

void setDir (axis_t axis, int dir)

Set rotation direction for this axis (variants are defined: FORWARD and BACKWARD).

Arguments:

  • axis_t axis: index of axis to set direction;
  • int dir: FORWARD or BACKWARD

Return value: Nothing.

Example:

axis_t my_motor;

... /* initialization */

void loop() {
  StepperDriver.setDir(my_motor, FORWARD);
  ...
  StepperDriver.setDir(my_motor, BACKWARD);
}

Clone this wiki locally