Thread: RPM calculator
View Single Post
  #17   Spotlight this post!  
Unread 02-03-2012, 13:06
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 8,089
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: RPM calculator

Quote:
Originally Posted by btslaser View Post
To calculate the delta time in Java do you use System.currentTimeMillis() before or after getting latest count or is there a better timestamp that is associated with the time the encoder count value was actually taken?
If you are using a 360 count per rev encoder on a wheel spinning at, say, 4000 rpm, and you are sampling at roughly 20ms, then the delta count per sample would be 480. One count out of 480 is 0.2% so you probably don't need to worry about that.

I suppose you could put the code to grab the encoder count and the system timer in a critical section to prevent getting swapped out between the two operations.


Reply With Quote