'------------------------------------------------------------
' copper coil winding           FreeBASIC or MS VB
#define inch *25.4
#define  mm  *1
#define Real Dim As Double
Real length, Din, depth
'------------------------------------------------------------
' input data        ' all units convert to millimetres
length = 75 mm      ' length of winding on former
Din = 0.5 inch      ' outer diam of former = inner diam of winding
depth = 1 mm        ' depth of wire winding on former

'------------------------------------------------------------
Const As Double Pi = 4 * Atn( 1 )
Real pack = Pi / 4 ' proportion packed with copper, not insulation
Real Dout = Din + 2 * depth    ' outer diam of winding
Real Rin =  Din  * 0.5   ' radii
Real Rout = Dout * 0.5
Real section = ( Rout - Rin ) * length   ' cross section in mm2
Real volume = Pi * ( Rout^2 - Rin^2 ) * length   ' in mm3

Real Cu = 1.715    ' resistivity of copper x 10-8
Real Cu_ampacity = 10  ' current limit per square mm of copper
Real max_amp_turns = section * pack * Cu_ampacity

' report geometry
Print Using " Diam inner =#####.## mm"; Din
Print Using " Diam outer =#####.## mm"; Dout
Print Using "Coil length =#####.## mm"; length
Print
Print Using " section =######.# mm2"; section
Print Using " volume  =######.# mm3"; volume
Print Using " Max A.n =######.# A.turns"; max_amp_turns
Print
'------------------------------------------------------------
' specify voltage and wire diameter
Real voltage = 7.0       ' available DC voltage
Real Diam_wire = 0.2 mm  ' pick the wire diameter

'------------------------------------------------------------
Real dw2 = Diam_wire * Diam_wire   ' wire diam squared
Real len_wire = volume / dw2       ' wire length in mm
Real turns = section / dw2   ' count of turns
Real area = dw2 * Pi / 4     ' wire circular area, mm2
Real rpm = Cu * .01 / area           ' ohms per metre
Real resistance = rpm * len_wire / 1000  ' of winding
Real current = voltage / resistance      ' actual current
Real power = current * voltage     ' ohmic heating of coil

' report electrical
Print Using "  wire diam  =###.### mm"; Diam_wire
Print Using " wire length =####.## metre"; len_wire * 0.001
Print Using " resistance  =####.## ohms/km, check."; rpm * 1000
Print Using " winding res =####.## ohms"; resistance
Print
Print Using " DC voltage  =####.### V"; voltage
Print Using "real current =####.### A"; current
Print Using "max ampacity =####.### A"; area * Cu_ampacity
Print
Print Using "  Power =####.### watt"; power
Print Using "  Turns =######.# turns"; turns
Print Using "A.Turns =######.# A.n"; current * turns
Print
Print Using " Optimum wire diam =###.### mm"; Sqr( Cu * Cu_ampacity * volume /voltage /100000 )
print 
'------------------------------------------------------------
' example results
'
'     Diam inner =   12.70 mm
'     Diam outer =   14.70 mm
'    Coil length =   75.00 mm
'    
'     section =    75.0 mm2
'     volume  =  3228.0 mm3
'     Max A.n =   589.0 A.turns
'    
'      wire diam  =  0.200 mm
'     wire length =  80.70 metre
'     resistance  = 545.90 ohms/km, check.
'     winding res =  44.05 ohms
'    
'     DC voltage  =   7.000 V
'    real current =   0.159 A
'    max ampacity =   0.314 A
'    
'      Power =   1.112 watt
'      Turns =  1875.0 turns
'    A.Turns =   297.9 A.n
'    
'     Optimum wire diam =  0.281 mm
'
'------------------------------------------------------------
' end of program
'------------------------------------------------------------
