Go to Post And we had to walk both ways to the venue from our hotel! Uphill! Barefoot over broken glass! - IMDWalrus [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
  #6   Spotlight this post!  
Unread 03-05-2008, 12:51
Kevin Sevcik's Avatar
Kevin Sevcik Kevin Sevcik is online now
(Insert witty comment here)
FRC #0057 (The Leopards)
Team Role: Mentor
 
Join Date: Jun 2001
Rookie Year: 1998
Location: Houston, Texas
Posts: 3,721
Kevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond reputeKevin Sevcik has a reputation beyond repute
Send a message via AIM to Kevin Sevcik Send a message via Yahoo to Kevin Sevcik
Re: Automatic counter-Encoder

Oh jeeez. Look, how fast is this "clicker" going to be clicking? If it's slower than 38 times per second you could have the code to do this in your slow loop. If it's slower than about 300 times per second (your wheel is turning slower than 600 RPM) then you can almost certainly put the checking code in your fast loop and just not worry about the complication of interrupts. The code itself is simple.

count = (count + ((dig_in ^ old_dig_in)?1:0))%30;
old_dig_in = dig_in;

And you're done. ^ is the bitwise XOR operator, it's true if both arguments aren't the same. So if the current input isn't equal to the old input, you add 1. Otherwise you add 0. And then you modulo by 30.

Unless you absolutely have to not miss any of the clicks and it's turning at some ludicrous speed, just plop that in your code with dig_in replaced by the actual digital input and don't worry about interrupts.
__________________
The difficult we do today; the impossible we do tomorrow. Miracles by appointment only.

Lone Star Regional Troubleshooter
 


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
Automatic Something... synth3tk IT / Communications 8 08-03-2008 20:20
Automatic Transmission gnirts Programming 6 18-01-2007 20:44
Automatic Power Swampcoder2 Control System 6 03-02-2005 17:08
Automatic Power Swampcoder2 Electrical 6 03-02-2005 17:08
automatic archiving Joe Ross CD Forum Support 5 04-08-2003 13:27


All times are GMT -5. The time now is 20:26.

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