Exemplo n.º 1
0
/**
 * \par Function
 *    moveTo
 * \par Description
 *    Stepper moves to the aim.
 * \param[in]
 *    absolute - The absolute length to Stepper's movement.
 * \par Output
 *    None
 * \par Return
 *    None
 * \par Others
 *    None
 */
void MeStepper::moveTo(long absolute)
{
  if (_targetPos != absolute)
  {
    _targetPos = absolute;
    computeNewSpeed();
  }
}
Exemplo n.º 2
0
boolean MeStepper::run()
{
    if (_targetPos == _currentPos)
	return false;
    
    if (runSpeed())
	computeNewSpeed();
    return true;
}
Exemplo n.º 3
0
void moveTo(Stepper_t* motor, long absolute)
{
    if (motor->_targetPos != absolute)
    {
    	motor->_targetPos = absolute;
		computeNewSpeed(motor);
		// compute new n?
    }
}
Exemplo n.º 4
0
void AccelStepper::moveTo(long absolute)
{
    if (_targetPos != absolute)
    {
	_targetPos = absolute;
	computeNewSpeed();
	// compute new n?
    }
}
Exemplo n.º 5
0
void AsyncDriver::setMaxSpeed(float speed){
	//uint8_t oldSREG = SREG;
//	noInterrupts();
	if (_maxSpeed != speed){
		_maxSpeed = speed;
		_cmin = 1000000.0 / speed;
		if (_n > 0){					// Recompute _n from current speed and adjust speed if accelerating or cruising
			_n = (long)((_speed * _speed) / (2.0 * _acceleration)); // Equation 16
			computeNewSpeed(true);
		}
	}
//	SREG = oldSREG;
}
Exemplo n.º 6
0
/**
 * \par Function
 *    run
 * \par Description
 *    Stepper's status----run or not.
 * \param[in]
 *    None
 * \par Output
 *    None
 * \par Return
 *    Return the status.
 * \par Others
 *    None
 */
boolean MeStepper::run()
{
  if((_speed == 0.0) || (distanceToGo() == 0))
  {
    return false;
  }

  if (runSpeed())
  {
	computeNewSpeed();
    return true;
  }
}
Exemplo n.º 7
0
void setAcceleration(Stepper_t* motor, float acceleration)
{
    if (acceleration == 0.0)
	return;
    if (motor->_acceleration != acceleration)
    {
	    // Recompute _n per Equation 17
    	motor->_n = motor->_n * (motor->_acceleration / acceleration);
		// New c0 per Equation 7, with correction per Equation 15
    	motor->_c0 = 0.676 * sqrt(2.0 / acceleration) * 1000000.0;// Equation 15
    	motor->_acceleration = acceleration;
		computeNewSpeed(motor);
    }
}
Exemplo n.º 8
0
void setMaxSpeed(Stepper_t* motor, float speed)
{
    if (motor->_maxSpeed != speed)
    {
    	motor->_maxSpeed = speed;
    	motor->_cmin = 1000000.0 / speed;
		// Recompute _n from current speed and adjust speed if accelerating or cruising
		if (motor->_n > 0)
		{
			motor->_n = (long)((motor->_speed * motor->_speed) / (2.0 * motor->_acceleration)); // Equation 16
			computeNewSpeed(motor);
		}
    }
}
Exemplo n.º 9
0
void AccelStepper::setAcceleration(float acceleration)
{
    if (acceleration == 0.0)
	return;
    if (_acceleration != acceleration)
    {
	// Recompute _n per Equation 17
	_n = _n * (_acceleration / acceleration);
	// New c0 per Equation 7
	_c0 = sqrt(2.0 / acceleration) * 1000000.0;
	_acceleration = acceleration;
	computeNewSpeed();
    }
}
Exemplo n.º 10
0
void AccelStepper::setMaxSpeed(float speed)
{
    if (_maxSpeed != speed)
    {
	_maxSpeed = speed;
	_cmin = 1000000.0 / speed;
	// Recompute _n from current speed and adjust speed if accelerating or cruising
	if (_n > 0)
	{
	    _n = (long)((_speed * _speed) / (2.0 * _acceleration)); // Equation 16
	    computeNewSpeed();
	}
    }
}
Exemplo n.º 11
0
/**
 * \par Function
 *    setAcceleration
 * \par Description
 *    Set Acceleration for Stepper.
 * \param[in]
 *    acceleration - The acceleration for Stepper.
 * \par Output
 *    None
 * \par Return
 *    None
 * \par Others
 *    None
 */
void MeStepper::setAcceleration(float acceleration)
{
  if(acceleration == 0.0)
  {
    return;
  }
  if(_acceleration != acceleration)
  {
    _n = _n * (_acceleration / acceleration);
    //	_c0 = sqrt(2.0 / acceleration) * 1000000.0;
    // Accelerates at half the expected rate. Why?
    _c0 = sqrt(1.0/acceleration) * 1000000.0;
    _acceleration = acceleration;
    computeNewSpeed();
  }
}
Exemplo n.º 12
0
void AsyncDriver::moveTo(long absolute){
	uint8_t oldSREG = SREG;
	noInterrupts();
	if ( _targetPos == absolute ){
		if( _targetPos ==_currentPos){
			onReady();
		}
	}else{
		if( disable_on_ready && is_disabled ){
			enableOutputs();
		}
		_targetPos = absolute;
		computeNewSpeed(true);
	}
	SREG = oldSREG;
}
Exemplo n.º 13
0
boolean AccelStepper::runStepBuffer()
{
	if (!is_full(_step_buffer))
	{
		if (_stepInterval == 0)
		{
			computeNewSpeed();
			if (_stepInterval != 0)
			{
				_halfstepInterval = _stepInterval/2;
				_stepInterval -= _halfstepInterval;
				if (_direction == DIRECTION_CW)
				{
					// Clockwise
					_currentPos += 1;
				}
				else
				{
					// Anticlockwise
					_currentPos -= 1;
				}
			}
			else
				return 0;
		}

		if (_halfstepInterval != 0)
		{
			pushStep(_halfstepInterval);
		}
		else if (_stepInterval != 0)
		{
			pushStep(_stepInterval);
		}

	}
	return 1;
}
Exemplo n.º 14
0
// Run the motor to implement speed and acceleration in order to proceed to the target position
// You must call this at least once per step, preferably in your main loop
// If the motor is in the desired position, the cost is very small
// returns true if the motor is still running to the target position.
uint8_t run(Stepper_t* motor)
{
    if (runSpeed(motor)) computeNewSpeed(motor);

    return motor->_speed != 0.0 || distanceToGo(motor) != 0;
}
Exemplo n.º 15
0
// Run the motor to implement speed and acceleration in order to proceed to the target position
// You must call this at least once per step, preferably in your main loop
// If the motor is in the desired position, the cost is very small
// returns true if the motor is still running to the target position.
boolean AccelStepper::run()
{
	if (runSpeed())
		computeNewSpeed();
	return ((_speed != 0.0) || (distanceToGo() != 0));
}
Exemplo n.º 16
0
void MeStepper::setAcceleration(float acceleration)
{
    _acceleration = acceleration;
    computeNewSpeed();
}
Exemplo n.º 17
0
void AccelStepper::moveTo(long absolute)
{
    _targetPos = absolute;
    computeNewSpeed();
}
Exemplo n.º 18
0
// Run the motor to implement speed and acceleration in order to proceed to the target position
// You must call this at least once per step, preferably in your main loop
// If the motor is in the desired position, the cost is very small
// returns true if we are still running to position
void AsyncDriver::run(){
	if (haveToRun()){
		computeNewSpeed(false);
	}
}
Exemplo n.º 19
0
// Run the motor to implement speed and acceleration in order to proceed to the target position
// You must call this at least once per step, preferably in your main loop
// If the motor is in the desired position, the cost is very small
// returns true if we are still running to position
bool AccelStepper::run()
{
    if (runSpeed())
	computeNewSpeed();
    return true;
}
Exemplo n.º 20
0
// Useful during initialisations or after initial positioning
void AccelStepper::setCurrentPosition(long position)
{
    _targetPos = _currentPos = position;
    computeNewSpeed(); // Expect speed of 0
}
Exemplo n.º 21
0
// Run the motor to implement speed and acceleration in order to proceed to the target position
// You must call this at least once per step, preferably in your main loop
// If the motor is in the desired position, the cost is very small
// returns true if the motor is still running to the target position.
boolean AccelStepper::run()
{
    if (runSpeed())
	computeNewSpeed();
    return _speed != 0.0 || distanceToGo() != 0;
}
Exemplo n.º 22
0
void MeStepper::setMaxSpeed(float speed)
{
    _maxSpeed = speed;
    computeNewSpeed();
}
Exemplo n.º 23
0
void AccelStepper::setAcceleration(float acceleration)
{
    _acceleration = acceleration;
    _sqrt_twoa = sqrt(2.0f * _acceleration);
    computeNewSpeed();
}