Class StepperDouble is the publish class of hierarchy implemented in pStpCouple.h library. Implements several advanced features and allows to perform movements with high precision. There are 11 programmed movements that can be quantified in centimeters or degrees (depending on movement). Movements can also be stored in a buffer and then executed in sequence. It also offers the option of using arduino timer2 for pulse timing. Below some concepts used by library.
void halfStepOn(); void halfStepOff(); void turboOn(); void turboOff();
This library suports 3 diferent modes to operate the stepper motors:
Note: Is not a good ideia switch between half and full step modes after setup. This impairs the movement control of classes. However, you can swicth beetwen turboOn and turboOff modes whenever necessary.
Stepper motors can reach reasonable speeds with relatively high loads (weight), but they can not reach their maximum speed at start if they have to carry a robot. They need to be accelerated gradually to gain inertia.
The class implement automatic acceleration and deceleration, that can be configured by the startSpeed and cruiseSpeed parameters of begin() method. Moves always start at startSpeed and automatically accelerate until they reach cruiseSpeed. At the end of movement the motors are decelerated until reaching startSpeed before stop. The values of these speeds depend on the motor used, but also on the weight of robot. It needs to be reviewed when the robot gains or loses significant weight.
Speeds should be informed in pulses per second.
#define STP_BRAKE_CUT_PERCENT 65 void setBrakeCutPercent(byte brakeCutPercent);
Turn movements require one of the wheels to be in brake state, ie with the coils on but not moving. Brake movement put both motors in brake state. This is a necessary situation to obtain accurate movement and emergency stops, but potentially dangerous. Causes current consumption to increase greatly and heats the motor and the driver board. If maintained for a long time, it may burn one of them. To protect the hardware and reduce energy consumption, whenever enters that state, the motor is turned off for some time at the end of each step. For example, if the pulse has a duration of 1000 microseconds and the cutoff percentage is 75%, the coils will be switched on for 750 microseconds and turned off the remaining 250. The STP_BRAKE_CUT_PERCENT define (pStpMotor.h) gives a default value, but the cutoff percentage can be setted by setBrakeCutPercent() method.
Here are listed the movements implemented by the classes:
#define mv_Off 0 #define mv_Ahead 1 #define mv_Back 2 #define mv_Brake 3 #define mv_SpinLf 4 #define mv_SpinRg 5 #define mv_TurnLf 6 #define mv_TurnRg 7 #define mv_TurnBkLf 8 #define mv_TurnBkRg 9 #define mv_CurveLf 10 #define mv_CurveRg 11
The movements can be expressed in centimeters, degrees or pulses. For the mv_Ahead and mv_Back movements the moveParam parameter means centimeters. For spin, turn, and curve movements, moveParam is expressed in degrees. Finally, for the mv_Brake move, moveParam indicates the number of pulses.
#define STP_USE_TIMER2
The pulses for motors can be timed by arduino timer2 or by software. Using the timer2 makes timing more accurate and independent of the main loop processing. Thus, an eventual overprocessing in the main loop does not interfere with the robot movement. If you prefer not to use the timer2, just comment define STP_USE_TIMER2 and the timing will be done by software.
Wiki: StepperCouple
Wiki: StepperDuo
Wiki: StepperSingle
Wiki: StpDuoBuff
Wiki: StpDuoTimer2