From c7725fe573a55554ced00b17f9e1103a6a0948a9 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Fri, 15 Nov 2024 16:06:00 +0000 Subject: [PATCH] Revert to 1/4" rails. Position the fiducials at 1/4 of the width --- SparkFunKiCadPanelizer/panelizer/panelizer.py | 41 +++++++++++++------ SparkFunKiCadPanelizer/plugin.py | 8 ++-- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/SparkFunKiCadPanelizer/panelizer/panelizer.py b/SparkFunKiCadPanelizer/panelizer/panelizer.py index c1a0119..75af457 100644 --- a/SparkFunKiCadPanelizer/panelizer/panelizer.py +++ b/SparkFunKiCadPanelizer/panelizer/panelizer.py @@ -73,6 +73,7 @@ def args_parse(self, args): ) parser.add_argument("--hrail", type=float, default="0.0", help="Horizontal edge rail width (mm)") parser.add_argument("--vrail", type=float, default="0.0", help="Vertical edge rail width (mm)") + parser.add_argument("--hrailtext", help="Text to put on the horizontal edge rail") parser.add_argument("--vrailtext", help="Text to put on the vertical edge rail") parser.add_argument( @@ -108,6 +109,11 @@ def args_parse(self, args): parser.add_argument( "--fiducialstb", action="store_true", help="Add panel fiducials top and bottom" ) + parser.add_argument( + "--fiducialpos", type=float, default="0.5", + help="Position the fiducials at this fraction of the rail width, default 0.5" + ) + parser.add_argument( "--exposeedge", action="store_true", help="Expose PCB bottom edge - e.g. for M.2 cards" ) @@ -190,6 +196,7 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None): TITLE_Y = args.vtitle FIDUCIALS_LR = args.fiducialslr FIDUCIALS_TB = args.fiducialstb + FIDUCIAL_POS = args.fiducialpos EXPOSED_EDGE = args.exposeedge # Check if this is running in a plugin @@ -280,21 +287,31 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None): sysExit = 2 return sysExit, report + # Check the fiducial position + if (FIDUCIAL_POS < 0.0) or (FIDUCIAL_POS > 1.0): + report += "Invalid fiducial position. Quitting.\n" + sysExit = 2 + return sysExit, report + # Check the fiducials if FIDUCIALS_LR: - if (VERTICAL_EDGE_RAIL_WIDTH < (FIDUCIAL_MASK + 1)): - report += "Cannot add L+R fiducials - edge rails not wide enough.\n" + fiducialExtent = (abs(0.5 - FIDUCIAL_POS) * VERTICAL_EDGE_RAIL_WIDTH) + (FIDUCIAL_MASK / 2) + clampClearance = VERTICAL_EDGE_RAIL_WIDTH - ((FIDUCIAL_POS * VERTICAL_EDGE_RAIL_WIDTH) + (FIDUCIAL_MASK / 2)) + if fiducialExtent >= (VERTICAL_EDGE_RAIL_WIDTH / 2): + report += "Cannot add L+R fiducials at the selected position - edge rails not wide enough.\n" FIDUCIALS_LR = False sysExit = 1 - elif (((VERTICAL_EDGE_RAIL_WIDTH - FIDUCIAL_MASK) / 2) < FIDUCIAL_CLAMP_CLEARANCE): + elif clampClearance < FIDUCIAL_CLAMP_CLEARANCE: report += "Vertical edge rails do not provide adequate clamp clearance.\n" sysExit = 1 if FIDUCIALS_TB: - if (HORIZONTAL_EDGE_RAIL_WIDTH < (FIDUCIAL_MASK + 1)): - report += "Cannot add T+B fiducials - edge rails not wide enough.\n" + fiducialExtent = (abs(0.5 - FIDUCIAL_POS) * HORIZONTAL_EDGE_RAIL_WIDTH) + (FIDUCIAL_MASK / 2) + clampClearance = HORIZONTAL_EDGE_RAIL_WIDTH - ((FIDUCIAL_POS * HORIZONTAL_EDGE_RAIL_WIDTH) + (FIDUCIAL_MASK / 2)) + if fiducialExtent >= (HORIZONTAL_EDGE_RAIL_WIDTH / 2): + report += "Cannot add T+B fiducials at the selected position - edge rails not wide enough.\n" FIDUCIALS_TB = False sysExit = 1 - elif (((HORIZONTAL_EDGE_RAIL_WIDTH - FIDUCIAL_MASK) / 2) < FIDUCIAL_CLAMP_CLEARANCE): + elif clampClearance < FIDUCIAL_CLAMP_CLEARANCE: report += "Horizontal edge rails do not provide adequate clamp clearance.\n" sysExit = 1 @@ -1015,34 +1032,34 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None): fiducials = [] if FIDUCIALS_LR: fiducials.append([ - int(panelCenter.x - (panelWidth / 2 - VERTICAL_EDGE_RAIL_WIDTH / 2 * SCALE)), + int(panelCenter.x - (panelWidth / 2 - VERTICAL_EDGE_RAIL_WIDTH * (1.0 - FIDUCIAL_POS) * SCALE)), int(panelCenter.y + (panelHeight / 2 - (SCALE * FIDUCIAL_OFFSET_FROM_RAIL + SCALE * HORIZONTAL_EDGE_RAIL_WIDTH))), FIDUCIAL_FOOTPRINT_BIG ]) fiducials.append([ - int(panelCenter.x - (panelWidth / 2 - VERTICAL_EDGE_RAIL_WIDTH / 2 * SCALE)), + int(panelCenter.x - (panelWidth / 2 - VERTICAL_EDGE_RAIL_WIDTH * (1.0 - FIDUCIAL_POS) * SCALE)), int(panelCenter.y - (panelHeight / 2 - (SCALE * FIDUCIAL_OFFSET_FROM_RAIL + SCALE * HORIZONTAL_EDGE_RAIL_WIDTH))), FIDUCIAL_FOOTPRINT_SMALL ]) fiducials.append([ - int(panelCenter.x + (panelWidth / 2 - VERTICAL_EDGE_RAIL_WIDTH / 2 * SCALE)), + int(panelCenter.x + (panelWidth / 2 - VERTICAL_EDGE_RAIL_WIDTH * (1.0 - FIDUCIAL_POS) * SCALE)), int(panelCenter.y - (panelHeight / 2 - (SCALE * FIDUCIAL_OFFSET_FROM_RAIL + SCALE * HORIZONTAL_EDGE_RAIL_WIDTH))), FIDUCIAL_FOOTPRINT_SMALL ]) if FIDUCIALS_TB: fiducials.append([ int(panelCenter.x - (panelWidth / 2 - (SCALE * FIDUCIAL_OFFSET_FROM_RAIL + SCALE * VERTICAL_EDGE_RAIL_WIDTH))), - int(panelCenter.y + (panelHeight / 2 - HORIZONTAL_EDGE_RAIL_WIDTH / 2 * SCALE)), + int(panelCenter.y + (panelHeight / 2 - HORIZONTAL_EDGE_RAIL_WIDTH * (1.0 - FIDUCIAL_POS) * SCALE)), FIDUCIAL_FOOTPRINT_BIG ]) fiducials.append([ int(panelCenter.x - (panelWidth / 2 - (SCALE * FIDUCIAL_OFFSET_FROM_RAIL + SCALE * VERTICAL_EDGE_RAIL_WIDTH))), - int(panelCenter.y - (panelHeight / 2 - HORIZONTAL_EDGE_RAIL_WIDTH / 2 * SCALE)), + int(panelCenter.y - (panelHeight / 2 - HORIZONTAL_EDGE_RAIL_WIDTH * (1.0 - FIDUCIAL_POS) * SCALE)), FIDUCIAL_FOOTPRINT_SMALL ]) fiducials.append([ int(panelCenter.x + (panelWidth / 2 - (SCALE * FIDUCIAL_OFFSET_FROM_RAIL + SCALE * VERTICAL_EDGE_RAIL_WIDTH))), - int(panelCenter.y - (panelHeight / 2 - HORIZONTAL_EDGE_RAIL_WIDTH / 2 * SCALE)), + int(panelCenter.y - (panelHeight / 2 - HORIZONTAL_EDGE_RAIL_WIDTH * (1.0 - FIDUCIAL_POS) * SCALE)), FIDUCIAL_FOOTPRINT_SMALL ]) for pos in fiducials: diff --git a/SparkFunKiCadPanelizer/plugin.py b/SparkFunKiCadPanelizer/plugin.py index c62b661..38defd0 100644 --- a/SparkFunKiCadPanelizer/plugin.py +++ b/SparkFunKiCadPanelizer/plugin.py @@ -134,11 +134,12 @@ def run_panelizer(dlg, p_panelizer): leftright = dlg.CurrentSettings()["productionFiducialsCheck"] if not exposeedge: if fiducials: - # Default the rail width to 3/8". + # Default the rail width to 1/4" and nudge by 1/4 of the rail width. # This provides the clearance needed for clamping and AOI Inspection of the fiducials. # This is nasty. The default should be in panelizer.py. But I can't think of a solution # which is good for everyone - including anyone running the panelizer from the command line. - command.extend(['--hrail','9.525','--vrail','9.525']) + command.extend(['--hrail','6.35','--vrail','6.35']) + command.extend(['--fiducialpos','0.25']) if leftright: command.append('--fiducialslr') else: @@ -146,7 +147,8 @@ def run_panelizer(dlg, p_panelizer): else: if fiducials: # Same comment as above - command.extend(['--vrail','9.525']) + command.extend(['--vrail','6.35']) + command.extend(['--fiducialpos','0.25']) command.append('--fiducialslr') self.logger.log(logging.INFO, command)