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

fix stepper jump back with small steps #4339

Merged
merged 1 commit into from Jan 25, 2023
Merged

fix stepper jump back with small steps #4339

merged 1 commit into from Jan 25, 2023

Conversation

0xDRRB
Copy link
Contributor

@0xDRRB 0xDRRB commented Jan 23, 2023

What does this implement/fix?

Sometimes with a reduced number of steps the stepper motor jumps in the opposite direction (clockwise) before turning in the right direction (counterclockwise). This only happens in case of counterclockwise rotation. Reducing max_speed does not fix the problem.

It turns out that the direction pin state change is too fast. I added a delay of 50µs and everything is back to normal (jump is still here with 5µs).

The problem was seen with a Wemos D1 mini connected to a cheap controller like this.
Driving the controller directly with Arduino code did not cause the problem to appear. It's just a simple timing issue.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040

Example entry for config.yaml:

# Example config.yaml
number:
  - platform: template
    name: Stepper Control
    min_value: -400
    max_value: 400
    step: 1
    set_action:
      then:
        - stepper.set_target:
            id: my_stepper
            target: !lambda 'return x;'

stepper:
  - platform: a4988
    id: my_stepper
    acceleration: 1000
    deceleration: 1000
    step_pin:
      number: D2
    dir_pin:
      number: D1
    sleep_pin:
      number: D3
    max_speed: 250 steps/s

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

@jesserockz jesserockz added this to the 2022.12.7 milestone Jan 25, 2023
@jesserockz jesserockz merged commit 267f058 into esphome:dev Jan 25, 2023
@jesserockz jesserockz mentioned this pull request Jan 26, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Jan 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants