mirror of
https://github.com/atomic14/kicad-coil-plugins.git
synced 2024-10-18 09:06:57 +00:00
WIP board connector
This commit is contained in:
parent
f11f403e9f
commit
02a304df72
6 changed files with 286 additions and 130 deletions
|
@ -20,15 +20,20 @@
|
|||
" translate,\n",
|
||||
" flip_y,\n",
|
||||
" flip_x,\n",
|
||||
" create_via,\n",
|
||||
" create_pad,\n",
|
||||
" create_track,\n",
|
||||
" create_silk,\n",
|
||||
" create_silk,\n",
|
||||
" optimize_points,\n",
|
||||
" chaikin,\n",
|
||||
")\n",
|
||||
"from pcb_json import dump_json, plot_json\n",
|
||||
"from pcb_json import (\n",
|
||||
" dump_json,\n",
|
||||
" plot_json,\n",
|
||||
" create_via,\n",
|
||||
" create_pad,\n",
|
||||
" create_pin,\n",
|
||||
" create_track,\n",
|
||||
" create_silk,\n",
|
||||
" create_silk,\n",
|
||||
" create_mounting_hole,\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"from enum import Enum\n",
|
||||
"\n",
|
||||
|
@ -44,11 +49,22 @@
|
|||
"VIA_DIAM = 0.8\n",
|
||||
"VIA_DRILL = 0.4\n",
|
||||
"# this is for a 1.27mm pitch pin\n",
|
||||
"PAD_DIAM = 1.0\n",
|
||||
"PAD_DRILL = 0.65\n",
|
||||
"PIN_DIAM = 1.0\n",
|
||||
"PIN_DRILL = 0.65\n",
|
||||
"\n",
|
||||
"# this is for the PCB connector - see https://www.farnell.com/datasheets/2003059.pdf\n",
|
||||
"PAD_WIDTH = 6\n",
|
||||
"PAD_HEIGHT = 2\n",
|
||||
"PAD_PITCH = 2.5\n",
|
||||
"\n",
|
||||
"# where to put the input pads\n",
|
||||
"INPUT_PAD_RADIUS = 19.5\n",
|
||||
"\n",
|
||||
"# PCB Edge size\n",
|
||||
"STATOR_RADIUS = 18\n",
|
||||
"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",
|
||||
"\n",
|
||||
"# Track width and spacing\n",
|
||||
|
@ -242,6 +258,8 @@
|
|||
"tracks_f = []\n",
|
||||
"tracks_b = []\n",
|
||||
"pads = []\n",
|
||||
"pins = []\n",
|
||||
"mounting_holes = []\n",
|
||||
"silk = []\n",
|
||||
"\n",
|
||||
"# create the pads at CONNECTION_PINS radius - 2 for each of the coils, A, B and C\n",
|
||||
|
@ -370,9 +388,9 @@
|
|||
"vias.append(create_via(get_arc_point(5 * 360 / 12, outer_connection_radius_C)))\n",
|
||||
"vias.append(create_via(get_arc_point(8 * 360 / 12, outer_connection_radius_C)))\n",
|
||||
"\n",
|
||||
"# create pads for the input\n",
|
||||
"for angle in range(0, 360, 15):\n",
|
||||
" pads.append(create_pad(CONNECTION_PINS_RADIUS, angle, \"A\"))\n",
|
||||
"# create pins for the input\n",
|
||||
"# for angle in range(0, 360, 15):\n",
|
||||
"# pins.append(create_pin(CONNECTION_PINS_RADIUS, angle, \"A\"))\n",
|
||||
"\n",
|
||||
"# coils_f[0].append(get_arc_point(0, CONNECTION_PINS_RADIUS))\n",
|
||||
"# coils_f[1].append(get_arc_point(1 * 360 / 12, CONNECTION_PINS_RADIUS))\n",
|
||||
|
@ -380,7 +398,18 @@
|
|||
"\n",
|
||||
"# coils_f[0].append(get_arc_point(15, CONNECTION_PINS_RADIUS))\n",
|
||||
"# coils_f[1].append(get_arc_point(15 + 1 * 360 / 12, CONNECTION_PINS_RADIUS))\n",
|
||||
"# coils_f[2].append(get_arc_point(15 + 2 * 360 / 12, CONNECTION_PINS_RADIUS))"
|
||||
"# coils_f[2].append(get_arc_point(15 + 2 * 360 / 12, CONNECTION_PINS_RADIUS))\n",
|
||||
"\n",
|
||||
"# create mounting holes at 45 degree angles\n",
|
||||
"mounting_holes = [\n",
|
||||
" create_mounting_hole(get_arc_point(angle, SCREW_HOLE_RADIUS), SCREW_HOLE_DRILL_DIAM)\n",
|
||||
" for angle in [45, 135, 225, 315]\n",
|
||||
"]\n",
|
||||
"\n",
|
||||
"# create the pads for connecting the inputs to the coils\n",
|
||||
"pads.append(create_pad((INPUT_PAD_RADIUS, -PAD_PITCH), PAD_WIDTH, PAD_HEIGHT, \"b\"))\n",
|
||||
"pads.append(create_pad((INPUT_PAD_RADIUS, 0), PAD_WIDTH, PAD_HEIGHT, \"b\"))\n",
|
||||
"pads.append(create_pad((INPUT_PAD_RADIUS, PAD_PITCH), PAD_WIDTH, PAD_HEIGHT, \"b\"))"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -395,15 +424,17 @@
|
|||
" STATOR_RADIUS,\n",
|
||||
" STATOR_HOLE_RADIUS,\n",
|
||||
" TRACK_WIDTH,\n",
|
||||
" PAD_DIAM,\n",
|
||||
" PAD_DRILL,\n",
|
||||
" PIN_DIAM,\n",
|
||||
" PIN_DRILL,\n",
|
||||
" VIA_DIAM,\n",
|
||||
" VIA_DRILL,\n",
|
||||
" vias,\n",
|
||||
" pins,\n",
|
||||
" pads,\n",
|
||||
" silk,\n",
|
||||
" tracks_f,\n",
|
||||
" tracks_b,\n",
|
||||
" mounting_holes,\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
|
|
|
@ -23,11 +23,16 @@
|
|||
" flip_x,\n",
|
||||
" optimize_points,\n",
|
||||
" chaikin,\n",
|
||||
")\n",
|
||||
"from pcb_json import (\n",
|
||||
" dump_json,\n",
|
||||
" plot_json,\n",
|
||||
" create_pad,\n",
|
||||
" create_silk,\n",
|
||||
" create_via,\n",
|
||||
" create_mounting_hole,\n",
|
||||
" create_pin,\n",
|
||||
")\n",
|
||||
"from pcb_json import dump_json, plot_json\n",
|
||||
"\n",
|
||||
"from enum import Enum\n",
|
||||
"\n",
|
||||
|
@ -43,13 +48,23 @@
|
|||
"VIA_DIAM = 0.8\n",
|
||||
"VIA_DRILL = 0.4\n",
|
||||
"# this is for a 1.27mm pitch pin\n",
|
||||
"PAD_DIAM = 1.0\n",
|
||||
"PAD_DRILL = 0.65\n",
|
||||
"PIN_DIAM = 1.0\n",
|
||||
"PIN_DRILL = 0.65\n",
|
||||
"\n",
|
||||
"# this is for the PCB connector - see https://www.farnell.com/datasheets/2003059.pdf\n",
|
||||
"PAD_WIDTH = 6\n",
|
||||
"PAD_HEIGHT = 2\n",
|
||||
"PAD_PITCH = 2.5\n",
|
||||
"\n",
|
||||
"# PCB Edge size\n",
|
||||
"STATOR_RADIUS = 18\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",
|
||||
"\n",
|
||||
"# where to put the input pads\n",
|
||||
"INPUT_PAD_RADIUS = 19.5\n",
|
||||
"\n",
|
||||
"# Track width and spacing\n",
|
||||
"TRACK_WIDTH = 0.127\n",
|
||||
"TRACK_SPACING = 0.127\n",
|
||||
|
@ -57,6 +72,10 @@
|
|||
"# Coil params\n",
|
||||
"TURNS = 18\n",
|
||||
"COIL_CENTER_RADIUS = 11.5\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",
|
||||
"\n",
|
||||
"# where to place the pins\n",
|
||||
"CONNECTION_PINS_RADIUS = 16.5\n",
|
||||
"\n",
|
||||
|
@ -295,22 +314,13 @@
|
|||
"vias = []\n",
|
||||
"tracks_f = []\n",
|
||||
"tracks_b = []\n",
|
||||
"pins = []\n",
|
||||
"pads = []\n",
|
||||
"\n",
|
||||
"angle_A = 0\n",
|
||||
"angle_B = 120\n",
|
||||
"angle_C = 240\n",
|
||||
"\n",
|
||||
"# create the pads at CONNECTION_PINS radius - 2 for each of the coils, A, B and C\n",
|
||||
"pads.append(create_pad(CONNECTION_PINS_RADIUS, angle_A - 30, \"A\"))\n",
|
||||
"pads.append(create_pad(CONNECTION_PINS_RADIUS, angle_A + 30, \"A\"))\n",
|
||||
"\n",
|
||||
"pads.append(create_pad(CONNECTION_PINS_RADIUS, angle_B - 30, \"B\"))\n",
|
||||
"pads.append(create_pad(CONNECTION_PINS_RADIUS, angle_B + 30, \"B\"))\n",
|
||||
"\n",
|
||||
"pads.append(create_pad(CONNECTION_PINS_RADIUS, angle_C - 30, \"C\"))\n",
|
||||
"pads.append(create_pad(CONNECTION_PINS_RADIUS, angle_C + 30, \"C\"))\n",
|
||||
"\n",
|
||||
"# the main coils\n",
|
||||
"coil_A_f = translate(rotate(points_f, angle_A), COIL_CENTER_RADIUS, angle_A)\n",
|
||||
"coil_A_b = translate(rotate(points_b, angle_A), COIL_CENTER_RADIUS, angle_A)\n",
|
||||
|
@ -368,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 = STATOR_RADIUS - (VIA_DIAM / 2 + TRACK_SPACING)\n",
|
||||
"common_connection_radius = MAX_TRACK_RADIUS - (VIA_DIAM / 2 + TRACK_SPACING)\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",
|
||||
|
@ -380,27 +390,6 @@
|
|||
"vias.append(create_via(get_arc_point(angle_B_opp, common_connection_radius)))\n",
|
||||
"vias.append(create_via(get_arc_point(angle_C_opp, common_connection_radius)))\n",
|
||||
"\n",
|
||||
"# connect the coils to the pads\n",
|
||||
"coil_A_f.append(get_arc_point(angle_A, common_connection_radius))\n",
|
||||
"coil_B_f.append(get_arc_point(angle_B, common_connection_radius))\n",
|
||||
"coil_C_f.append(get_arc_point(angle_C, common_connection_radius))\n",
|
||||
"\n",
|
||||
"tracks_f.append(\n",
|
||||
" [get_arc_point(angle_A - 30, CONNECTION_PINS_RADIUS)]\n",
|
||||
" + draw_arc(angle_A - 30, angle_A + 30, common_connection_radius)\n",
|
||||
" + [get_arc_point(angle_A + 30, CONNECTION_PINS_RADIUS)]\n",
|
||||
")\n",
|
||||
"tracks_f.append(\n",
|
||||
" [get_arc_point(angle_B - 30, CONNECTION_PINS_RADIUS)]\n",
|
||||
" + draw_arc(angle_B - 30, angle_B + 30, common_connection_radius)\n",
|
||||
" + [get_arc_point(angle_B + 30, CONNECTION_PINS_RADIUS)]\n",
|
||||
")\n",
|
||||
"tracks_f.append(\n",
|
||||
" [get_arc_point(angle_C - 30, CONNECTION_PINS_RADIUS)]\n",
|
||||
" + draw_arc(angle_C - 30, angle_C + 30, common_connection_radius)\n",
|
||||
" + [get_arc_point(angle_C + 30, CONNECTION_PINS_RADIUS)]\n",
|
||||
")\n",
|
||||
"\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",
|
||||
|
@ -451,7 +440,68 @@
|
|||
" create_silk(get_arc_point(angle_A, COIL_CENTER_RADIUS), \"A\"),\n",
|
||||
" create_silk(get_arc_point(angle_B, COIL_CENTER_RADIUS), \"B\"),\n",
|
||||
" create_silk(get_arc_point(angle_C, COIL_CENTER_RADIUS), \"C\"),\n",
|
||||
"]"
|
||||
"]\n",
|
||||
"\n",
|
||||
"# create mounting holes at 45 degree angles\n",
|
||||
"mounting_holes = [\n",
|
||||
" create_mounting_hole(get_arc_point(angle, SCREW_HOLE_RADIUS), SCREW_HOLE_DRILL_DIAM)\n",
|
||||
" for angle in [45, 135, 225, 315]\n",
|
||||
"]\n",
|
||||
"\n",
|
||||
"# connect the coils to the input pads\n",
|
||||
"# coil_A_f.append(get_arc_point(angle_A, common_connection_radius))\n",
|
||||
"# coil_B_f.append(get_arc_point(angle_B, common_connection_radius))\n",
|
||||
"# coil_C_f.append(get_arc_point(angle_C, common_connection_radius))\n",
|
||||
"\n",
|
||||
"# tracks_f.append(\n",
|
||||
"# [get_arc_point(angle_A - 30, CONNECTION_PINS_RADIUS)]\n",
|
||||
"# + draw_arc(angle_A - 30, angle_A + 30, common_connection_radius)\n",
|
||||
"# + [get_arc_point(angle_A + 30, CONNECTION_PINS_RADIUS)]\n",
|
||||
"# )\n",
|
||||
"# tracks_f.append(\n",
|
||||
"# [get_arc_point(angle_B - 30, CONNECTION_PINS_RADIUS)]\n",
|
||||
"# + draw_arc(angle_B - 30, angle_B + 30, common_connection_radius)\n",
|
||||
"# + [get_arc_point(angle_B + 30, CONNECTION_PINS_RADIUS)]\n",
|
||||
"# )\n",
|
||||
"# tracks_f.append(\n",
|
||||
"# [get_arc_point(angle_C - 30, CONNECTION_PINS_RADIUS)]\n",
|
||||
"# + draw_arc(angle_C - 30, angle_C + 30, common_connection_radius)\n",
|
||||
"# + [get_arc_point(angle_C + 30, CONNECTION_PINS_RADIUS)]\n",
|
||||
"# )\n",
|
||||
"\n",
|
||||
"# create the pins at CONNECTION_PINS radius - 2 for each of the coils, A, B and C\n",
|
||||
"# pins.append(create_pin(CONNECTION_PINS_RADIUS, angle_A - 30, \"A\"))\n",
|
||||
"# pins.append(create_pin(CONNECTION_PINS_RADIUS, angle_A + 30, \"A\"))\n",
|
||||
"\n",
|
||||
"# pins.append(create_pin(CONNECTION_PINS_RADIUS, angle_B - 30, \"B\"))\n",
|
||||
"# pins.append(create_pin(CONNECTION_PINS_RADIUS, angle_B + 30, \"B\"))\n",
|
||||
"\n",
|
||||
"# pins.append(create_pin(CONNECTION_PINS_RADIUS, angle_C - 30, \"C\"))\n",
|
||||
"# pins.append(create_pin(CONNECTION_PINS_RADIUS, angle_C + 30, \"C\"))\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"# create the pads for connecting the inputs to the coils\n",
|
||||
"pads.append(create_pad((-PAD_PITCH, INPUT_PAD_RADIUS), PAD_HEIGHT, PAD_WIDTH, \"b\"))\n",
|
||||
"pads.append(create_pad((0, INPUT_PAD_RADIUS), PAD_HEIGHT, PAD_WIDTH, \"b\"))\n",
|
||||
"pads.append(create_pad((PAD_PITCH, INPUT_PAD_RADIUS), PAD_HEIGHT, PAD_WIDTH, \"b\"))\n",
|
||||
"\n",
|
||||
"# connect coil A to the top pad\n",
|
||||
"coil_A_f.append((INPUT_PAD_RADIUS, PAD_PITCH))\n",
|
||||
"# connect coil B to the middle pad\n",
|
||||
"input_pad_connection_radius = STATOR_RADIUS - TRACK_SPACING - TRACK_WIDTH\n",
|
||||
"tracks_f.append(\n",
|
||||
" [(INPUT_PAD_RADIUS, 0)] + draw_arc(0, angle_B, input_pad_connection_radius, 5)\n",
|
||||
")\n",
|
||||
"# connect coil C to the bottom pad\n",
|
||||
"tracks_f.append(\n",
|
||||
" draw_arc(angle_C, 350, input_pad_connection_radius, 5)\n",
|
||||
" + [(INPUT_PAD_RADIUS, -PAD_PITCH)]\n",
|
||||
")\n",
|
||||
"coil_B_f.append(get_arc_point(angle_B, input_pad_connection_radius))\n",
|
||||
"coil_C_f.append(get_arc_point(angle_C, input_pad_connection_radius))\n",
|
||||
"vias.append(create_via((INPUT_PAD_RADIUS, 0)))\n",
|
||||
"vias.append(create_via((INPUT_PAD_RADIUS, PAD_PITCH)))\n",
|
||||
"vias.append(create_via((INPUT_PAD_RADIUS, -PAD_PITCH)))"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -466,15 +516,17 @@
|
|||
" STATOR_RADIUS,\n",
|
||||
" STATOR_HOLE_RADIUS,\n",
|
||||
" TRACK_WIDTH,\n",
|
||||
" PAD_DIAM,\n",
|
||||
" PAD_DRILL,\n",
|
||||
" PIN_DIAM,\n",
|
||||
" PIN_DRILL,\n",
|
||||
" VIA_DIAM,\n",
|
||||
" VIA_DRILL,\n",
|
||||
" vias,\n",
|
||||
" pins,\n",
|
||||
" pads,\n",
|
||||
" silk,\n",
|
||||
" tracks_f,\n",
|
||||
" tracks_b,\n",
|
||||
" mounting_holes,\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
|
|
|
@ -44,8 +44,8 @@ class CoilPlugin(pcbnew.ActionPlugin):
|
|||
track_width = coil_data["parameters"]["trackWidth"]
|
||||
stator_hole_radius = coil_data["parameters"]["statorHoleRadius"]
|
||||
stator_radius = coil_data["parameters"]["statorRadius"]
|
||||
pad_diameter = coil_data["parameters"]["padDiameter"]
|
||||
pad_drill = coil_data["parameters"]["padDrillDiameter"]
|
||||
pin_diameter = coil_data["parameters"]["pinDiameter"]
|
||||
pin_drill = coil_data["parameters"]["pinDrillDiameter"]
|
||||
via_diameter = coil_data["parameters"]["viaDiameter"]
|
||||
via_drill_diameter = coil_data["parameters"]["viaDrillDiameter"]
|
||||
|
||||
|
@ -82,21 +82,39 @@ class CoilPlugin(pcbnew.ActionPlugin):
|
|||
board.Add(pcb_via)
|
||||
# pcb_group.AddItem(pcb_via)
|
||||
|
||||
# create the pads
|
||||
for pad in coil_data["pads"]:
|
||||
# create the pins
|
||||
for pin in coil_data["pins"]:
|
||||
module = pcbnew.FOOTPRINT(board)
|
||||
module.SetPosition(pcbnew.wxPointMM(pad["x"], pad["y"]))
|
||||
module.SetPosition(pcbnew.wxPointMM(pin["x"], pin["y"]))
|
||||
board.Add(module)
|
||||
pcb_pad = pcbnew.PAD(module)
|
||||
pcb_pad.SetSize(pcbnew.wxSizeMM(pad_diameter, pad_diameter))
|
||||
pcb_pad.SetSize(pcbnew.wxSizeMM(pin_diameter, pin_diameter))
|
||||
pcb_pad.SetShape(pcbnew.PAD_SHAPE_CIRCLE)
|
||||
pcb_pad.SetAttribute(pcbnew.PAD_ATTRIB_PTH)
|
||||
pcb_pad.SetLayerSet(pcb_pad.PTHMask())
|
||||
pcb_pad.SetDrillSize(pcbnew.wxSizeMM(pad_drill, pad_drill))
|
||||
pcb_pad.SetPosition(pcbnew.wxPointMM(pad["x"], pad["y"]))
|
||||
pcb_pad.SetDrillSize(pcbnew.wxSizeMM(pin_drill, pin_drill))
|
||||
pcb_pad.SetPosition(pcbnew.wxPointMM(pin["x"], pin["y"]))
|
||||
pcb_pad.SetNetCode(net.GetNetCode())
|
||||
module.Add(pcb_pad)
|
||||
|
||||
# create the pads
|
||||
lset = pcbnew.LSET()
|
||||
lset.AddLayer(pcbnew.B_Cu)
|
||||
for pin in coil_data["pads"]:
|
||||
module = pcbnew.FOOTPRINT(board)
|
||||
module.SetPosition(pcbnew.wxPointMM(pin["x"], pin["y"]))
|
||||
board.Add(module)
|
||||
pcb_pad = pcbnew.PAD(module)
|
||||
pcb_pad.SetSize(pcbnew.wxSizeMM(pin["width"], pin["height"]))
|
||||
pcb_pad.SetShape(pcbnew.PAD_SHAPE_RECT)
|
||||
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.SetNetCode(net.GetNetCode())
|
||||
pcb_pad.Flip(pcbnew.wxPointMM(pin["x"], pin["y"]), False)
|
||||
module.Add(pcb_pad)
|
||||
|
||||
# create any silk screen
|
||||
for text in coil_data["silk"]:
|
||||
pcb_txt = pcbnew.PCB_TEXT(board)
|
||||
|
@ -108,14 +126,13 @@ class CoilPlugin(pcbnew.ActionPlugin):
|
|||
board.Add(pcb_txt)
|
||||
# pcb_group.AddItem(pcb_txt)
|
||||
|
||||
|
||||
# create the stator outline
|
||||
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.SetCenter(pcbnew.wxPointMM(0, 0))
|
||||
arc.SetLayer(pcbnew.Edge_Cuts)
|
||||
arc.SetWidth(int(0.1 * pcbnew.IU_PER_MM))
|
||||
board.Add(arc)
|
||||
|
@ -133,4 +150,5 @@ class CoilPlugin(pcbnew.ActionPlugin):
|
|||
board.Add(arc)
|
||||
# pcb_group.AddItem(arc)
|
||||
|
||||
|
||||
CoilPlugin().register() # Instantiate and register to Pcbnew])
|
||||
|
|
BIN
coils.png
Normal file
BIN
coils.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 420 KiB |
24
helpers.py
24
helpers.py
|
@ -49,30 +49,6 @@ def flip_x(points):
|
|||
return [[-x, y] for x, y in points]
|
||||
|
||||
|
||||
def create_pad(radius, angle, name):
|
||||
return {
|
||||
"x": radius * np.cos(np.deg2rad(angle)),
|
||||
"y": radius * np.sin(np.deg2rad(angle)),
|
||||
"name": name,
|
||||
}
|
||||
|
||||
|
||||
def create_silk(point, text):
|
||||
return {
|
||||
"x": point[0],
|
||||
"y": point[1],
|
||||
"text": text,
|
||||
}
|
||||
|
||||
|
||||
def create_via(point):
|
||||
return {"x": point[0], "y": point[1]}
|
||||
|
||||
|
||||
def create_track(points):
|
||||
return [{"x": x, "y": y} for x, y in points]
|
||||
|
||||
|
||||
def optimize_points(points):
|
||||
# follow the line and remove points that are in the same direction as the previous poin
|
||||
# keep doing this until the direction changes significantly
|
||||
|
|
163
pcb_json.py
163
pcb_json.py
|
@ -1,26 +1,71 @@
|
|||
import json
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
|
||||
def create_pin(radius, angle, name):
|
||||
return {
|
||||
"x": radius * np.cos(np.deg2rad(angle)),
|
||||
"y": radius * np.sin(np.deg2rad(angle)),
|
||||
"name": name,
|
||||
}
|
||||
|
||||
|
||||
def create_pad(point, width, height, layer):
|
||||
return {
|
||||
"x": point[0],
|
||||
"y": point[1],
|
||||
"width": width,
|
||||
"height": height,
|
||||
"layer": layer,
|
||||
}
|
||||
|
||||
|
||||
def create_silk(point, text):
|
||||
return {
|
||||
"x": point[0],
|
||||
"y": point[1],
|
||||
"text": text,
|
||||
}
|
||||
|
||||
|
||||
def create_via(point):
|
||||
return {"x": point[0], "y": point[1]}
|
||||
|
||||
|
||||
def create_track(points):
|
||||
return [{"x": x, "y": y} for x, y in points]
|
||||
|
||||
|
||||
def create_mounting_hole(point, diameter):
|
||||
return {
|
||||
"x": point[0],
|
||||
"y": point[1],
|
||||
"diameter": diameter,
|
||||
}
|
||||
|
||||
|
||||
def create_track_json(points):
|
||||
return [{"x": x, "y": y} for x, y in points]
|
||||
|
||||
|
||||
def dump_json(
|
||||
filename,
|
||||
stator_radius,
|
||||
stator_hole_radius,
|
||||
track_width,
|
||||
pad_diam,
|
||||
pad_drill,
|
||||
pin_diam,
|
||||
pin_drill,
|
||||
via_diam,
|
||||
via_drill,
|
||||
vias,
|
||||
pins,
|
||||
pads,
|
||||
silk,
|
||||
tracks_f,
|
||||
tracks_b,
|
||||
mounting_holes,
|
||||
):
|
||||
# dump out the results to json
|
||||
json_result = {
|
||||
|
@ -30,16 +75,18 @@ def dump_json(
|
|||
"statorRadius": stator_radius,
|
||||
"viaDiameter": via_diam,
|
||||
"viaDrillDiameter": via_drill,
|
||||
"padDiameter": pad_diam,
|
||||
"padDrillDiameter": pad_drill,
|
||||
"pinDiameter": pin_diam,
|
||||
"pinDrillDiameter": pin_drill,
|
||||
},
|
||||
"vias": vias,
|
||||
"pins": pins,
|
||||
"pads": pads,
|
||||
"silk": silk,
|
||||
"tracks": {
|
||||
"f": [create_track(points) for points in tracks_f],
|
||||
"b": [create_track(points) for points in tracks_b],
|
||||
"f": [create_track_json(points) for points in tracks_f],
|
||||
"b": [create_track_json(points) for points in tracks_b],
|
||||
},
|
||||
"mounting_holes": mounting_holes,
|
||||
}
|
||||
json.dump(json_result, open(filename, "w"))
|
||||
return json_result
|
||||
|
@ -48,8 +95,8 @@ def dump_json(
|
|||
def plot_json(json_result):
|
||||
stator_radius = json_result["parameters"]["statorRadius"]
|
||||
stator_hole_radius = json_result["parameters"]["statorHoleRadius"]
|
||||
pad_diam = json_result["parameters"]["padDiameter"]
|
||||
pad_drill = json_result["parameters"]["padDrillDiameter"]
|
||||
pin_diam = json_result["parameters"]["pinDiameter"]
|
||||
pin_drill = json_result["parameters"]["pinDrillDiameter"]
|
||||
# track_width = json_result["parameters"]["trackWidth"]
|
||||
via_dim = json_result["parameters"]["viaDiameter"]
|
||||
via_drill = json_result["parameters"]["viaDrillDiameter"]
|
||||
|
@ -69,7 +116,57 @@ def plot_json(json_result):
|
|||
# hide the legend
|
||||
ax.legend().set_visible(False)
|
||||
# make the plot bigger
|
||||
ax.figure.set_size_inches(10, 10)
|
||||
ax.figure.set_size_inches(11, 11)
|
||||
|
||||
# set the axis range
|
||||
ax.set_xlim(-stator_radius - 1, stator_radius + 1)
|
||||
ax.set_ylim(-stator_radius - 1, stator_radius + 1)
|
||||
|
||||
# plot the pads
|
||||
for pad in json_result["pads"]:
|
||||
color = "red"
|
||||
if pad["layer"] == "b":
|
||||
color = "blue"
|
||||
ax.add_patch(
|
||||
plt.Rectangle(
|
||||
(pad["x"] - pad["width"] / 2, pad["y"] - pad["height"] / 2),
|
||||
pad["width"],
|
||||
pad["height"],
|
||||
fill=True,
|
||||
color=color,
|
||||
)
|
||||
)
|
||||
|
||||
# plot the pins
|
||||
for pin in json_result["pins"]:
|
||||
ax.add_patch(
|
||||
plt.Circle(
|
||||
(pin["x"], pin["y"]),
|
||||
radius=pin_diam / 2,
|
||||
fill=True,
|
||||
color="orange",
|
||||
)
|
||||
)
|
||||
ax.add_patch(
|
||||
plt.Circle(
|
||||
(pin["x"], pin["y"]),
|
||||
radius=pin_drill / 2,
|
||||
fill=True,
|
||||
color="white",
|
||||
)
|
||||
)
|
||||
|
||||
# plot the silk
|
||||
for silk in json_result["silk"]:
|
||||
ax.text(
|
||||
silk["x"],
|
||||
silk["y"],
|
||||
silk["text"],
|
||||
horizontalalignment="center",
|
||||
verticalalignment="center",
|
||||
color="black",
|
||||
fontsize=50,
|
||||
)
|
||||
|
||||
# plot the vias
|
||||
for via in json_result["vias"]:
|
||||
|
@ -90,13 +187,24 @@ def plot_json(json_result):
|
|||
)
|
||||
)
|
||||
|
||||
# plot the mounting holes
|
||||
for hole in json_result["mounting_holes"]:
|
||||
ax.add_patch(
|
||||
plt.Circle(
|
||||
(hole["x"], hole["y"]),
|
||||
radius=hole["diameter"] / 2,
|
||||
fill=False,
|
||||
color="orange",
|
||||
)
|
||||
)
|
||||
|
||||
# plot the edge cuts
|
||||
ax.add_patch(
|
||||
plt.Circle(
|
||||
(0, 0),
|
||||
radius=stator_radius,
|
||||
fill=False,
|
||||
color="yellow",
|
||||
color="orange",
|
||||
)
|
||||
)
|
||||
ax.add_patch(
|
||||
|
@ -104,37 +212,8 @@ def plot_json(json_result):
|
|||
(0, 0),
|
||||
radius=stator_hole_radius,
|
||||
fill=False,
|
||||
color="yellow",
|
||||
color="orange",
|
||||
)
|
||||
)
|
||||
|
||||
# plot the pads
|
||||
for pad in json_result["pads"]:
|
||||
ax.add_patch(
|
||||
plt.Circle(
|
||||
(pad["x"], pad["y"]),
|
||||
radius=pad_diam / 2,
|
||||
fill=True,
|
||||
color="yellow",
|
||||
)
|
||||
)
|
||||
ax.add_patch(
|
||||
plt.Circle(
|
||||
(pad["x"], pad["y"]),
|
||||
radius=pad_drill / 2,
|
||||
fill=True,
|
||||
color="white",
|
||||
)
|
||||
)
|
||||
|
||||
# plot the silk
|
||||
for silk in json_result["silk"]:
|
||||
ax.text(
|
||||
silk["x"],
|
||||
silk["y"],
|
||||
silk["text"],
|
||||
horizontalalignment="center",
|
||||
verticalalignment="center",
|
||||
color="black",
|
||||
fontsize=50,
|
||||
)
|
||||
# save to file
|
||||
ax.figure.savefig("coils.png")
|
||||
|
|
Loading…
Reference in a new issue