Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add Stepper Motor PWM-Counter driver. #720

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

Open
IhorNehrutsa wants to merge 1 commit into micropython:master
base: master
Choose a base branch
Loading
from IhorNehrutsa:stepper_motor_pwm_counter

Conversation

@IhorNehrutsa
Copy link

@IhorNehrutsa IhorNehrutsa commented Aug 21, 2023
edited
Loading

image
The main feature of this driver is that the generation and counting of pulses are performed by hardware, which frees up time in the main loop. PWM will start pulses and Counter will stop pulses in irq handler.

View the README
Motor speed acceleration/deceleration video

This driver requires PR's:
esp32/PWM: Reduce inconsitencies between ports. #10854
ESP32: Add Quadrature Encoder and Pulse Counter classes. #8766

Copy link
Author

@jonathanhogg
May you test esp32/esp32_pcnt: Add PCNT class and Counter/Encoder shims in machine #7582 with this PR?

Copy link
Author

@robert-hh
May you test mimxrt: Add Quadrature Encoder and Pulse Counter classes. #7911 with this PR?

Copy link
Contributor

Sorry, I do not have any motor and /or driver hardware for testing.

IhorNehrutsa reacted with confused emoji

Copy link

@jonathanhogg
May you test esp32/esp32_pcnt: Add PCNT class and Counter/Encoder shims in machine #7582 with this PR?

This code won't work with my version of Counter() as I don't support an .irq() method – I've only implemented the basic #8072 API – on the assumption that anyone who needed to do something more low level would use my PCNT() class directly.

As I currently use IRQs to implement wide-value counting, it'll be hard – though probably not impossible – to extend Counter() to support a threshold callback. I'd not look at doing this unless there was a decent cross-port API for it though, which at the least is going to need to decide on what to call the IRQ constant and how to specify the threshold.

Copy link
Author

@jonathanhogg
I think you remember the
docs\machine: Add Counter and Encoder classes. #8072

Copy link

@jonathanhogg
I think you remember the
docs\machine: Add Counter and Encoder classes. #8072

I'm sorry, I don't know what you mean.

Copy link
Author

Sorry,
I relied on the API in which you also participated in the discussion. I have no complaints.

Copy link

Sorry,
I relied on the API in which you also participated in the discussion. I have no complaints.

Yes, but we didn't arrive at a standard API for .irq() in that discussion. This code uses .irq():

self._counter.irq(handler=self.irq_handler, trigger=Counter.IRQ_MATCH1, value=self._match)

and thus won't work with my implementation.

As far as I can tell, @robert-hh's MIMXRT implementation doesn't have an IRQ_MATCH1 and so I don't think it'll work with his code either.

IhorNehrutsa reacted with eyes emoji

Add .gitignore
stepper_motor_pwm_counter.py: Code formatting by codeformat.py.
Signed-off-by: Ihor Nehrutsa <IhorNehrutsa@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /