Go to Post Calculate everything. You won't need to make speed holes if you figure it all out beforehand and get it taken care of. - Otaku [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 19-02-2005, 00:26
Alan Anderson's Avatar
Alan Anderson Alan Anderson is offline
Software Architect
FRC #0045 (TechnoKats)
Team Role: Mentor
 
Join Date: Feb 2004
Rookie Year: 2004
Location: Kokomo, Indiana
Posts: 9,113
Alan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond reputeAlan Anderson has a reputation beyond repute
Encoders, interrupts, and edge-triggering issues

I just fixed a nagging problem with our encoders tonight. The nature of the problem is such that I think many people might be suffering from it. Here's the deal:

The encoder counts wouldn't always track the motion properly. Theoretically, for one full rotation, the software should always see exactly 64 counts. On occasion, it would apparently miss counts. Even though I was sure the rate wasn't too high, I added the 7474 "Phase B Catcher" circuit. I don't know whether or not that fixed the original problem, or if I was misunderstanding what was wrong in the first place, but a new and consistent problem appeared: it would often give extra counts.

Analyzing the situation yielded a theory. If the encoder were at a point where a little bit of wiggling made the Phase A signal change, it would get an interrupt for each wiggle past that point in one particular direction, because the interrupt is configured to occur only for one edge. That theory was supported by intentionally wiggling the encoder back and forth repeatedly until it started counting with no net motion actually occurring.

To fix it, I added code to toggle the interrupt edge from rising to falling, and vice versa, each time an interrupt occurred, and to treat the Phase B signal backwards for the additional edge. Now it interrupts (and counts) twice as fast, but it never loses a count or sees an extra one.

And the 7474 circuit apparently isn't necessary -- saving almost a half ounce of weight.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 04:39.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi