PropWare  3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Public Types | Public Member Functions | Static Public Attributes | List of all members
PropWare::Stepper Class Reference

4-pin bipolar and 5-pin unipolar stepper motor driver More...

#include <PropWare/motor/stepper.h>

+ Collaboration diagram for PropWare::Stepper:

Public Types

enum  Step {
  HALF,
  ONE,
  ONE_AND_A_HALF,
  TWO,
  TWO_AND_A_HALF,
  THREE,
  THREE_AND_A_HALF,
  FOUR
}
 

Public Member Functions

 Stepper (const Pin::Mask phase1Mask, const Pin::Mask phase2Mask, const Pin::Mask phase3Mask, const Pin::Mask phase4Mask, const Step start=DEFAULT_START_STEP)
 Constructor. More...
 
void step_to (const Stepper::Step step)
 Move the motor directly to the specified step. More...
 
Step get_current_step () const
 Get the current step. More...
 
bool full_power_hold (const bool direction, const unsigned int usDelay=DEFAULT_DELAY)
 Step the motor to the nearest half-step to achieve a full-power hold. More...
 
bool half_power_hold (const bool direction, const unsigned int usDelay=DEFAULT_DELAY)
 Step the motor to the nearest full-step to achieve a half-power hold. More...
 
void step_forward (unsigned int steps, const unsigned int usDelay=DEFAULT_DELAY)
 Move the motor forward by a specified number of steps. More...
 
void half_forward (unsigned int halfSteps, const unsigned int usDelay=DEFAULT_DELAY)
 Move the motor forward the a specified number of half-steps. More...
 
void step_reverse (unsigned int steps, const unsigned int usDelay=DEFAULT_DELAY)
 Move the motor backward by a specified number of steps. More...
 
void half_reverse (unsigned int halfSteps, const unsigned int usDelay=DEFAULT_DELAY)
 Move the motor backward by a specified number of half-steps. More...
 

Static Public Attributes

static const unsigned int DEFAULT_DELAY = 10000
 Default delay in microseconds used between each step.
 
static const Step DEFAULT_START_STEP = Step::HALF
 

Detailed Description

4-pin bipolar and 5-pin unipolar stepper motor driver

Examples
Stepper_Demo.cpp.

Definition at line 35 of file stepper.h.

Constructor & Destructor Documentation

◆ Stepper()

PropWare::Stepper::Stepper ( const Pin::Mask  phase1Mask,
const Pin::Mask  phase2Mask,
const Pin::Mask  phase3Mask,
const Pin::Mask  phase4Mask,
const Step  start = DEFAULT_START_STEP 
)

Constructor.

Parameters
[in]phase1MaskPin mask connected to phase 1
[in]phase2MaskPin mask connected to phase 2
[in]phase3MaskPin mask connected to phase 3
[in]phase4MaskPin mask connected to phase 4
[in]startWhat step should the motor start with

Definition at line 64 of file stepper.h.

Member Function Documentation

◆ full_power_hold()

bool PropWare::Stepper::full_power_hold ( const bool  direction,
const unsigned int  usDelay = DEFAULT_DELAY 
)

Step the motor to the nearest half-step to achieve a full-power hold.

Parameters
direction[in]True for forward, false for backward
usDelayDelay in microseconds after the step is taken (must be greater than 17 for lmm)
Returns
True if the motor requirement movement to achieve full-power hold, false if the motor was already on a full-power hold

Definition at line 101 of file stepper.h.

+ Here is the call graph for this function:

◆ get_current_step()

Step PropWare::Stepper::get_current_step ( ) const

Get the current step.

Returns
Current step where the motor is holding

Definition at line 88 of file stepper.h.

◆ half_forward()

void PropWare::Stepper::half_forward ( unsigned int  halfSteps,
const unsigned int  usDelay = DEFAULT_DELAY 
)

Move the motor forward the a specified number of half-steps.

Parameters
[in]halfStepsNumber of half-steps to move forward
[in]usDelayDelay in microseconds between half-steps (must be greater than 17 for lmm)

Definition at line 153 of file stepper.h.

+ Here is the caller graph for this function:

◆ half_power_hold()

bool PropWare::Stepper::half_power_hold ( const bool  direction,
const unsigned int  usDelay = DEFAULT_DELAY 
)

Step the motor to the nearest full-step to achieve a half-power hold.

Parameters
direction[in]True for forward, false for backward
usDelayDelay in microseconds after the step is taken (must be greater than 17 for lmm)
Returns
True if the motor requirement movement to achieve half-power hold, false if the motor was already on a half-power hold

Definition at line 121 of file stepper.h.

+ Here is the call graph for this function:

◆ half_reverse()

void PropWare::Stepper::half_reverse ( unsigned int  halfSteps,
const unsigned int  usDelay = DEFAULT_DELAY 
)

Move the motor backward by a specified number of half-steps.

Parameters
[in]halfStepsNumber of half-steps to move backward
[in]usDelayDelay in microseconds between steps (must be greater than 17 for lmm)

Definition at line 183 of file stepper.h.

+ Here is the caller graph for this function:

◆ step_forward()

void PropWare::Stepper::step_forward ( unsigned int  steps,
const unsigned int  usDelay = DEFAULT_DELAY 
)

Move the motor forward by a specified number of steps.

Parameters
[in]stepsNumber of steps to move forward
[in]usDelayDelay in microseconds between steps (must be greater than 17 for lmm)

Definition at line 138 of file stepper.h.

◆ step_reverse()

void PropWare::Stepper::step_reverse ( unsigned int  steps,
const unsigned int  usDelay = DEFAULT_DELAY 
)

Move the motor backward by a specified number of steps.

Parameters
[in]stepsNumber of steps to move backward
[in]usDelayDelay in microseconds between steps (must be greater than 17 for lmm)

Definition at line 168 of file stepper.h.

◆ step_to()

void PropWare::Stepper::step_to ( const Stepper::Step  step)

Move the motor directly to the specified step.

Parameters
step[in]Step to move to

Definition at line 79 of file stepper.h.


The documentation for this class was generated from the following file: