'John Fields '20 May 2005 top: SCREEN 0 COLOR 0, 7 init: CLS INPUT "Enter maximum coil length in inches: ", winw INPUT "Enter bobbin shaft diameter in inches: ", bdia INPUT "Enter wire size in AWG: ", awg INPUT "Enter switch sensitivity in Ampere-Turns : ", sens INPUT "Enter minimum coil voltage in volts ", vcoil INPUT "Enter desired coil current in milliamperes : ", icoil rflag = 0 recal: pi = 3.14159 'duh... tper = 0 dia = 0 cir = 0 wlen = 0 res = 0 ntot = 0 nlay = 0 layr = 1 IF awg = 20 THEN wdia = .0334: wres = 10.13 IF awg = 21 THEN wdia = .0298: wres = 12.77 IF awg = 22 THEN wdia = .0266: wres = 16.2 IF awg = 23 THEN wdia = .0239: wres = 20.31 IF awg = 24 THEN wdia = .0213: wres = 25.67 IF awg = 25 THEN wdia = .019: wres = 32.37 IF awg = 26 THEN wdia = .017: wres = 41.02 IF awg = 27 THEN wdia = .0153: wres = 51.43 IF awg = 28 THEN wdia = .0137: wres = 65.33 IF awg = 29 THEN wdia = .0123: wres = 81.22 IF awg = 30 THEN wdia = .0109: wres = 103.7 IF awg = 31 THEN wdia = .0097: wres = 130.9 IF awg = 32 THEN wdia = .0088: wres = 162 IF awg = 33 THEN wdia = .0078: wres = 205.7 IF awg = 34 THEN wdia = .007: wres = 261.3 IF awg = 35 THEN wdia = .0062: wres = 330.7 IF awg = 36 THEN wdia = .0056: wres = 414.8 IF awg = 37 THEN wdia = .005: wres = 512.1 IF awg = 38 THEN wdia = .0045: wres = 648.2 IF awg = 39 THEN wdia = .0039: wres = 846.6 IF awg = 40 THEN wdia = .0035: wres = 1079 IF awg = 41 THEN wdia = .0028: wres = 1323 IF awg = 42 THEN wdia = .0025: wres = 1659 IF awg = 43 THEN wdia = .0022: wres = 2143 IF awg = 44 THEN wdia = .002: wres = 2593 IF awg < 20 THEN GOTO err1 'out of range error IF awg > 44 THEN GOTO err1 'out of range wdia = 1.2 * wdia 'add some slop for winding wres = wres / 12000 'convert ohms/kft to ohms/inch rcoil = 1000 * (vcoil / icoil) 'target coil resistance tper = INT(winw / wdia) 'number of turns per layer dia = bdia + wdia 'diameter of barrel and wire cir = pi * dia 'length of turn on layer 1 wlen = cir * tper 'length of wire on layer 1 res = wlen * wres 'resistance of layer 1 ntot = sens / (icoil * .001) 'total turns on coil nlay = INT(ntot / tper) 'total layers on coil DO WHILE layr < nlay layr = layr + 1 'increment layer counter dia = dia + (2 * wdia) 'increment diameter and add 20% slop cir = pi * dia 'new length of turn wlen = wlen + (cir * tper) 'new accumulated length of wire res = (wlen * wres) 'new accumulated resistance LOOP IF rflag = 0 AND res > rcoil THEN GOTO err2 rflag = 1 IF res < rcoil THEN winw = winw - .03125: GOTO recal dia$ = LEFT$(STR$(dia), 5) CLS PRINT "" PRINT "Target coil resistance ="; rcoil; "ohms" PRINT "Wire size = #"; awg; "AWG" PRINT "Length of wire ="; INT(wlen / 12); "feet" PRINT "Length of coil ="; winw; "inch" PRINT "Diameter of coil =" + dia$ + " inches" PRINT "Resistance of coil ="; INT(res); "ohms" PRINT "Number of turns "; ntot PRINT "Number of layers "; layr PRINT "" PRINT "Another run? N" loopa: a$ = INKEY$ IF a$ = "Y" THEN GOTO init IF a$ = "y" THEN GOTO init IF a$ = CHR$(13) THEN GOTO init IF a$ = "" THEN GOTO loopa END err1: CLS PRINT "Sorry, that wire size is out of range." PRINT "Choose from 20 to 44 AWG." PRINT "Want to try again? N" GOTO loopa err2: CLS PRINT "Sorry, the coil's resistance is too high. " PRINT "Use a larger wire size or a longer bobbin." PRINT "Want to try again? N" GOTO loopa