Re: Problem writing quadrature decoder
- From: Peter Alfke <alfke@xxxxxxxxxxxxx>
- Date: Sun, 20 Apr 2008 20:14:56 -0700 (PDT)
On Apr 20, 8:09 pm, Michael <nleah...@xxxxxxxxx> wrote:
On Apr 20, 7:12 pm, Peter Alfke <al...@xxxxxxxxxxxxx> wrote:
Michael, you might prefer my much simpler solution, as described in a
recent blog on the Xilinx forums website.
http://forums.xilinx.com/xlnx/blog/article?message.uid=9394
I designed this a few years ago, and we use it in our programmable
frequency gererator, that I have mentioned here a few times.
Ken Chapman then took the exact same shaft encoder for the Spartan
eval board.
The design is absolutely bounce-proof, no Mickey Mouse low-pass
filters or other analog nonsense.
I hope the explanation is sufficient.
Viel Spaß
Peter Alfke
Hi Peter - I didn't see any code attached to the post. Does this look
right?
signal Q1, Q2 : std_logic;
process (A, B)
begin
if (A = '1' and B = '1') then
Q1 <= '1';
elsif (A = '0' and B = '0') then
Q1 <= '0';
elsif (A = '0' and B = '1') then
Q2 <= '1';
elsif (A = '1' and B = '0') then
Q2 <= '0';
end if;
D1 <= (A and B) or ((A or B) and Q1);
D2 <= ((not A) and B) or (((not A) or B) and Q2);
end process;
So then I would take say D1 and call it the clock, and call D2 the
direction, and then increment the count on every edge of D1 when D2
was high and decrement it for every D1 edge when D2 was low? At least,
that was my understanding from your post.
However, I just simulated it by hand (on a piece of paper- haven't
figured out how to use a simulator just yet) - and I set it up to have
B 90 degrees behind A, and then I found Q1 = A, Q2 = B, D1 = A, and D2
= B. So I suspect I'm misunderstanding something...
-Michael
Check it with pencil and paper.
Yes, A and B are 90 degree offset, that's why it's called a quadrature
decoder.
Then check if for a monotonic "friendly" rotation, and you see how it
works. The trickery is that it also works for any non-monotonic move.
Peter
.
- Follow-Ups:
- Re: Problem writing quadrature decoder
- From: Peter Alfke
- Re: Problem writing quadrature decoder
- References:
- Problem writing quadrature decoder
- From: Michael
- Re: Problem writing quadrature decoder
- From: Peter Alfke
- Re: Problem writing quadrature decoder
- From: Michael
- Problem writing quadrature decoder
- Prev by Date: Re: Problem writing quadrature decoder
- Next by Date: Re: synchronous reset problems on FPGA
- Previous by thread: Re: Problem writing quadrature decoder
- Next by thread: Re: Problem writing quadrature decoder
- Index(es):
Relevant Pages
|