mirror of
https://github.com/atomic14/kicad-coil-plugins.git
synced 2024-10-18 09:06:57 +00:00
Move connections arouns
This commit is contained in:
parent
8ec2348d31
commit
a914baefd9
4 changed files with 70 additions and 45 deletions
|
@ -286,8 +286,13 @@
|
||||||
" coil_A_f = translate(rotate(points_f, angle), COIL_CENTER_RADIUS, angle)\n",
|
" coil_A_f = translate(rotate(points_f, angle), COIL_CENTER_RADIUS, angle)\n",
|
||||||
" coil_A_b = translate(rotate(points_b, angle), COIL_CENTER_RADIUS, angle)\n",
|
" coil_A_b = translate(rotate(points_b, angle), COIL_CENTER_RADIUS, angle)\n",
|
||||||
" else:\n",
|
" else:\n",
|
||||||
" coil_A_f = translate(rotate(flip_y(points_f), angle), COIL_CENTER_RADIUS, angle)\n",
|
" # slightly nudge the coils so that they don't overlap when flipped\n",
|
||||||
" coil_A_b = translate(rotate(flip_y(points_b), angle), COIL_CENTER_RADIUS, angle)\n",
|
" coil_A_f = translate(\n",
|
||||||
|
" rotate(flip_y(points_f), angle - 2), COIL_CENTER_RADIUS, angle\n",
|
||||||
|
" )\n",
|
||||||
|
" coil_A_b = translate(\n",
|
||||||
|
" rotate(flip_y(points_b), angle - 2), COIL_CENTER_RADIUS, angle\n",
|
||||||
|
" )\n",
|
||||||
" # keep track of the coils\n",
|
" # keep track of the coils\n",
|
||||||
" coils_f.append(coil_A_f)\n",
|
" coils_f.append(coil_A_f)\n",
|
||||||
" coils_b.append(coil_A_b)\n",
|
" coils_b.append(coil_A_b)\n",
|
||||||
|
@ -300,7 +305,7 @@
|
||||||
" )\n",
|
" )\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# raidus for connecting the bottoms of the coils together\n",
|
"# raidus for connecting the bottoms of the coils together\n",
|
||||||
"connection_radius1 = STATOR_HOLE_RADIUS + TRACK_SPACING + TRACK_WIDTH\n",
|
"connection_radius1 = STATOR_HOLE_RADIUS + 0.5\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# create tracks to link the A coils around the center\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 + TRACK_SPACING + VIA_DIAM / 2\n",
|
||||||
|
@ -356,14 +361,14 @@
|
||||||
"vias.append(create_via(coil_C3_C4_inner[-1]))\n",
|
"vias.append(create_via(coil_C3_C4_inner[-1]))\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# connect the last three coils together\n",
|
"# connect the last three coils together\n",
|
||||||
"common_connection_radius = STATOR_RADIUS - TRACK_SPACING - TRACK_WIDTH\n",
|
"common_connection_radius = SCREW_HOLE_RADIUS - (SCREW_HOLE_DRILL_DIAM / 2 + 0.5)\n",
|
||||||
"tracks_f.append(draw_arc(9 * 360 / 12, 11 * 360 / 12, common_connection_radius))\n",
|
"tracks_f.append(draw_arc(9 * 360 / 12, 11 * 360 / 12, common_connection_radius))\n",
|
||||||
"coils_f[9].append(get_arc_point(9 * 360 / 12, common_connection_radius))\n",
|
"coils_f[9].append(get_arc_point(9 * 360 / 12, common_connection_radius))\n",
|
||||||
"coils_f[10].append(get_arc_point(10 * 360 / 12, common_connection_radius))\n",
|
"coils_f[10].append(get_arc_point(10 * 360 / 12, common_connection_radius))\n",
|
||||||
"coils_f[11].append(get_arc_point(11 * 360 / 12, common_connection_radius))\n",
|
"coils_f[11].append(get_arc_point(11 * 360 / 12, common_connection_radius))\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# connect the outer A coils together\n",
|
"# connect the outer A coils together\n",
|
||||||
"outer_connection_radius_A = STATOR_RADIUS - TRACK_SPACING - TRACK_WIDTH\n",
|
"outer_connection_radius_A = SCREW_HOLE_RADIUS + (SCREW_HOLE_DRILL_DIAM / 2 + 0.5)\n",
|
||||||
"tracks_f.append(draw_arc(3 * 360 / 12, 6 * 360 / 12, outer_connection_radius_A))\n",
|
"tracks_f.append(draw_arc(3 * 360 / 12, 6 * 360 / 12, outer_connection_radius_A))\n",
|
||||||
"coils_f[3].append(get_arc_point(3 * 360 / 12, outer_connection_radius_A))\n",
|
"coils_f[3].append(get_arc_point(3 * 360 / 12, outer_connection_radius_A))\n",
|
||||||
"coils_f[6].append(get_arc_point(6 * 360 / 12, outer_connection_radius_A))\n",
|
"coils_f[6].append(get_arc_point(6 * 360 / 12, outer_connection_radius_A))\n",
|
||||||
|
@ -381,7 +386,8 @@
|
||||||
"vias.append(create_via(get_arc_point(7 * 360 / 12, outer_connection_radius_B)))\n",
|
"vias.append(create_via(get_arc_point(7 * 360 / 12, outer_connection_radius_B)))\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# connect the outer C coilds together\n",
|
"# connect the outer C coilds together\n",
|
||||||
"outer_connection_radius_C = outer_connection_radius_B - TRACK_SPACING - VIA_DIAM / 2\n",
|
"outer_connection_radius_C = SCREW_HOLE_RADIUS - (SCREW_HOLE_DRILL_DIAM / 2 + 0.5)\n",
|
||||||
|
"# outer_connection_radius_C = outer_connection_radius_B - TRACK_SPACING - VIA_DIAM / 2\n",
|
||||||
"tracks_b.append(draw_arc(5 * 360 / 12, 8 * 360 / 12, outer_connection_radius_C))\n",
|
"tracks_b.append(draw_arc(5 * 360 / 12, 8 * 360 / 12, outer_connection_radius_C))\n",
|
||||||
"coils_f[5].append(get_arc_point(5 * 360 / 12, outer_connection_radius_C))\n",
|
"coils_f[5].append(get_arc_point(5 * 360 / 12, outer_connection_radius_C))\n",
|
||||||
"coils_f[8].append(get_arc_point(8 * 360 / 12, outer_connection_radius_C))\n",
|
"coils_f[8].append(get_arc_point(8 * 360 / 12, outer_connection_radius_C))\n",
|
||||||
|
@ -407,6 +413,14 @@
|
||||||
"]\n",
|
"]\n",
|
||||||
"\n",
|
"\n",
|
||||||
"# create the pads for connecting the inputs to the coils\n",
|
"# create the pads for connecting the inputs to the coils\n",
|
||||||
|
"silk.append(\n",
|
||||||
|
" create_silk((INPUT_PAD_RADIUS - PAD_HEIGHT - 2.5, PAD_PITCH), \"C\", \"b\", 2.5, -900)\n",
|
||||||
|
")\n",
|
||||||
|
"silk.append(create_silk((INPUT_PAD_RADIUS - PAD_HEIGHT - 2.5, 0), \"B\", \"b\", 2.5, -900))\n",
|
||||||
|
"silk.append(\n",
|
||||||
|
" create_silk((INPUT_PAD_RADIUS - PAD_HEIGHT - 2.5, -PAD_PITCH), \"A\", \"b\", 2.5, -900)\n",
|
||||||
|
")\n",
|
||||||
|
"\n",
|
||||||
"pads.append(create_pad((INPUT_PAD_RADIUS, -PAD_PITCH), PAD_WIDTH, PAD_HEIGHT, \"b\"))\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, 0), PAD_WIDTH, PAD_HEIGHT, \"b\"))\n",
|
||||||
"pads.append(create_pad((INPUT_PAD_RADIUS, PAD_PITCH), PAD_WIDTH, PAD_HEIGHT, \"b\"))\n",
|
"pads.append(create_pad((INPUT_PAD_RADIUS, PAD_PITCH), PAD_WIDTH, PAD_HEIGHT, \"b\"))\n",
|
||||||
|
|
|
@ -448,45 +448,22 @@
|
||||||
" for angle in [45, 135, 225, 315]\n",
|
" for angle in [45, 135, 225, 315]\n",
|
||||||
"]\n",
|
"]\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",
|
"# create the pads for connecting the inputs to the coils\n",
|
||||||
|
"silk.append(\n",
|
||||||
|
" create_silk((-PAD_PITCH, INPUT_PAD_RADIUS - PAD_HEIGHT - 2.5), \"C\", \"b\", 2.5)\n",
|
||||||
|
")\n",
|
||||||
"pads.append(create_pad((-PAD_PITCH, 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",
|
||||||
|
"silk.append(create_silk((0, INPUT_PAD_RADIUS - PAD_HEIGHT - 2.5), \"B\", \"b\", 2.5))\n",
|
||||||
"pads.append(create_pad((0, INPUT_PAD_RADIUS), PAD_HEIGHT, PAD_WIDTH, \"b\"))\n",
|
"pads.append(create_pad((0, INPUT_PAD_RADIUS), PAD_HEIGHT, PAD_WIDTH, \"b\"))\n",
|
||||||
|
"\n",
|
||||||
|
"silk.append(\n",
|
||||||
|
" create_silk((PAD_PITCH, INPUT_PAD_RADIUS - PAD_HEIGHT - 2.5), \"A\", \"b\", 2.5)\n",
|
||||||
|
")\n",
|
||||||
"pads.append(create_pad((PAD_PITCH, 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",
|
"\n",
|
||||||
"# connect coil A to the middle pad\n",
|
"# connect coil A to the middle pad\n",
|
||||||
"input_pad_connection_radius = STATOR_RADIUS - TRACK_SPACING - TRACK_WIDTH\n",
|
"input_pad_connection_radius = SCREW_HOLE_RADIUS + SCREW_HOLE_DRILL_DIAM / 2 + 0.5\n",
|
||||||
"tracks_f.append(\n",
|
"tracks_f.append(\n",
|
||||||
" draw_arc(angle_A, 80, input_pad_connection_radius, 5)\n",
|
" draw_arc(angle_A, 80, input_pad_connection_radius, 5)\n",
|
||||||
" + [(PAD_PITCH, INPUT_PAD_RADIUS + VIA_DIAM)]\n",
|
" + [(PAD_PITCH, INPUT_PAD_RADIUS + VIA_DIAM)]\n",
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import pcbnew
|
import pcbnew
|
||||||
import json
|
import json
|
||||||
import wx
|
import wx
|
||||||
|
import math
|
||||||
|
|
||||||
|
|
||||||
def create_tracks(board, group, net, layer, thickness, coords):
|
def create_tracks(board, group, net, layer, thickness, coords):
|
||||||
|
@ -121,11 +122,38 @@ class CoilPlugin(pcbnew.ActionPlugin):
|
||||||
pcb_txt.SetText(text["text"])
|
pcb_txt.SetText(text["text"])
|
||||||
pcb_txt.SetPosition(pcbnew.wxPointMM(text["x"], text["y"]))
|
pcb_txt.SetPosition(pcbnew.wxPointMM(text["x"], text["y"]))
|
||||||
pcb_txt.SetHorizJustify(pcbnew.GR_TEXT_HJUSTIFY_CENTER)
|
pcb_txt.SetHorizJustify(pcbnew.GR_TEXT_HJUSTIFY_CENTER)
|
||||||
pcb_txt.SetTextSize(pcbnew.wxSize(5000000, 5000000))
|
pcb_txt.Rotate(
|
||||||
|
pcbnew.wxPointMM(text["x"], text["y"]), text["angle"]
|
||||||
|
)
|
||||||
|
pcb_txt.SetTextSize(
|
||||||
|
pcbnew.wxSize(
|
||||||
|
text["size"] * pcbnew.IU_PER_MM,
|
||||||
|
text["size"] * pcbnew.IU_PER_MM,
|
||||||
|
)
|
||||||
|
)
|
||||||
pcb_txt.SetLayer(pcbnew.F_SilkS)
|
pcb_txt.SetLayer(pcbnew.F_SilkS)
|
||||||
|
if text["layer"] == "b":
|
||||||
|
pcb_txt.Flip(pcbnew.wxPointMM(text["x"], text["y"]), True)
|
||||||
board.Add(pcb_txt)
|
board.Add(pcb_txt)
|
||||||
# pcb_group.AddItem(pcb_txt)
|
# pcb_group.AddItem(pcb_txt)
|
||||||
|
|
||||||
|
# create the mounting holes
|
||||||
|
for hole in coil_data["mountingHoles"]:
|
||||||
|
module = pcbnew.FOOTPRINT(board)
|
||||||
|
module.SetPosition(pcbnew.wxPointMM(hole["x"], hole["y"]))
|
||||||
|
board.Add(module)
|
||||||
|
pcb_pad = pcbnew.PAD(module)
|
||||||
|
pcb_pad.SetSize(pcbnew.wxSizeMM(hole["diameter"], hole["diameter"]))
|
||||||
|
pcb_pad.SetShape(pcbnew.PAD_SHAPE_CIRCLE)
|
||||||
|
pcb_pad.SetAttribute(pcbnew.PAD_ATTRIB_NPTH)
|
||||||
|
# pcb_pad.SetLayerSet(pcb_pad.NPTHMask())
|
||||||
|
pcb_pad.SetDrillSize(
|
||||||
|
pcbnew.wxSizeMM(hole["diameter"], hole["diameter"])
|
||||||
|
)
|
||||||
|
pcb_pad.SetPosition(pcbnew.wxPointMM(hole["x"], hole["y"]))
|
||||||
|
module.Add(pcb_pad)
|
||||||
|
# pcb_group.AddItem(pcb_hole)
|
||||||
|
|
||||||
# create the stator outline
|
# create the stator outline
|
||||||
arc = pcbnew.PCB_SHAPE(board)
|
arc = pcbnew.PCB_SHAPE(board)
|
||||||
arc.SetShape(pcbnew.SHAPE_T_CIRCLE)
|
arc.SetShape(pcbnew.SHAPE_T_CIRCLE)
|
||||||
|
|
16
pcb_json.py
16
pcb_json.py
|
@ -22,11 +22,14 @@ def create_pad(point, width, height, layer):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def create_silk(point, text):
|
def create_silk(point, text, layer="f", size=5, angle=0):
|
||||||
return {
|
return {
|
||||||
"x": point[0],
|
"x": point[0],
|
||||||
"y": point[1],
|
"y": point[1],
|
||||||
"text": text,
|
"text": text,
|
||||||
|
"layer": layer,
|
||||||
|
"size": size,
|
||||||
|
"angle": angle,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,7 +89,7 @@ def dump_json(
|
||||||
"f": [create_track_json(points) for points in tracks_f],
|
"f": [create_track_json(points) for points in tracks_f],
|
||||||
"b": [create_track_json(points) for points in tracks_b],
|
"b": [create_track_json(points) for points in tracks_b],
|
||||||
},
|
},
|
||||||
"mounting_holes": mounting_holes,
|
"mountingHoles": mounting_holes,
|
||||||
}
|
}
|
||||||
json.dump(json_result, open(filename, "w"))
|
json.dump(json_result, open(filename, "w"))
|
||||||
return json_result
|
return json_result
|
||||||
|
@ -158,14 +161,17 @@ def plot_json(json_result):
|
||||||
|
|
||||||
# plot the silk
|
# plot the silk
|
||||||
for silk in json_result["silk"]:
|
for silk in json_result["silk"]:
|
||||||
|
color = "cyan"
|
||||||
|
if silk["layer"] == "b":
|
||||||
|
color = "magenta"
|
||||||
ax.text(
|
ax.text(
|
||||||
silk["x"],
|
silk["x"],
|
||||||
silk["y"],
|
silk["y"],
|
||||||
silk["text"],
|
silk["text"],
|
||||||
horizontalalignment="center",
|
horizontalalignment="center",
|
||||||
verticalalignment="center",
|
verticalalignment="center",
|
||||||
color="black",
|
color=color,
|
||||||
fontsize=50,
|
fontsize=silk["size"] * 10,
|
||||||
)
|
)
|
||||||
|
|
||||||
# plot the vias
|
# plot the vias
|
||||||
|
@ -188,7 +194,7 @@ def plot_json(json_result):
|
||||||
)
|
)
|
||||||
|
|
||||||
# plot the mounting holes
|
# plot the mounting holes
|
||||||
for hole in json_result["mounting_holes"]:
|
for hole in json_result["mountingHoles"]:
|
||||||
ax.add_patch(
|
ax.add_patch(
|
||||||
plt.Circle(
|
plt.Circle(
|
||||||
(hole["x"], hole["y"]),
|
(hole["x"], hole["y"]),
|
||||||
|
|
Loading…
Reference in a new issue