GAKC.org

Gateway Area Knife Club

Grind_Height_Calculator


Grind Height Calculator

This page contains a Windows PowerShell program that will calculate the grind height of a blade given the blade thickness, final edge thickness, and wheel diameter.

PowerShell has been a default install on Windows since Windows 7. So if you have any Windows box from 7 on it will be there and it is free. In an attempt to avoid any kind of download virus I have printed the program below. Simply copy the lines below and paste them into a file then save the file as GrindHeight.ps1

You can name the file whatever you like but it must be the ps1 file type.
Let's say you save the file to C:\Scripts\GrindHeight.ps1. You can run the file in several ways.

1. Open a command prompt, enter the command below:
powershell c:\Scripts\GrindHeight.ps1

2. Open an explorer window, in the address bar enter:
C:\Windows\System32\WindowsPowerShell\v1.0
then scroll down and click on powershell.exe
in the command area of the new window enter:

C:\Scripts\GrindHeight.ps1
Note:
If this is the first time you are using PowerShell
you will need to run the following in PowerShell:
Set-ExecutionPolicy Unrestricted


#---------------------Copy lines starting below this line---------------------
#Script Name: GrindHeight.ps1

#language: PowerShell

#Created By: Augie

#Created On: 20170227

#Description:
# this calculation is (BT - FE)/2 = GA
# (WD - GA) * GA = GV
# sqrt of GV = GH
# GA - Grind Area
# GV - Grind Volume
# GH - Grind Height
# BT - Blank Thickness
# WD - Wheel Diameter
# FE - Final Edge


#Input:
# Blade Thickness, less than one inch
# Final Edge thickness, less than Blade Thickness
# Wheel Diameter or "99"
# 99 will give a list of Wheel Diameters from .125 to 20 inches
# with associated Grind Height

#Output:
# If Wheel Diameter is entered then the Grind Height value for that wheel
# If 99, then list of Grind Heights with associated wheel size

#Called Scripts:
#None

#Changes:
#20170227: Creation Date

#################################################

function IsDecimal($value){
Try{
[decimal]$value | Out-Null
$true
} Catch {
$false
}
}

function GetUserInput
{
# Get User Input

#Get Blade Thickness

$script:bladeThickness = 1

while ( $script:bladeThickness -eq 1 )
{
$script:bladeThicknessInput = Read-host "Enter Blade Thickness"
if (IsDecimal $script:bladeThicknessInput)
{
if ([float]$script:bladeThicknessInput -le 0)
{
"Blade Thickness must be greater than 0. You entered '$script:bladeThicknessInput'"
}
elseif ($script:bladeThicknessInput -lt 1)
{
$script:bladeThickness = $script:bladeThicknessInput
" "
"Blade Thickness is $script:bladeThickness"
" "
}
else
{
"Blade Thickness must be less than 1 inch. You entered '$script:bladeThicknessInput'"
}
}
else
{
"Blade Thickness must a decimal number. You entered '$script:bladeThicknessInput'"
}
}

#Get Edge Thickness
$script:edgeThickness = 1

while ( $script:edgeThickness -eq 1 )
{
$script:edgeThicknessInput = Read-host "Enter Thickness of Final Edge"
if (IsDecimal $script:edgeThicknessInput)
{
if ([float]$script:edgeThicknessInput -le 0)
{
"Edge Thickness must be greater than 0. You entered '$script:edgeThicknessInput'"
}
elseif ($script:edgeThicknessInput -lt 1)
{
if ( $script:edgeThicknessInput -lt $script:bladeThickness )
{
$script:edgeThickness = $script:edgeThicknessInput
" "
"Edge Thickness is $script:edgeThickness"
" "
}
else
{
"Edge Thickness must be less than Blade Thickness."
"You entered an edge of '$script:edgeThicknessInput'"
" and a bldade of '$script:bladeThickness'"
}
}
else
{
"Edge Thickness must be less than 1 inch. You entered '$script:edgeThicknessInput'"
}
}
else
{
"Edge Thickness must a decimal number. You entered '$script:edgeThicknessInput'"
}
}

#calculate Grind Area
$script:grindArea = ( $script:bladeThickness - $script:edgeThickness )/2
"Grind Area is $script:grindArea"
" "

#Get Wheel Diameter
$script:wheelDiameter = 'a'
while ( $script:wheelDiameter -eq 'a' )
{
"Enter a specific Wheel Diameter"
" OR "
$script:wheelDiameterInput = Read-host "99 for a list of common diameters"
if (IsDecimal $script:wheelDiameterInput)
{
if ([float]$script:wheelDiameterInput -le 0)
{
"Wheel Diameter must be greater than 0. You entered '$script:wheelDiameterInput'"
}
elseif ([float]$script:wheelDiameterInput -lt 100)
{
$script:wheelDiameter = $script:wheelDiameterInput
if ( $script:wheelDiameter -ne 99 )
{
$script:wheelArray = $script:wheelDiameter
" "
"Wheel Diameter is $script:wheelDiameter"
" "
}
else
{
$script:wheelArray = @(.125, .25, .375, .50, .625, .75, .875, 1, 1.125, 1.25, 1.375, 1.50, 1.625, 1.75, 1.875, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20)
" "
"Wheel Diameter is $script:wheelDiameter for a list"
" "
}
}
else
{
"Wheel Diameter must be less than 100 inchs. You entered '$script:wheelDiameterInput'"
}
}
else
{
"Wheel Diameter must a decimal number. You entered '$script:wheelDiameterInput'"
}
}
#end function
}

function CalculateAndDisplay
{
#foreach ($diameter in $script:wheelArray)
# {
# " x $diameter"
# }

if ( $script:wheelDiameter -eq 99 )
{
" "
" "
"Wheel - Grind Height Wheel - Grind Height Wheel - Grind Height"
" "
for ( [int]$i = 0; $i -lt $script:wheelArray.length; $i++ )
{
$script:grindVolume = ( $script:wheelArray[$i] - $script:grindArea ) * $script:grindArea
$script:out0 = "{0,6:N3} {1:N7}" -f $($script:wheelArray[$i]),$([System.Math]::Sqrt($script:grindVolume))
$i++

$script:out1 = " "
$script:out2 = " "
if ( $i -lt $script:wheelArray.length )
{
$script:grindVolume = ( $script:wheelArray[$i] - $script:grindArea ) * $script:grindArea
$script:out1 = "{0,6:N3} {1:N7}" -f $($script:wheelArray[$i]),$([System.Math]::Sqrt($script:grindVolume))
$i++;
}
if ( $i -lt $script:wheelArray.length )
{
$script:grindVolume = ( $script:wheelArray[$i] - $script:grindArea ) * $script:grindArea
$script:out2 = "{0,6:N3} {1:N7}" -f $($script:wheelArray[$i]),$([System.Math]::Sqrt($script:grindVolume))
}
"$script:out0 $script:out1 $script:out2"
}
}
else
{
" "
"Wheel - Grind Height"
" "
$script:grindVolume = ( $script:wheelDiameter - $script:grindArea ) * $script:grindArea
$script:out = "{0,6:N3} {1:N7}" -f $($script:wheelDiameter),$([System.Math]::Sqrt($script:grindVolume))
"$script:out"
}

#end function
}

#*************************************************

#start of script

$ErrorActionPreference = "Stop"

# Get time
$currentdate = Get-Date

# Create time stamp and send it to log file

[string]$TimeStamp = get-date -uformat "%Y%m%d_%H%M%S"

"Job started on $currentdate"

" "
"This program is designed to calculate the maximum height of a grind line given"
"the thickness of the blade, thickness of the final edge, and wheel diameter"
"The thickness of the blade must be less than one inch and"
"the final edge must be smaller than the blade thickness"
" "
"The calculation used is: (BladeThickness - FinalEdge)/2 = GrindArea"
" (WheelDiameter - GrindArea) * GrindArea = GrindVolume"
" square root of GrindVolume = GrindHeight"
" "
"The output will be"
" "
"Either a list of values using wheel diameters from .125 to 20 inches"
" OR"
"One value with your specified wheel diameter"
" "

GetUserInput
" "
"----------------------------------------------------------------------"
CalculateAndDisplay
" "
"----------------------------------------------------------------------"
" "
#---------------------Do Not Copy lines from here or below---------------------
#--------------------------------Do Not Copy ---------------------------------
#--------------------------------Do Not Copy ---------------------------------
#--------------------------------Do Not Copy ---------------------------------
#--------------------------------Do Not Copy ---------------------------------
#--------------------------------Do Not Copy ---------------------------------
#--------------------------------Do Not Copy ---------------------------------
#--------------------------------Do Not Copy ---------------------------------