This is the first class on hierarchy. Gives the basic support for the operation of a couple of motors. Implements the movements and allows automatic acceleration and deceleration. It can trigger events when a movement is completed and when a certain number of steps are performed. At this level the step timing is made via software.
Public declaration:
class StepperDuo{ public: // Construction StepperDuo(); // Initialization void begin(uint startSpeed, uint cruiseSpeed); void beginLf(int mPin_1, int mPin_2, int mPin_3, int mPin_4); void beginRg(int mPin_1, int mPin_2, int mPin_3, int mPin_4); void turboOn(); void turboOff(); void halfStepOn(); void halfStepOff(); void setBrakeCutPercent(byte brakeCutPercent); void setReportSteps(long steps); // Operation void run(); void moveSteps(byte mvType, long steps); void moveOn(byte mvType); void stopNow(); void decelStop(); void motorOff(); // Monitoring boolean halfStep(); boolean isMoving(); byte getMoveType(); protected: virtual void onMoveStepsDone(byte mvType, long steps){} virtual void onStepsDone(long steps, long totalSteps){} };
Read first the topics discussed on the Stepper Motors page.
Call begin() before any method to inform startSpeed and cruiseSpeed. Next, call beginLf() and beginRg() methods to inform control pins of stepper motors.
Then select the operation mode of motors (half step, turbo or none).
If needed, configure the brake cut percent calling setBrakeCutPercent().
If you want to receive events when certain number of steps are performed, call setReportSteps() informing the number of steps to trigger the event onStepsDone(). The value zero on steps parameter disable onStepsDone() event.
Dont forget to call run() method at least once per loop.
To start a move, call moveSteps() or moveOn(). moveSteps() execute the number of steps informed and stop (after decelerate). moveOn() causes the movement to continue until some method is called to stop.
To stop the movement immediately call stopNow(). To stop with deceleration call decelStop().
Wiki: StepperCouple
Wiki: StepperMotors
Wiki: StepperSingle
Wiki: StpDuoBuff
Wiki: StpDuoTimer2