' UDF: Dimension over pins/balls/wire for external involute helical gear
' or involute splines
' SYNTAX: OverBalls(Rng[, Index])
'
' ARGUMENTS:
' Rng - range/array with 6 values:
' 1 - Number of teeth
' 2 - Diametral pitch
' 3 - Helix angle on pitch diameter
' 4 - Normal pressure angle on pitch diameter
' 5 - Normal arc tooth thickness on pitch diameter
' 6 - Ball/Pin/ Wire diameter
' Index - (Optional) If defined then index value is rerurned from output array.
' Index range: 1 up to 13
'
' OUTPUT ARRAY:
' Index Comment
' 1 - Transverse pressure angle
' 2 - Transverse arc tooth thickness
' 3 - Helix angle on base cylinger
' 4 - Transverse pin diameter
' 5 - Pitch diameter
' 6 - Base diameter
' 7 - Involute functin on pitch diameter
' 8 - Involute functin on ball tangent point
' 9 - Pressure angle to pin center
' 10 - Diameter of pin centers
' 11 - Dimension over pins
' 12 - Pressure angle at point of tangency
' 13 - Radius to point of tangency
'
' NOTE: If Index is omitted then 2-columns array is returned.
' Select 13 rows in 1 or 2 column(s), put formula and confirm by Ctrl-Shift-Enter
' Array formula example: =OverBalls(A2:A7)
' Single value formula: =OverBalls(A2:A7,1) ... =OverBalls(A2:A7,13)
Function OverBalls(Rng, Optional Index = 0)
Dim Inp, Ret(1 To 13, 1 To 2)
Dim N_teeth#, D_Pitch#, Hel_Ang#, Nor_Pr#, Nor_Thick#, Ball_Dia#
Dim tpa#, tatt#, habc#, tpd#, pd#, bd#, ifpd#, ifbtp#, papc#, dpc#, dop#, papt#, rpt#
Dim a#, b#, tet#, i&
Const j& = 100 ' <-- iterations
Const pi# = 3.14159265358979
Const D2R# = pi / 180, R2D# = 180 / pi, pi4# = pi / 4, pi8# = pi / 8
' Parse input range/array Rng to variables
N_teeth = Rng(1)
D_Pitch = Rng(2)
Hel_Ang = Rng(3)
Nor_Pr = Rng(4)
Nor_Thick = Rng(5)
Ball_Dia = Rng(6)
tpa = Atn(Tan(D2R * Nor_Pr) / Cos(D2R * Hel_Ang)) * R2D
Ret(1, 1) = tpa
Ret(1, 2) = "Transverse pressure angle"
tatt = Nor_Thick / Cos(D2R * Hel_Ang)
Ret(2, 1) = tatt
Ret(2, 2) = "Transverse arc tooth thickness"
habc = Atn(Tan(D2R * Hel_Ang) * Cos(D2R * tpa)) * R2D
Ret(3, 1) = habc
Ret(3, 2) = "Helix angle on base cylinger"
tpd = Ball_Dia / Cos(D2R * habc)
Ret(4, 1) = tpd
Ret(4, 2) = "Transverse pin diameter"
pd = N_teeth / (D_Pitch * Cos(D2R * Hel_Ang))
Ret(5, 1) = pd
Ret(5, 2) = "Pitch diameter"
bd = pd * Cos(D2R * tpa)
Ret(6, 1) = bd
Ret(6, 2) = "Base diameter"
ifpd = Tan(D2R * tpa) - D2R * tpa
Ret(7, 1) = ifpd
Ret(7, 2) = "Involute function on pitch diameter"
ifbtp = tatt / pd + tpd / bd + ifpd - pi / N_teeth
Ret(8, 1) = ifbtp
Ret(8, 2) = "Involute function on ball tangent point"
a = pi4: b = pi8
For i = 1 To j
tet = Tan(a) - a
If ifbtp < tet Then a = a - b Else a = a + b
b = b / 2
Next
papc = R2D * a
Ret(9, 1) = papc
Ret(9, 2) = "Pressure angle to pin center"
dpc = bd / Cos(D2R * papc)
Ret(10, 1) = dpc
Ret(10, 2) = "Diameter of pin centers"
dop = Ball_Dia + dpc * Cos(0.5 * pi / N_teeth * (N_teeth Mod 2))
Ret(11, 1) = dop
Ret(11, 2) = "Dimension over pins"
papt = Atn(Tan(D2R * papc) - Ball_Dia * Cos(D2R * habc) / bd) * R2D
Ret(12, 1) = papt
Ret(12, 2) = "Pressure angle at point of tangency"
rpt = bd / 2 / Cos(D2R * papt)
Ret(13, 1) = rpt
Ret(13, 2) = "Radius to point of tangency"
If Index > 0 And Index < 14 Then
OverBalls = Ret(Index, 1)
Else
OverBalls = Ret
End If
End Function
' Testing subroutine
Sub Test_OverBalls()
Dim a, v, i
' Add new shhet for the testing
With Sheets.Add(Sheets(1))
.Range("A1") = "Input Values"
.Range("A2") = 50
.Range("A3") = 10
.Range("A4") = 31.5
.Range("A5") = 30
.Range("A6") = 0.1544
.Range("A7") = 0.1728
.Range("B1") = "Comment"
.Range("B2") = "Number of Teeth"
.Range("B3") = "Diametral Pitch"
.Range("B4") = "Helix Angle on Pitch Diameter"
.Range("B5") = "Normal Pressure Angle on Pitch Diameter"
.Range("B6") = "Normal Arc Tooth Thickness on Pitch Diameter"
.Range("B7") = "Ball/Pin/Wire Diameter"
With .Range("A9:B9")
.MergeCells = True
.HorizontalAlignment = xlCenter
.Value = "A10:B22 Array Formula"
End With
.Range("A10:B22").FormulaArray = "=OverBalls(A2:A7)"
.Range("D9") = "D10:D22 Array Formula"
.Range("D10:D22").FormulaArray = "=OverBalls(A2:A7)"
.Range("F9") = "Individual Formulas"
.Range("F10:F22").Formula = "=OverBalls($A$2:$A$7,ROW()-9)"
.Columns("A:F").AutoFit
End With
' VBA testing of array returning
Debug.Print "Array values:"
a = OverBalls(Range("A2:A7"))
For i = 1 To 13
Debug.Print i, a(i, 1), a(i, 2)
Next
' VBA testing of individual value returning
Debug.Print "Some values:"
Debug.Print 12, OverBalls(Range("A2:A7"), 12)
Debug.Print 13, OverBalls(Range("A2:A7"), 13)
End Sub