View Single Post
  #3   Spotlight this post!  
Unread 05-02-2005, 00:06
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Kevin Watson's encoder code with RPM output

Quote:
Originally Posted by Mike Betts
...Integer arithemetic! You are multiplying by 1... Try doing the math outside of the printf. Multiply by 6987 and store into a long int variable. Now divide by 10000 and store in an int variable. Now printf your int.
Or multiply by 45788 (2^16 * 0.6986666...) and then right shift sixteen bits or just grab the high order sixteen bits of the thirty-two bit long. Man, I dig this stuff <grin>.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org