|
Re: Sensing RPM with the kit encoder.
Code:
private double[] getRPM()
{
double rpm[] = new double[2]; //Declares an array of integers which the function will return.
currentTime = time.get(); //Sets currentTime to the time calculatged from FPGA
rpm[0] = leftEncoder.getRaw() * 16666666.666666 / currentTime; //dAngle*(60000000us/360deg)/dTime = RPM
rpm[1] = rightEncoder.getRaw() * 16666666.666666 / currentTime; //dAngle*(60000000us/360deg)/dTime = RPM
leftEncoder.reset(); //Resets the left wheel encoder.
rightEncoder.reset(); //Resets the right wheel encoder.
time.reset(); //This resets the timer.
return rpm;
}
__________________
Do not say what can or cannot be done, but, instead, say what must be done for the task at hand must be accomplished.
|