67 const Pin::Mask phase4Mask,
const Step start = ZERO)
68 : m_currentStep(start) {
74 this->m_phase1.
clear();
75 this->m_phase2.
clear();
76 this->m_phase3.
clear();
77 this->m_phase4.
clear();
84 this->set_full_step();
93 void step_forward (
unsigned int steps,
const unsigned int usDelay = DEFAULT_DELAY) {
95 this->m_currentStep = (Step) ((this->m_currentStep + 1) % 4);
96 this->set_full_step();
97 waitcnt(usDelay * MICROSECOND);
107 void step_reverse (
unsigned int steps,
const unsigned int usDelay = DEFAULT_DELAY) {
109 this->m_currentStep = (Step) ((this->m_currentStep + 3) % 4);
110 this->set_full_step();
111 waitcnt(usDelay * MILLISECOND);
119 void set_full_step () {
120 switch (this->m_currentStep) {
122 this->m_phase1.
set();
123 this->m_phase2.
set();
124 this->m_phase3.
clear();
125 this->m_phase4.
clear();
128 this->m_phase1.
clear();
129 this->m_phase2.
set();
130 this->m_phase3.
set();
131 this->m_phase4.
clear();
134 this->m_phase1.
clear();
135 this->m_phase2.
clear();
136 this->m_phase3.
set();
137 this->m_phase4.
set();
140 this->m_phase1.
set();
141 this->m_phase2.
clear();
142 this->m_phase3.
clear();
143 this->m_phase4.
set();
void set_mask(const PropWare::Port::Mask mask)
Utility class to handle general purpose I/O pins.
void step_reverse(unsigned int steps, const unsigned int usDelay=DEFAULT_DELAY)
Move the motor backward by a specified number of steps.
void clear() const
Clear selected output port (set it to 0)
Generic definitions and functions for the Parallax Propeller.
Stepper(const Pin::Mask phase1Mask, const Pin::Mask phase2Mask, const Pin::Mask phase3Mask, const Pin::Mask phase4Mask, const Step start=ZERO)
Constructor.
void set_dir_out() const
Set the port for output.
4-phase stepper motor driver
void step_forward(unsigned int steps, const unsigned int usDelay=DEFAULT_DELAY)
Move the motor forward by a specified number of steps.
static const unsigned int DEFAULT_DELAY
Default delay in microseconds used between each step.
void set() const
Set selected output port high (set all pins to 1)