Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"AccelStepper" can be improved #6

Closed
jeromefavrou opened this issue Apr 12, 2020 · 3 comments
Closed

"AccelStepper" can be improved #6

jeromefavrou opened this issue Apr 12, 2020 · 3 comments
Labels
analysis This issue requires additional analysis enhancement New feature or request

Comments

@jeromefavrou
Copy link

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++;
        }
@andre-stefanov andre-stefanov transferred this issue from OpenAstroTech/OpenAstroTracker Dec 13, 2020
@andre-stefanov andre-stefanov added analysis This issue requires additional analysis enhancement New feature or request labels Dec 13, 2020
@andre-stefanov
Copy link
Member

We have analyzed the code and you are right, there is definitely an error which stacks with each step because the _lastStepTime is based on the current time instead on the interval and the runSpeed() function is not called on each microsecond.

@jeromefavrou
Copy link
Author

jeromefavrou commented Dec 27, 2020

I made a pull on the lib accelstepper's git
waspinator/AccelStepper#9

CTetford added a commit that referenced this issue Feb 2, 2021
@andre-stefanov
Copy link
Member

We are moving away from AccelStepper dependency meanwhile because it is not performant enough and has several issues. Also the linked PR was not merged by that library meaning it is not supported enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analysis This issue requires additional analysis enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants