home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1 / HamRadio.cdr / tech / inductor / inductor.bas
BASIC Source File  |  1988-10-13  |  3KB  |  53 lines

  1. 100 'Program to calculate the number of turns for an inductor.
  2. 110 CLS : pi = 3.1415926545#
  3. 120 k = 1473061.855#      'mhos per square inch of area of copper
  4. 130 PRINT "          *****************************************"
  5. 140 PRINT "          *     Inductor Design Calculator        *"
  6. 150 PRINT "          *     by David E. Powell, KA4KNG        *"
  7. 160 PRINT "          *****************************************": PRINT : PRINT
  8. 210 INPUT "Desired inductance in microhenries"; L
  9. 220 INPUT "Guage or diameter of wire in inches"; diameter
  10. 230 INPUT "Diameter of coil form in inches"; form
  11. 240 IF diameter >= 1 THEN diameter = .46 / 1.1229283027# ^ (diameter + 3)
  12. 250 PRINT : PRINT "calculating";
  13. 260 layers = 1              'Single layer starting out
  14. 500 a = diameter * layers + form'Average coil diameter to center of thickness
  15. 510 GOSUB 2000        'Calculate the number of turns
  16. 520 IF prob = 1 THEN layers = layers + 1: IF layers < 100 THEN GOTO 500
  17. 530 IF b > 1 THEN layers = layers + 1: GOTO 500
  18. 540 IF n > 9999 THEN PRINT "ERROR - turns count larger than 10000": SYSTEM
  19. 550 n = CINT(n): b = n * diameter / layers: ltry = (.2 * a ^ 2 * n ^ 2) / (3 * a + 9 * b + 10 * c)
  20. 560 w.length = n * a * pi
  21. 570 'calculate the resistance of coil
  22. 580 w.area = (diameter / 2) ^ 2 * pi
  23. 590 r = 1 / (w.area * k) * w.length
  24. 800 'show the results
  25. 810 PRINT : PRINT
  26. 815 PRINT "Overall coil diameter......  "; diameter * layers * 2 + form; "inches"
  27. 820 PRINT "Average coil diameter......  "; a; "inches"
  28. 830 PRINT "Depth of coil..............  "; layers * diameter; "inches"
  29. 840 PRINT "Length of coil.............  "; b; "inches"
  30. 850 PRINT "Length of wire (approx)....  "; INT(w.length / 12); "feet,";
  31. 855 PRINT INT((w.length - INT(w.length)) * 12); "inches"
  32. 860 PRINT "Number of layers...........  "; layers
  33. 870 PRINT "Number of turns............  "; n
  34. 880 PRINT "Number of turns per layer..  "; n / layers
  35. 890 PRINT "Actual inductance..........  "; ltry; "microhenries"
  36. 900 PRINT "Coil DC resistance.........  "; r; "ohms"
  37. 1000 SYSTEM         'Exit the program and BASIC
  38. 2000 'subroutine to calculate the number of turns
  39. 2010 muin.n = 1: max.n = 10000: c = layers * diameter: prob = 0
  40. 2060 n = (max.n - min.n) / 2 + min.n
  41. 2070 b = n * diameter / layers
  42. 2080 ltry = (.2 * a ^ 2 * n ^ 2) / (3 * a + 9 * b + 10 * c)
  43. 2090 IF CINT(max.n) = CINT(min.n) THEN GOTO 3000
  44. 2100 IF min.n >= 9999 THEN prob = 1: GOTO 3000
  45. 2110 IF ltry < L THEN min.n = n: GOTO 2060
  46. 2120 IF ltry > L THEN max.n = n: GOTO 2060
  47. 3000 RETURN
  48.  
  49.  
  50.  
  51.  
  52.  
  53.