Accessories
Arduino for motors and lights library.
PortStepper Class Reference

#include "PortStepper.hpp"

Inheritance diagram for PortStepper:
Port

Public Member Functions

 PortStepper ()
 
void begin (uint8_t inPin1, uint8_t inPin2, PIN_TYPE inType = DIGITAL, uint8_t *inpSteps = NULL)
 
void begin (uint8_t inPin1, uint8_t inPin2, uint8_t inPin3, uint8_t inPin4, PIN_TYPE inType = DIGITAL, uint8_t *inpSteps = NULL)
 
void MovePosition (unsigned long inDuration, int inEndPosition)
 
void MoveRelativePosition (unsigned long inDuration, int inIncrementalPosition)
 
bool run ()
 
long currentPosition ()
 
long targetPosition ()
 
int GetPosition ()
 
- Public Member Functions inherited from Port
 Port ()
 
virtual void begin ()
 
virtual void beginByAccessory (int inStartingPosition)
 
PIN_TYPE GetPinType () const
 
PORT_STATE GetState () const
 
int GetSpeed () const
 
virtual int SetSpeed (int inSpeed)
 
bool IsLeftDir () const
 
bool IsRightDir () const
 
bool IsStopped () const
 
virtual void MoveLeftDir (unsigned long inDuration = 0)
 
virtual void MoveRightDir (unsigned long inDuration = 0)
 
void MoveLeftDir (unsigned long inDuration, int inSpeed)
 
void MoveRightDir (unsigned long inDuration, int inSpeed)
 
PORT_STATE MoveToggle (unsigned long inDuration = 0)
 
virtual void MoveStop ()
 

Protected Attributes

LocoStepperpMotor
 
- Protected Attributes inherited from Port
PIN_TYPE pinType
 
PORT_STATE state
 
int speed
 

Additional Inherited Members

- Protected Member Functions inherited from Port
int MapValue (int inValue, PIN_TYPE inType = UNDEFINED) const
 
int beginPin (int inPin, PIN_TYPE inType = UNDEFINED) const
 
void MovePin (int inPin, int inValue, PIN_TYPE inType = UNDEFINED) const
 

Detailed Description

This class can drive a stepper motor, using the LocoStepper class.

Positions are specified by a signed long integer. At construction time, the current position of the motor is consider to be 0. Positive positions are clockwise from the initial position; negative positions are anticlockwise. The current position can be altered for instance after initialization positioning.

See LocoStepper class for more information.

Definition at line 25 of file PortStepper.hpp.

Constructor & Destructor Documentation

PortStepper::PortStepper ( )

Default constructor.

Definition at line 11 of file PortStepper.cpp.

Member Function Documentation

void PortStepper::begin ( uint8_t  inPin1,
uint8_t  inPin2,
PIN_TYPE  inType = DIGITAL,
uint8_t *  inpSteps = NULL 
)

Initialize the instance of two pins stepper motor.

Parameters
inPin1Command pin 1 for the stepper.
inPin2Command pin 2 for the stepper.
inTypekind of all the pins. Can be only DIGITAL or DIGITAL_INVERTED. Default is DIGITAL.
inpStepsspecific step list. Default is NULL. It gives the caller the possibility to fix himself the sequence of pins activation. If nothing is specifed, a default value will be used:
B01, B11, B10, B00.

Definition at line 15 of file PortStepper.cpp.

void PortStepper::begin ( uint8_t  inPin1,
uint8_t  inPin2,
uint8_t  inPin3,
uint8_t  inPin4,
PIN_TYPE  inType = DIGITAL,
uint8_t *  inpSteps = NULL 
)

Initialize the instance for four pins stepper motor.

Parameters
inPin1Command pin 1 for the stepper.
inPin2Command pin 2 for the stepper.
inPin3Command pin 3 for the stepper.
inPin4Command pin 4 for the stepper.
inTypekind of all the pins. Can be only DIGITAL or DIGITAL_INVERTED. Default is DIGITAL.
inpStepsspecific step list. Default is NULL. It gives the caller the possibility to fix himself the sequence of pins activation. If nothing is specifed, a default value will be used:
B1010, B0110, B0101, B1001 for four wires stepper
These steps are those working for a 28BYJ very common and inexpensive small stepper.

Definition at line 20 of file PortStepper.cpp.

long PortStepper::currentPosition ( )
inline

Gets the current position.

Returns
current position.

Definition at line 83 of file PortStepper.hpp.

int PortStepper::GetPosition ( )
inlinevirtual

Gets the current position.

Returns
current position.
Remarks
This function is the same than currentPosition() and is only defined to match Accessory class functions.

Reimplemented from Port.

Definition at line 93 of file PortStepper.hpp.

void PortStepper::MovePosition ( unsigned long  inDuration,
int  inEndPosition 
)
virtual

Move the stepper to the given position using a given duration.

Parameters
inDurationthe movement should take the time of this delay.
inEndPositionfinal position to reach.

Reimplemented from Port.

Definition at line 45 of file PortStepper.cpp.

void PortStepper::MoveRelativePosition ( unsigned long  inDuration,
int  inIncrementalPosition 
)

Move the servo of the given value from the current position using a given duration.

Parameters
inDurationthe movement should take the time of this delay.
inIncrementalPositionposition to move.

Definition at line 57 of file PortStepper.cpp.

bool PortStepper::run ( )
inline

Poll the motor and step it if a step is due. You must call this as frequently as possible, but at least once per minimum step interval, preferably in your main loop.

Returns
true if the motor is still going to the target position.

Definition at line 79 of file PortStepper.hpp.

long PortStepper::targetPosition ( )
inline

Gets the target position.

Returns
target position. This is equal to current position if no movement is goining...

Definition at line 87 of file PortStepper.hpp.

Member Data Documentation

LocoStepper* PortStepper::pMotor
protected

Instance of LocoStepper class.

Definition at line 29 of file PortStepper.hpp.


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