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

add a quadrature encoder pio example #126

Merged
merged 1 commit into from
Oct 26, 2021

Conversation

pmarques-dev
Copy link
Contributor

No description provided.

@kilograham
Copy link
Contributor

@Wren6991 can you take a look at this
@pmarques-dev this will be added under our BSD-3 license, ok?

@pmarques-dev
Copy link
Contributor Author

sure, the BSD-3 license is perfectly fine

Copy link
Contributor

@kilograham kilograham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this works!

@kilograham kilograham merged commit 09e34e7 into raspberrypi:develop Oct 26, 2021
@kilograham
Copy link
Contributor

I put you as (C) pmarques-dev @ github.
Let me know if you'd like something else

@pmarques-dev
Copy link
Contributor Author

I've tested the code with an actual encoder and it works great. Since it uses a state machine to count the steps, it doesn't miss a step, even in scenarios with frequent changes of direction (like would happen with simpler approaches, like waiting for a specific transition in one phase and using the other phase to decide if it is positive or negative).
Also, since everything is done in the PIO itself it uses zero CPU time to keep track of the count and supports very high step frequencies (unlike what would happen in an interrupt based approach, or if the PIO would send data at each step). The CPU just needs to ask for the current count when it needs it.

@pmarques-dev
Copy link
Contributor Author

"(C) pmarques-dev @ github" is fine. In the future, If you would prefer to use my real name is "Paulo Marques".
I also have some code to do a full duplex UART on a single PIO, that would allow a RP2040 to have 10 full duplex UARTs, but I haven't had a chance to test it thoroughly yet, so I haven't tried to push it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants