Armand Coetzer / Stepper
Embed: (wiki syntax)

« Back to documentation index

Stepper Class Reference

Stepper Class Reference

Class library for a Stepper Motor to be able to Select amount of steps,set the time interval between steps, run stepper motor freely and stop the stepper motor. More...

#include <Stepper.h>

Public Member Functions

 Stepper (PinName Coil1, PinName Coil2, PinName Coil3, PinName Coil4)
 Create a Stepper motor object connected to the specified pins.
void Run ()
 Makes the stepper run continuously.
void Stop ()
 To make stepper stop.
void Direction (bool dir)
 Setting direction of the stepper motor, Clockwise or Anticlockwise.
void Interval (float sec)
 Choosing time interval between steps(control speed).
void Step (int steps)
 Selct amount of steps the stpper motor should turn.

Detailed Description

Class library for a Stepper Motor to be able to Select amount of steps,set the time interval between steps, run stepper motor freely and stop the stepper motor.

Example:

 #include "mbed.h"                                           //include the mbed APIs and other libraries
 #include "Stepper.h"                                        //include the Stepper librariy

 Stepper stepper (PE_4, PE_5, PE_6, PE_7);                   //Initialize bus pins

 int main() 
 {

    while(1)                                               //Enter infinite while loop
    {
       stepper.Interval(0.1);                              //Choosing time interval between steps(control speed)
       stepper.Direction(true);                            //Choosing direction. true = Clockwise, false = Anticlockwise
       stepper.Run();                                      //Makes the stepper run continuously
       wait(5);                                            //mbed's wait function, wait 5 sec.
       stepper.Direction(false); 
       wait(5);   
       stepper.Stop();                                     //To make stepper stop
       wait(5);     
    }                   
 }

Definition at line 57 of file Stepper.h.


Constructor & Destructor Documentation

Stepper ( PinName  Coil1,
PinName  Coil2,
PinName  Coil3,
PinName  Coil4 
)

Create a Stepper motor object connected to the specified pins.

Parameters:
coil1MCU Output Pin for coil1.
coil2MCU Output Pin for coil2.
coil3MCU Output Pin for coil3.
coil4MCU Output Pin for coil4.

Definition at line 4 of file Stepper.cpp.


Member Function Documentation

void Direction ( bool  dir )

Setting direction of the stepper motor, Clockwise or Anticlockwise.

Parameters:
booleanslection to select direction. true = Clockwise, false = Anticlockwise

Definition at line 42 of file Stepper.cpp.

void Interval ( float  sec )

Choosing time interval between steps(control speed).

Parameters:
Afloat value to set the time between steps.
Returns:
None

Definition at line 54 of file Stepper.cpp.

void Run (  )

Makes the stepper run continuously.

Parameters:
None

Definition at line 21 of file Stepper.cpp.

void Step ( int  steps )

Selct amount of steps the stpper motor should turn.

Parameters:
intergervalue to select the amount of steps.
Returns:
None

Definition at line 64 of file Stepper.cpp.

void Stop (  )

To make stepper stop.

Parameters:
None

Definition at line 34 of file Stepper.cpp.