Can you explain in more detail what you want to do?
The posted code has NO comments explaining what it is doing.
Is RPM revoltions per minute?