Add quadrature encoder starter course
This commit is contained in:
commit
032ef0a15b
5 changed files with 140 additions and 0 deletions
|
|
@ -0,0 +1,33 @@
|
|||
---
|
||||
title: Counting Direction and Steps
|
||||
summary: Decode edges from the A and B channels to recover step count and direction.
|
||||
chapter: Reading Encoder Signals
|
||||
order: 2
|
||||
tags:
|
||||
- decoding
|
||||
- interrupts
|
||||
- firmware
|
||||
estimated_minutes: 10
|
||||
---
|
||||
|
||||
# Counting Direction and Steps
|
||||
|
||||
Once you can read the A and B channels, the next job is decoding.
|
||||
|
||||
The most common approach is:
|
||||
|
||||
- trigger on an edge
|
||||
- read both channels
|
||||
- use a lookup table or state machine to update the count
|
||||
|
||||
If your decoder sees illegal state jumps, you are probably dropping edges or reading a noisy signal.
|
||||
|
||||
## Practical notes
|
||||
|
||||
- Start with low shaft speed.
|
||||
- Add debounce or filtering only if the hardware needs it.
|
||||
- Test forward and reverse explicitly.
|
||||
|
||||
## Checkpoint
|
||||
|
||||
Write firmware that increments a counter when the shaft turns forward and decrements when it turns backward.
|
||||
Loading…
Add table
Add a link
Reference in a new issue