Gear Number OpenOffice Calc Macro

Derived from engine speed vs. vehicle speed math, here’s an Basic macro calculating gear numbers. Again values are for EDM Impreza 2.0 Diesel. Calc using macro formula

' Usage: GearNum(Engine Speed [rpm], Vehicle Speed [kph])
' Does not require clutch and neutral input
' but yields invalid values in neutral and when clutch depressed!
Function GearNum(ByVal rpm, ByVal velocity)
  Const Invalid = ""
  If Not IsNumeric(velocity) Or velocity < 1 Or Not IsNumeric(rpm) then
    GearNum = Invalid
    Dim factor As Double
    factor = rpm / velocity
    Select Case factor
      ' range values calculated using 5% tolerance
      Case 108.669 To 120.108
	      GearNum = 1
      Case 55.0583 To 60.8539
	      GearNum = 2
      Case 33.4125 To 36.9296
	      GearNum = 3
      Case 24.6976 To 27.2973
	      GearNum = 4
      Case 19.9468 To 22.0465
	      GearNum = 5
      Case 17.5243 To 19.3689
	      GearNum = 6
      Case Else
	      ' neutral or clutch depressed
	      GearNum = Invalid
    End Select
  End If
End Function

If you always log clutch and neutral switches you could add those as inputs to the macro. Then check (if…then..) to prevent invalid output.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.