More tweaks

This commit is contained in:
Chris Greening 2022-10-12 20:18:28 +01:00
parent a914baefd9
commit e200c08fa2
3 changed files with 62 additions and 47 deletions

View file

@ -64,8 +64,8 @@
"STATOR_RADIUS = 23\n",
"STATOR_HOLE_RADIUS = 5\n",
"SCREW_HOLE_RADIUS = 20\n",
"SCREW_HOLE_DRILL_DIAM = 3.2 # 3.2mm drill for a 3mm screw\n",
"STATOR_HOLE_RADIUS = 5\n",
"SCREW_HOLE_DRILL_DIAM = 2.3 # 2.3mm drill for a 2mm screw\n",
"STATOR_HOLE_RADIUS = 5.5\n",
"\n",
"# Track width and spacing\n",
"TRACK_WIDTH = 0.127\n",
@ -73,11 +73,11 @@
"\n",
"# Coil params\n",
"TURNS = 9\n",
"COIL_CENTER_RADIUS = 11.5\n",
"COIL_VIA_RADIUS = 12.5\n",
"COIL_CENTER_RADIUS = 11.8\n",
"COIL_VIA_RADIUS = 12.8\n",
"\n",
"# where to place the pins\n",
"CONNECTION_PINS_RADIUS = 16.5\n",
"# CONNECTION_PINS_RADIUS = 16.5\n",
"\n",
"USE_SPIRAL = False"
]
@ -305,10 +305,10 @@
" )\n",
"\n",
"# raidus for connecting the bottoms of the coils together\n",
"connection_radius1 = STATOR_HOLE_RADIUS + 0.5\n",
"connection_radius1 = STATOR_HOLE_RADIUS + 3 * TRACK_SPACING\n",
"\n",
"# create tracks to link the A coils around the center\n",
"connection_via_radius_A = connection_radius1 + TRACK_SPACING + VIA_DIAM / 2\n",
"connection_via_radius_A = connection_radius1 + 3 * TRACK_SPACING + VIA_DIAM / 2\n",
"coil_A1_A2_inner = (\n",
" [get_arc_point(0, connection_via_radius_A)]\n",
" + draw_arc(0, 3 * 360 / 12, connection_radius1)\n",
@ -344,7 +344,7 @@
"coils_b[10].append(coil_B3_B4_inner[-1])\n",
"\n",
"# create tracks to link the C coils around the center\n",
"connection_via_radius_C = connection_via_radius_A + TRACK_SPACING + VIA_DIAM / 2\n",
"connection_via_radius_C = connection_via_radius_A + 3 * TRACK_SPACING + VIA_DIAM / 2\n",
"coil_C1_C2_inner = draw_arc(2 * 360 / 12, 5 * 360 / 12, connection_via_radius_C)\n",
"tracks_f.append(coil_C1_C2_inner)\n",
"coil_C3_C4_inner = draw_arc(8 * 360 / 12, 11 * 360 / 12, connection_via_radius_C)\n",
@ -426,19 +426,20 @@
"pads.append(create_pad((INPUT_PAD_RADIUS, PAD_PITCH), PAD_WIDTH, PAD_HEIGHT, \"b\"))\n",
"\n",
"# connect coil A to the top pad\n",
"coils_f[0].append((INPUT_PAD_RADIUS, -PAD_PITCH))\n",
"vias.append(create_via(((INPUT_PAD_RADIUS, -PAD_PITCH))))\n",
"pad_connection_point_x = INPUT_PAD_RADIUS + PAD_WIDTH / 2 - VIA_DIAM\n",
"coils_f[0].append((pad_connection_point_x, -PAD_PITCH))\n",
"vias.append(create_via(((pad_connection_point_x, -PAD_PITCH))))\n",
"# connect coil B to the middle pad\n",
"coils_f[1].append((INPUT_PAD_RADIUS, 0))\n",
"vias.append(create_via(((INPUT_PAD_RADIUS, 0))))\n",
"coils_f[1].append((pad_connection_point_x, 0))\n",
"vias.append(create_via(((pad_connection_point_x, 0))))\n",
"# connect coil C to the bottom pad\n",
"coils_f[2].append(\n",
" get_arc_point(\n",
" 2 * 360 / 12, SCREW_HOLE_RADIUS - (SCREW_HOLE_DRILL_DIAM / 2 + TRACK_SPACING)\n",
" )\n",
")\n",
"coils_f[2].append((INPUT_PAD_RADIUS, PAD_PITCH))\n",
"vias.append(create_via(((INPUT_PAD_RADIUS, PAD_PITCH))))"
"coils_f[2].append((pad_connection_point_x, PAD_PITCH))\n",
"vias.append(create_via(((pad_connection_point_x, PAD_PITCH))))"
]
},
{

View file

@ -59,8 +59,8 @@
"# PCB Edge size\n",
"STATOR_RADIUS = 23\n",
"SCREW_HOLE_RADIUS = 20\n",
"SCREW_HOLE_DRILL_DIAM = 3.2 # 3.2mm drill for a 3mm screw\n",
"STATOR_HOLE_RADIUS = 5\n",
"SCREW_HOLE_DRILL_DIAM = 2.3 # 2.3mm drill for a 2mm screw\n",
"STATOR_HOLE_RADIUS = 5.5\n",
"\n",
"# where to put the input pads\n",
"INPUT_PAD_RADIUS = 19.5\n",
@ -71,7 +71,7 @@
"\n",
"# Coil params\n",
"TURNS = 18\n",
"COIL_CENTER_RADIUS = 11.5\n",
"COIL_CENTER_RADIUS = 12.2\n",
"\n",
"# where do we want to stop routing any tracks?\n",
"MAX_TRACK_RADIUS = SCREW_HOLE_RADIUS - (SCREW_HOLE_DRILL_DIAM / 2 + TRACK_SPACING * 2)\n",
@ -378,7 +378,7 @@
"vias.append(create_via(get_arc_point(angle_C_opp, COIL_CENTER_RADIUS)))\n",
"\n",
"# connect the front copper opposite coils together\n",
"common_connection_radius = MAX_TRACK_RADIUS - (VIA_DIAM / 2 + TRACK_SPACING)\n",
"common_connection_radius = MAX_TRACK_RADIUS\n",
"common_coil_connections_b = draw_arc(angle_A_opp, angle_C_opp, common_connection_radius)\n",
"coil_A_opp_f.append(get_arc_point(angle_A_opp, common_connection_radius))\n",
"coil_B_opp_f.append(get_arc_point(angle_B_opp, common_connection_radius))\n",
@ -392,7 +392,7 @@
"\n",
"# wires for connecting to opposite coils\n",
"connection_radius1 = STATOR_HOLE_RADIUS + (2 * TRACK_SPACING)\n",
"connection_radius2 = connection_radius1 + (TRACK_SPACING + VIA_DIAM / 2)\n",
"connection_radius2 = connection_radius1 + (2 * TRACK_SPACING + VIA_DIAM / 2)\n",
"\n",
"# draw a 45 degree line from each coil at connection radius 1\n",
"# then connect up to connection radius 2\n",
@ -462,25 +462,29 @@
")\n",
"pads.append(create_pad((PAD_PITCH, INPUT_PAD_RADIUS), PAD_HEIGHT, PAD_WIDTH, \"b\"))\n",
"\n",
"# connect coil A to the middle pad\n",
"# connect coil A to the top pad\n",
"pad_connection_point_y = INPUT_PAD_RADIUS + PAD_WIDTH / 2 - VIA_DIAM\n",
"input_pad_connection_radius = SCREW_HOLE_RADIUS + SCREW_HOLE_DRILL_DIAM / 2 + 0.5\n",
"tracks_f.append(\n",
" draw_arc(angle_A, 80, input_pad_connection_radius, 5)\n",
" + [(PAD_PITCH, INPUT_PAD_RADIUS + VIA_DIAM)]\n",
" + [(PAD_PITCH, pad_connection_point_y)]\n",
")\n",
"# connect coil B to the middle pad\n",
"tracks_f.append(draw_arc(90, angle_B, INPUT_PAD_RADIUS, 5))\n",
"tracks_f.append(\n",
" [(0, pad_connection_point_y)] + draw_arc(90, angle_B, INPUT_PAD_RADIUS, 5)\n",
")\n",
"# connect coil C to the bottom pad\n",
"tracks_f.append(\n",
" [(-PAD_PITCH, INPUT_PAD_RADIUS + VIA_DIAM)]\n",
" [(-PAD_PITCH, pad_connection_point_y)]\n",
" + draw_arc(100, angle_C, input_pad_connection_radius, 5)\n",
")\n",
"coil_A_f.append(get_arc_point(angle_A, input_pad_connection_radius))\n",
"coil_B_f.append(get_arc_point(angle_B, INPUT_PAD_RADIUS))\n",
"coil_C_f.append(get_arc_point(angle_C, input_pad_connection_radius))\n",
"vias.append(create_via((-PAD_PITCH, INPUT_PAD_RADIUS + VIA_DIAM)))\n",
"vias.append(create_via((0, INPUT_PAD_RADIUS)))\n",
"vias.append(create_via((PAD_PITCH, INPUT_PAD_RADIUS + VIA_DIAM)))"
"\n",
"vias.append(create_via((-PAD_PITCH, pad_connection_point_y)))\n",
"vias.append(create_via((0, pad_connection_point_y)))\n",
"vias.append(create_via((PAD_PITCH, pad_connection_point_y)))"
]
},
{

View file

@ -4,12 +4,16 @@ import wx
import math
CENTER_X = 150
CENTER_Y = 100
def create_tracks(board, group, net, layer, thickness, coords):
last_x = None
last_y = None
for coord in coords:
x = coord["x"]
y = coord["y"]
x = coord["x"] + CENTER_X
y = coord["y"] + CENTER_Y
track = pcbnew.PCB_TRACK(board)
if last_x is not None:
track.SetStart(pcbnew.wxPointMM(float(last_x), float(last_y)))
@ -75,7 +79,7 @@ class CoilPlugin(pcbnew.ActionPlugin):
for via in coil_data["vias"]:
pcb_via = pcbnew.PCB_VIA(board)
pcb_via.SetPosition(
pcbnew.wxPointMM(float(via["x"]), float(via["y"]))
pcbnew.wxPointMM(via["x"] + CENTER_X, via["y"] + CENTER_Y)
)
pcb_via.SetWidth(int(via_diameter * 1e6))
pcb_via.SetDrill(int(via_drill_diameter * 1e6))
@ -85,8 +89,10 @@ class CoilPlugin(pcbnew.ActionPlugin):
# create the pins
for pin in coil_data["pins"]:
x = pin["x"] + CENTER_X
y = pin["y"] + CENTER_Y
module = pcbnew.FOOTPRINT(board)
module.SetPosition(pcbnew.wxPointMM(pin["x"], pin["y"]))
module.SetPosition(pcbnew.wxPointMM(x, y))
board.Add(module)
pcb_pad = pcbnew.PAD(module)
pcb_pad.SetSize(pcbnew.wxSizeMM(pin_diameter, pin_diameter))
@ -94,7 +100,7 @@ class CoilPlugin(pcbnew.ActionPlugin):
pcb_pad.SetAttribute(pcbnew.PAD_ATTRIB_PTH)
pcb_pad.SetLayerSet(pcb_pad.PTHMask())
pcb_pad.SetDrillSize(pcbnew.wxSizeMM(pin_drill, pin_drill))
pcb_pad.SetPosition(pcbnew.wxPointMM(pin["x"], pin["y"]))
pcb_pad.SetPosition(pcbnew.wxPointMM(x, y))
pcb_pad.SetNetCode(net.GetNetCode())
module.Add(pcb_pad)
@ -102,8 +108,10 @@ class CoilPlugin(pcbnew.ActionPlugin):
lset = pcbnew.LSET()
lset.AddLayer(pcbnew.B_Cu)
for pin in coil_data["pads"]:
x = pin["x"] + CENTER_X
y = pin["y"] + CENTER_Y
module = pcbnew.FOOTPRINT(board)
module.SetPosition(pcbnew.wxPointMM(pin["x"], pin["y"]))
module.SetPosition(pcbnew.wxPointMM(x, y))
board.Add(module)
pcb_pad = pcbnew.PAD(module)
pcb_pad.SetSize(pcbnew.wxSizeMM(pin["width"], pin["height"]))
@ -111,20 +119,20 @@ class CoilPlugin(pcbnew.ActionPlugin):
pcb_pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD)
pcb_pad.SetLayerSet(pcb_pad.SMDMask())
# pcb_pad.SetLayerSet(lset)
pcb_pad.SetPosition(pcbnew.wxPointMM(pin["x"], pin["y"]))
pcb_pad.SetPosition(pcbnew.wxPointMM(x, y))
pcb_pad.SetNetCode(net.GetNetCode())
pcb_pad.Flip(pcbnew.wxPointMM(pin["x"], pin["y"]), False)
pcb_pad.Flip(pcbnew.wxPointMM(x, y), False)
module.Add(pcb_pad)
# create any silk screen
for text in coil_data["silk"]:
x = text["x"] + CENTER_X
y = text["y"] + CENTER_Y
pcb_txt = pcbnew.PCB_TEXT(board)
pcb_txt.SetText(text["text"])
pcb_txt.SetPosition(pcbnew.wxPointMM(text["x"], text["y"]))
pcb_txt.SetPosition(pcbnew.wxPointMM(x, y))
pcb_txt.SetHorizJustify(pcbnew.GR_TEXT_HJUSTIFY_CENTER)
pcb_txt.Rotate(
pcbnew.wxPointMM(text["x"], text["y"]), text["angle"]
)
pcb_txt.Rotate(pcbnew.wxPointMM(x, y), text["angle"])
pcb_txt.SetTextSize(
pcbnew.wxSize(
text["size"] * pcbnew.IU_PER_MM,
@ -133,14 +141,16 @@ class CoilPlugin(pcbnew.ActionPlugin):
)
pcb_txt.SetLayer(pcbnew.F_SilkS)
if text["layer"] == "b":
pcb_txt.Flip(pcbnew.wxPointMM(text["x"], text["y"]), True)
pcb_txt.Flip(pcbnew.wxPointMM(x, y), True)
board.Add(pcb_txt)
# pcb_group.AddItem(pcb_txt)
# create the mounting holes
for hole in coil_data["mountingHoles"]:
x = hole["x"] + CENTER_X
y = hole["y"] + CENTER_Y
module = pcbnew.FOOTPRINT(board)
module.SetPosition(pcbnew.wxPointMM(hole["x"], hole["y"]))
module.SetPosition(pcbnew.wxPointMM(x, y))
board.Add(module)
pcb_pad = pcbnew.PAD(module)
pcb_pad.SetSize(pcbnew.wxSizeMM(hole["diameter"], hole["diameter"]))
@ -150,7 +160,7 @@ class CoilPlugin(pcbnew.ActionPlugin):
pcb_pad.SetDrillSize(
pcbnew.wxSizeMM(hole["diameter"], hole["diameter"])
)
pcb_pad.SetPosition(pcbnew.wxPointMM(hole["x"], hole["y"]))
pcb_pad.SetPosition(pcbnew.wxPointMM(x, y))
module.Add(pcb_pad)
# pcb_group.AddItem(pcb_hole)
@ -158,9 +168,9 @@ class CoilPlugin(pcbnew.ActionPlugin):
arc = pcbnew.PCB_SHAPE(board)
arc.SetShape(pcbnew.SHAPE_T_CIRCLE)
arc.SetFilled(False)
arc.SetStart(pcbnew.wxPointMM(0, 0))
arc.SetEnd(pcbnew.wxPointMM(stator_radius, 0))
arc.SetCenter(pcbnew.wxPointMM(0, 0))
arc.SetStart(pcbnew.wxPointMM(CENTER_X, CENTER_Y))
arc.SetEnd(pcbnew.wxPointMM(CENTER_X + stator_radius, CENTER_Y))
arc.SetCenter(pcbnew.wxPointMM(CENTER_X, CENTER_Y))
arc.SetLayer(pcbnew.Edge_Cuts)
arc.SetWidth(int(0.1 * pcbnew.IU_PER_MM))
board.Add(arc)
@ -170,9 +180,9 @@ class CoilPlugin(pcbnew.ActionPlugin):
arc = pcbnew.PCB_SHAPE(board)
arc.SetShape(pcbnew.SHAPE_T_CIRCLE)
arc.SetFilled(False)
arc.SetStart(pcbnew.wxPointMM(0, 0))
arc.SetEnd(pcbnew.wxPointMM(stator_hole_radius, 0))
arc.SetCenter(pcbnew.wxPointMM(0, 0))
arc.SetStart(pcbnew.wxPointMM(CENTER_X, CENTER_Y))
arc.SetEnd(pcbnew.wxPointMM(CENTER_X + stator_hole_radius, CENTER_Y))
arc.SetCenter(pcbnew.wxPointMM(CENTER_X, CENTER_Y))
arc.SetLayer(pcbnew.Edge_Cuts)
arc.SetWidth(int(0.1 * pcbnew.IU_PER_MM))
board.Add(arc)