shell_script_lcf_calculator
Shell Script LCF Calculator
Finds L (Inductance), or C (Capacitance), or F (Frequency), from the other two values.
This shell script program calculates values of L, C, and F. From any of the two it will find the third member.
INSTALLATION:
Copy it to your "/usr/local/bin" directory.
make it executable (chmod 755 /usr/local/bin/lcfcalc)
and add it to your menu system (make it executable in a terminal session).
============== start ==============
#!/bin/sh
#
# Program Name: lcfcalc
#
# Arv Evans K7HKL
# 1 January, 2007
#
# This is FREEWARE.
# You can copy it, use it, modify it, etc. without any licensing issues.
# If you break it, you own it...you fix it!
#
# NOTE: This program requires use of "dc" the desktop calculator.
# The dc program must be installed on your computer to run this software.
#
while true
do
clear
echo "#====================================#"
echo "# L, C, & F Calculator #"
echo "#-----------------------------k7hkl--#"
echo "# 1) L from C & F #"
echo "# 2) C from L & F #"
echo "# 3) F from L & C #"
echo "# q) Exit #"
echo "#------------------------------------#"
echo -n "# Selection: "
read selection
case $selection in
1|l|L) # Calculating Incudtance from C and F
clear
echo -n "Enter Capacitance in pf: "
read capacitance
echo -n "Enter Frequency (MHz): "
read frequency
# L = (25400 / (f * F * C))
inductance=`echo "6 k 25400 $frequency $frequency $capacitance * * / p" | dc`
echo "Inductance = $inductance uH."
echo
echo -n "Hit ENTER To Continue: "
read junk
;;
2|c|C) # Calculating Capacitance from L and C
clear # C = (25400 / (F * F * L))
echo # where: C=pf, L=uH, F=MHz
echo -n "Enter Inductance (uH): "
read inductance
echo -n "Enter Frequency (MHz): "
read frequency
capacitance=`echo "6 k 25400 $inductance $frequency $frequency * * / p" | dc`
echo "Capacitance = $capacitance pf"
echo
echo -n "Hit ENTER To Continue: "
read junk
;;
3|f|F) # Calculate Frequency from L and C
clear # F = (1 / ( 6.28 * SQRT(L * C)))
echo # where: L=uh, C=pf, F=KHz
echo -n "Enter Inductance (uH): "
read inductance
echo -n "Enter Capacitance(pf): "
read capacitance
frequency=`echo "6 k 159.2 $inductance $capacitance * v / p" | dc`
echo "Frequency = $frequency MHz"
echo
echo -n "Hit ENTER To Continue: "
read junk
;;
q|Q|0) # Exit on q, Q, or 0 entry
exit
;;
*) # Wildcard '*' is catchall for undefined command entries
echo
echo "Illegal Command in '$selection'"
echo -n "Hit ENTER To Continue: "
read junk
;;
esac # end of "case" evaluations
done
============== end ==============