![]() |
Re: RPM calculator
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?
|
Re: RPM calculator
Quote:
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. |
Re: RPM calculator
I meant to ask if System.currentTimeMillis() is the best time source -or- is there some other timeStamp to use?
|
Re: RPM calculator
Quote:
Code:
/** |
Re: RPM calculator
Excellent! In the WPILib I just found:
Timer.java /** * Return the system clock time in seconds. Return the time from the * FPGA hardware clock in seconds since the FPGA started. * * @return Robot running time in seconds. */ public static double getFPGATimestamp() { return Utility.getFPGATime() / 1000000.0; } Utility.java /** * Read the microsecond timer from the FPGA. * * @return The current time in microseconds according to the FPGA. */ public static long getFPGATime() { return tGlobal.readLocalTime(); } Thanks! |
Re: RPM calculator
I generally use System.nanoTime() for anything in Java. It's overkill, but I've never found a reason NOT to use it.
You could measure the dT that it takes to get the latest count and see how negligible it is. (or isn't) |
| All times are GMT -5. The time now is 21:01. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi