Quote:
Originally Posted by btslaser
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.