' ' AN #138 - RPM meter and rotational speed sensor with AT90S2313 ' 'http://www.mcselec.com/index.php?option=com_content&task=view&id=106&Itemid=57 ' ' (c) 2005-2006 MCS Eletronics Modified by diymania for use with a reflex detector. ' ' Program : Main program ' ' Note : this program calculate with recompiled mcs.lib with Genus(0) ! ' see AN for details Config Timer1 = Pwm , Prescale = 64 , Compare A Pwm = Clear Down , Pwm = 10 Dim W As Word Dim Pinhz As Word Dim Temp As Single Dim Rpm As Word Pinhz = 19444.3 ' 3.68MHz crystal. ' Constant PulseIN value for 10Hz Pwm1a = 0 Do Pulsein W , Pinb , 2 , 1 Temp = Pinhz / W Temp = Temp * 10 Rpm = Temp / 1 ' One pulse per revolution. Temp = Rpm * 60 Temp = 258.38 * Log(temp) Temp = Temp - 1437.2 Rpm = Temp Pwm1a = Rpm Loop