Skip to content

"AccelStepper" can be improved #6

Closed
@jeromefavrou

Description

@jeromefavrou

the "AccelStepper" library can be improved. This one accumulates in time a software error. It can be interesting to mathematically integrate this one. Where the "AccelStepper" lib makes

    unsigned long time = micros();   
    if (time - _lastStepTime >= _stepInterval)
    {
	if (_direction == DIRECTION_CW)
	{
	    _currentPos += 1;
	}
	else
	{
	    _currentPos -= 1;
	}
	step(_currentPos);

	_lastStepTime = time; 
	return true;
    }

I had coded a version with this fix, my lib is much less complete than AccelStepper but takes into account the software error. As a comparison in my lib I did like this . "this->m_ei" is integrate error

unsigned long r_elsp= micros() - this->m_elaps;

        if( (_mv_type == MOVE_TYPE::HALF_STEP ? this->m_inter_delay/2.0 : this->m_inter_delay)  <=r_elsp-this->m_ie)
        {
          this->next_step(_mv_type);
          this->m_elaps = micros();
          this->m_ie += this->m_inter_delay-r_elsp;

          step++;
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    analysisThis issue requires additional analysisenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions