Exemplo n.º 1
0
/**
 * \par Function
 *    runSpeedAndTime
 * \par Description
 *    The speed and time of Motor's movement.
 * \param[in]
 *    speed - The speed move of Motor.
 * \param[in]
 *    time - The time move of Motor.
 * \param[in]
 *    lock_state - The lock state of Motor.
 * \par Output
 *    None
 * \par Return
 *    None
 * \par Others
 *    None
 */
void MeEncoderNew::runSpeedAndTime(float speed, float time, float lock_state)
{
  if(_lastTime == 0)
  {
    _lastTime = millis();
    runSpeed(speed,lock_state);
  }

  if(millis() - _lastTime > (1000 * time))
  {
    _lastTime = 0;
    runSpeed(0,lock_state);
  }
}
Exemplo n.º 2
0
void MeEncoderNew::runSpeedAndTime(int speed, float time)
{
    if(_lastTime == 0)
    {
        _lastTime = millis();
        runSpeed(speed);
    }

    if(millis() - _lastTime > time)
    {
        _lastTime = 0;
        runSpeed(0);
    }
}
Exemplo n.º 3
0
boolean AccelStepper::runSpeedToPosition()
{
    if (_targetPos >_currentPos)
	_speed = fabs(_speed);
    else
	_speed = -fabs(_speed);
    return _targetPos!=_currentPos ? runSpeed() : false;
}
Exemplo n.º 4
0
boolean MeStepper::run()
{
    if (_targetPos == _currentPos)
	return false;
    
    if (runSpeed())
	computeNewSpeed();
    return true;
}
Exemplo n.º 5
0
boolean AccelStepper::runSpeedToPosition()
{
    if (_targetPos == _currentPos)
	return false;
    if (_targetPos >_currentPos)
	_direction = DIRECTION_CW;
    else
	_direction = DIRECTION_CCW;
    return runSpeed();
}
Exemplo n.º 6
0
uint8_t runSpeedToPosition(Stepper_t* motor)
{
    if (motor->_targetPos == motor->_currentPos)
    	return 0; // false
    if (motor->_targetPos > motor->_currentPos)
    	motor->_direction = DIRECTION_CW;
    else
    	motor->_direction = DIRECTION_CCW;

    return runSpeed(motor);
}
Exemplo n.º 7
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.º 8
0
/**
 * \par Function
 *    runSpeedToPosition
 * \par Description
 *    The speed of Stepper on the way to position.
 * \param[in]
 *    None
 * \par Output
 *    None
 * \par Return
 *    Return true or false.
 * \par Others
 *    None
 */
boolean MeStepper::runSpeedToPosition()
{
  if (_targetPos == _currentPos)
  {
    return false;
  }
  if (_targetPos >_currentPos)
  {
	_dir = DIRECTION_CW;
  }
  else
  {
	_dir = DIRECTION_CCW;
  }
  return runSpeed();
}
/**
 * \par Function
 *    update
 * \par Description
 *    The Stepper loop function, used to move the stepper.
 * \param[in]
 *    None
 * \par Output
 *    None
 * \par Return
 *    None
 * \par Others
 *    None
 */
void MeStepperOnBoard::update(void)
{
  if(_mode == 0)
  {
    runSpeed();
  }
  else
  {
    long dist = distanceToGo();
    if(dist==0)
    {
      if(_moving)
      {
        _moving = false;
        _callback(_slot, _extId);
      }
    }
    runSpeedToPosition();  
  }
}
Exemplo n.º 10
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.º 11
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.º 12
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.º 13
0
boolean AccelStepper::runSpeedToPosition()
{
    return _targetPos!=_currentPos ? runSpeed() : false;
}
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.
boolean AccelStepper::run()
{
	if (runSpeed())
		computeNewSpeed();
	return ((_speed != 0.0) || (distanceToGo() != 0));
}