--Developed by Luther Lloyd III 8/22/14 for use by Autosport Labs Community --Copy this text into the scripting window of Race Analyzer --Edit the gear ratios to mathc your car --Add another gear row if needed for 6th gear or delete extraneous ones --below values are constants for the vehicle local 1stGear = 3.5 local 2ndGear = 2.7 local 3rdGear = 2.0 local 4thGear = 1.4 local 5thGear = 0.9 local FinalDrive = 3.21 --diameter in inches local TireDia = 25.0 --allowable error of gear ratio to allow for measurement variation local gearErr = 0.1 local rpmSpeedRatio = 0 --initialized to 0 so if it doesn't work you know local gearPos = 0 --this is the gear channel variable function onTick() --updates gear position every second by default --assumes Pulse Input channel one is for the RPM signal and speed in MPH local speed = getGpsSpeed() local rpm = getTimerRpm(0) --this part only works for firmware version 2.0 per the RCP page gearId = addChannel("Analog1",5) --no known channel gear so using Analog1 if speed > 10 then --makes sure your rolling so as not to divide by 0 rpmSpeedRatio = (rpm/speed)/(FinalDrive*1056/(TireDia*3.14159)) if ((1stGear - rpmSpeedRatio)^2) < (gearErr^2) then gearPos = 1 end if ((2ndGear - rpmSpeedRatio)^2) < (gearErr^2) then gearPos = 2 end if ((3rdGear - rpmSpeedRatio)^2) < (gearErr^2) then gearPos = 3 end if ((4thGear - rpmSpeedRatio)^2) < (gearErr^2) then gearPos = 4 end if ((5thGear - rpmSpeedRatio)^2) < (gearErr^2) then gearPos = 5 end else gearPos = 0 end setChannel(gearId, gearPos) --outputs to virtual channel end