예제 #1
0
void MiniStepper::step(long steps)
{
	long absSteps = abs(steps);
	byte stepDirection = (steps<0 ? -1 : 1);
	for (long i=0; i<absSteps; i+=stepDirection) {
		incrementStep(stepDirection);
		executeStep();
	}
}
예제 #2
0
bool StepperMotor::moveOneStepForward()
{
	if (!interrupt)
	{
		stepIdx = incrementStep(stepIdx);
		moveOneStep(stepIdx);
	}
	
	return interrupt;
}
예제 #3
0
bool StepperMotor::moveOneStepBackward()
{
	if (!interrupt)
	{
		stepIdx = incrementStep(stepIdx);
		moveOneStep(NUMBER_OF_STEPS - stepIdx - 1);
	}
	
	return interrupt; 
}
예제 #4
0
void MiniStepper::step(long steps)
{
	startIdleHold(); // engage all pins at this stage, so we can do incremental updates
	long absSteps = abs(steps);
	int stepDirection = (steps<0 ? -1 : 1);
	unsigned long startTime;
	unsigned long sleepTime;
	for (long i=0; i<absSteps; i++) {
		startTime = micros();
		incrementStep(stepDirection);
		if (stepDirection > 0) {
			executePositiveStep();
		} else {
			executeNegativeStep();
		}
		delayMicroseconds(stepMicros - (startTime - micros())); // Always doing subtraction calculations to make sure we don't have weird rollover incidents.
	}
	
}