$resArray = [1.0, 1.1, 1.2, 1.3, 1.5, 1.6, 1.8, 2.0, 2.2, 2.4, 2.7, 3.0, 3.3, 3.6, 3.9, 4.3, 4.7, 5.1, 5.6, 6.2, 6.8, 7.5, 8.2, 9.1,10, 11, 12, 13, 15, 16, 18, 20, 22, 24, 27, 30, 33, 36, 39, 43, 47, 51, 56, 62, 68, 75, 82, 91,100, 110, 120, 130, 150, 160, 180, 200, 220, 240, 270, 300, 330, 360, 390, 430, 470, 510, 560, 620, 680, 750, 820, 910,1000, 1100, 1200, 1300, 1500, 1600, 1800, 2000, 2200, 2400, 2700, 3000, 3300, 3600, 3900, 4300, 4700, 5100, 5600, 6200, 6800, 7500, 8200, 9100, 10000, 11000, 12000, 13000, 15000, 16000, 18000, 20000, 22000, 24000, 27000, 30000, 33000, 36000, 39000, 43000, 47000, 51000, 56000, 62000, 68000, 75000, 82000, 91000, 100000, 110000, 120000, 130000, 150000, 160000, 180000, 200000, 220000, 240000, 270000, 300000, 330000, 360000, 390000, 430000, 470000, 510000, 560000, 620000, 680000, 750000, 820000, 910000, 1000000, 1100000, 1200000, 1300000, 1500000, 1600000, 1800000, 2000000, 2200000, 2400000, 2700000, 3000000, 3300000, 3600000, 3900000, 4300000, 4700000, 5100000, 5600000, 6200000, 6800000, 7500000, 8200000, 9100000, 1000000]
$capArray = Array.new
$indArray = Array.new
$breakFreq = 19*(10**3)
$tol = 0.997
$PI = Math.atan2(0,-1)
def makeArray(j,arr)
for i in 0...$resArray.size
if i%j == 0
arr << $resArray[i]*(10**-9)
end
end
end
def capTest()
puts "RC Circuit Estimation"
for i in 0...$resArray.size
for j in 0...$capArray.size
n = 1/(2*$PI*$resArray[i]*$capArray[j])
if n > $breakFreq*$tol && n < $breakFreq*(2-$tol)
diff = 100 - ((n-$breakFreq)/$breakFreq).abs
puts "Resistor: #{$resArray[i]} Ohms"
puts "Capacitor: #{$capArray[j].to_f} F"
puts "Within #{diff}%"
puts "---------------------"
end
end
end
end
def indTest()
puts "RL Circuit Estimation"
for i in 0...$resArray.size
for j in 0...$indArray.size
n = $resArray[i]/(2*$PI*$indArray[j])
if n > $breakFreq*$tol && n < $breakFreq*(2-$tol)
diff = (1 - ((n-$breakFreq)/$breakFreq).abs)*100
puts "Resistor: #{$resArray[i]} Ohms"
puts "Inductor: #{$indArray[j].to_f} H"
puts "Within #{diff}%"
puts "---------------------"
end
end
end
end
makeArray(2,$capArray)
makeArray(4,$indArray)
capTest()
indTest()