コード例 #1
0
def read_kicadpcb(kicadpcb_file):
    """ Open the board file, read the modules and extract the placement
    data.
    """
    board = PN.LoadBoard(kicadpcb_file)
    board_bb = board.ComputeBoundingBox(True)
    bot_left_x = board_bb.GetLeft()
    bot_left_y = board_bb.GetBottom()
    result_mods = {}
    for module in board.GetModules():
        rot = module.GetOrientation() / 10.0
        module_rect = getFootprintRect(module, upright=True)
        x_size = PN.ToMils(module_rect.GetWidth())
        y_size = PN.ToMils(module_rect.GetHeight())
        designator = module.GetReference()
        module_center = module_rect.Centre()
        result_mods[designator] = {
            "DESIGNATOR": designator,
            "VALUE": module.GetValue(),
            "X_SIZE": x_size,
            "Y_SIZE": y_size,
            "ROTATION": rot,
            "SIDE": "top" if (module.GetLayer() is PN.F_Cu) else
            "bot",  #1/T/top for Top, 2/B/bot/bottom for Bottom
            "TYPE": "SMD" if
            (isModuleSMD(module)) else "PTH",  #1/SMT/SMD for SMD, 2 for PTH
            "X_LOC": PN.ToMils(module_center.x - bot_left_x),
            "Y_LOC": PN.ToMils(bot_left_y - module_center.y),
            "FOOTPRINT": "",  #C0805, R0603, TQFP-100
            "POPULATE": "1"  #1 for populate, 0 for do not populate
        }
    return result_mods
コード例 #2
0
def get_MacroFab_xyrs_data(parts, include_th = True):

    def footprint_type(t):
        if t.lower() == 'smt':
            return 1
        return 2

    def populate_val(i):
        if i:
            return 1
        return 0

    spec_dict = collections.OrderedDict([
            ('reference',        ('Designator', lambda x: '%s'%x)), 
            ('bbox_pos_x',       ('X-Loc',      lambda x: '%.2f'%pcbnew.ToMils(x))), 
            ('bbox_pos_y',       ('Y-Loc',      lambda x: '%.2f'%pcbnew.ToMils(x))), 
            ('rotation_deg',     ('Rotation',   lambda x: '%.0f'%x)), 
            ('side',             ('Side',       lambda x: '%s'%x)), 
            ('footprint_type',   ('Type',       lambda x: '%s'%footprint_type(x))), 
            ('size_x',           ('X-Size',     lambda x: '%.2f'%pcbnew.ToMils(x))), 
            ('size_y',           ('Y-Size',     lambda x: '%.2f'%pcbnew.ToMils(x))), 
            ('value',            ('Value',      lambda x: '%s'%x)), 
            ('footprint',        ('Footprint',  lambda x: '%s'%x)), 
            ('populate',         ('Populate',   lambda x: '%d'%populate_val(x))), 
            ('manuf part',       ('MPN',        lambda x: '%s'%x)), 
            ]) 

    return get_data_str(
            parts,
            spec_dict,
            separator = '\t',
            populated_only = True,
            smt_only = not include_th,
            file_doc = '#Units used = mils / deg',
            header_on = True,
            header_prefix = '#'
            )
コード例 #3
0
def report_teed_lengths(groupname, netname, target_length, tolerance):
    global dbg_conn

    print(groupname, netname)
    nc = pcb.GetNetcodeFromNetname(netname)
    #print("nc", nc)

    pads = nets[netname].Pads()

    # convert from std::vector<> to python list
    pads = list(pads)
    #print_pads(netname, pads )

    cpu_pad = find_cpu_pad(pads)
    pads.remove(cpu_pad)

    # a trap for a troublesome net that appears to be disconnected or has stray segments.
    if netname == None:
    #if netname == '/DDR3/DRAM_SDCKE0':
        dbg_conn = True

    # find the first T
    #print_pads(netname + ' without cpu pad', pads )
    t1 = find_connected_pad(cpu_pad, pads)
    pads.remove(t1)

    # find 2 second tier T pads
    t2_1 = find_connected_pad(t1, pads)
    pads.remove(t2_1)

    t2_2 = find_connected_pad(t1, pads)
    pads.remove(t2_2)

    cpad = [0] * 4

    # find 4 memory pads off of each 2nd tier T
    cpad[0] = find_connected_pad(t2_1, pads)
    pads.remove(cpad[0])

    cpad[1] = find_connected_pad(t2_1, pads)
    pads.remove(cpad[1])

    cpad[2] = find_connected_pad(t2_2, pads)
    pads.remove(cpad[2])

    cpad[3] = find_connected_pad(t2_2, pads)
    pads.remove(cpad[3])

    len_t1   = sum_track_lengths(cpu_pad.GetPosition(),t1.GetPosition(),nc)
    #print("len_t1 %.0f" % len_t1)

    len_t2_1 = sum_track_lengths(t1.GetPosition(),t2_1.GetPosition(),nc)
    len_t2_2 = sum_track_lengths(t1.GetPosition(),t2_2.GetPosition(),nc)
    #print("len_t2_1 %.0f" % len_t2_1)
    #print("len_t2_2 %.0f" % len_t2_2)

    lens = [0] * 4

    lens[0] = sum_track_lengths(t2_1.GetPosition(),cpad[0].GetPosition(),nc)
    lens[1] = sum_track_lengths(t2_1.GetPosition(),cpad[1].GetPosition(),nc)
    lens[2] = sum_track_lengths(t2_2.GetPosition(),cpad[2].GetPosition(),nc)
    lens[3] = sum_track_lengths(t2_2.GetPosition(),cpad[3].GetPosition(),nc)

    """
    for index, total_len in enumerate(lens):
        print( "%s: %.0f" % (pad_name(cpad[index]), lens[index]))
    """

    # Each net goes from CPU to four memory chips, these are the 4 lengths from
    # CPU to each of the for memory chip balls/pads, some of these journeys are
    # common with one another but branch off at each T.
    lens[0] += len_t1 + len_t2_1
    lens[1] += len_t1 + len_t2_1
    lens[2] += len_t1 + len_t2_2
    lens[3] += len_t1 + len_t2_2

    for index, total_len in enumerate(lens):
        delta = total_len - target_length
        if delta > tolerance:
            print_color( BRIGHTRED, "%s %s len:%.0f long by %.0f mils" %
                  (netname, pad_name(cpad[index]), pcbnew.ToMils(total_len), pcbnew.ToMils(delta - tolerance)  ))
        elif delta < -tolerance:
            print_color( BRIGHTRED, "%s %s len:%.0f short by %.0f mils" %
                  (netname, pad_name(cpad[index]), pcbnew.ToMils(total_len), pcbnew.ToMils(tolerance - delta) ))
コード例 #4
0
ファイル: pcbnew_misc.py プロジェクト: nhatkhai/kicad_scripts
def ToInch(a):
    if isinstance(a, pcbnew.wxPoint):
        return pcbnew.wxPoint(pcbnew.ToMils(a.x / 1000.0),
                              pcbnew.ToMils(a.y / 1000.0))
    else:
        return pcbnew.ToMils(a / 1000.0)
コード例 #5
0
ファイル: pnt.py プロジェクト: orihikarna/Hermit
def unit2mils(pnt):
    return (pcbnew.ToMils(pnt[0]), pcbnew.ToMils(pnt[1]))