Exemplo n.º 1
0
def write_trace_footprint(stream, name, description, vertices, trace_width, 
        pad_size, mirror=False):
    mirror = [1, -1][mirror]
    text_effects = SExpression('font', [SExpression('size', [1, 1]),
        SExpression('thickness', .15)])
    module = SExpression('module', [name,
        SExpression('layer', ['F.Cu']),
        SExpression('fp_text', [identifier('reference'), 'REF**'],
            [('at', [0, .5]), ('effects', text_effects), ('layer', 'F.SilkS')]),
        SExpression('fp_text', [identifier('value'), name],
            [('at', [0, -.5]), ('effects', text_effects),
                ('layer', 'F.SilkS')])])
    module.children.extend(SExpression('fp_line', [], [
        ('start', vertices[ii]), ('end', vertices[ii + 1]), ('layer', 'F.Cu'),
        ('width', trace_width)]) for ii in range(len(vertices) - 1))
    pad_offset = (pad_size - trace_width) / 2
    module.children.append(SExpression('pad', [1, identifier('smd'),
        identifier('rect')], [('at', (vertices[0][0] - pad_offset * mirror,
            vertices[0][1] + pad_offset)), ('size', [pad_size, pad_size]),
            ('layers', 'F.Cu')]))
    module.children.append(SExpression('pad', [2, identifier('smd'),
        identifier('rect')], [('at', (vertices[-1][0] - pad_offset * mirror,
            vertices[-1][1] - pad_offset)), ('size', [pad_size, pad_size]),
            ('layers', 'F.Cu')]))
    module.children.append(SExpression('descr', description))
    module.write_to_stream(stream)
Exemplo n.º 2
0
def write_trace_footprint(stream,
                          name,
                          description,
                          vertices,
                          trace_width,
                          pad_size,
                          mirror=False):
    mirror = [1, -1][mirror]
    text_effects = SExpression(
        'font', [SExpression('size', [1, 1]),
                 SExpression('thickness', .15)])
    module = SExpression('module', [
        name,
        SExpression('layer', ['F.Cu']),
        SExpression('fp_text', [identifier('reference'), 'REF**'],
                    [('at', [0, .5]), ('effects', text_effects),
                     ('layer', 'F.SilkS')]),
        SExpression('fp_text', [identifier('value'), name],
                    [('at', [0, -.5]), ('effects', text_effects),
                     ('layer', 'F.SilkS')])
    ])
    module.children.extend(
        SExpression('fp_line', [], [('start',
                                     vertices[ii]), ('end', vertices[ii + 1]),
                                    ('layer', 'F.Cu'), ('width', trace_width)])
        for ii in range(len(vertices) - 1))
    pad_offset = (pad_size - trace_width) / 2
    module.children.append(
        SExpression(
            'pad',
            [1, identifier('smd'), identifier('rect')],
            [('at', (vertices[0][0] - pad_offset * mirror,
                     vertices[0][1] + pad_offset)),
             ('size', [pad_size, pad_size]), ('layers', 'F.Cu')]))
    module.children.append(
        SExpression(
            'pad',
            [2, identifier('smd'), identifier('rect')],
            [('at', (vertices[-1][0] - pad_offset * mirror,
                     vertices[-1][1] - pad_offset)),
             ('size', [pad_size, pad_size]), ('layers', 'F.Cu')]))
    module.children.append(SExpression('descr', description))
    module.write_to_stream(stream)
Exemplo n.º 3
0
    else:
        pads = [
            (1, (coil[0][0] + pad_offset * args.mirror, 
                 coil[0][1] - pad_offset),
                 'rect'),
            (2, (coil[-1][0] - pad_offset * args.mirror,
                 coil[-1][1]),
                 'circle')]
        pad_locations = [
            (coil[0][0] + pad_offset * args.mirror, coil[0][1] - pad_offset),
            (coil[-1][0] - pad_offset * args.mirror, coil[-1][1] + pad_offset)]
    for number, location, shape in pads:
        module.children.append(SExpression('pad', [
            number, 
            identifier('smd'),
            identifier(shape)], [
                ('at', location),
                ('size', [pad_size, pad_size]),
                ('layers', 'F.Cu')]))
    descr = 'PCB inductor {}m x {}m {} turns {}m pitch'.format(
        si_prefix_format(side1*2e-3), si_prefix_format(side2*2e-3), 
        args.turns, si_prefix_format(pitch*1e-3))
    if args.fasthenry:
        descr += ' inductance {}H Q={:.1e} at {}Hz'.format(
            si_prefix_format(L), Q, si_prefix_format(args.frequency))
    descr += ' generated with https://github.com/ignamv/kicad_scripts'
    module.children.append(SExpression('descr', descr))
    module.write_to_stream(args.kicad_mod)
    args.kicad_mod.close()
    print('\nFootprint written to ' + args.kicad_mod.name)
Exemplo n.º 4
0
                     coil[0][1] + pad_offset), 'rect'),
                (2, (coil[-1][0] - pad_offset * args.mirror,
                     coil[-1][1] - pad_offset), 'rect')]
    else:
        pads = [(1, (coil[0][0] + pad_offset * args.mirror,
                     coil[0][1] - pad_offset), 'rect'),
                (2, (coil[-1][0] - pad_offset * args.mirror, coil[-1][1]),
                 'circle')]
        pad_locations = [
            (coil[0][0] + pad_offset * args.mirror, coil[0][1] - pad_offset),
            (coil[-1][0] - pad_offset * args.mirror, coil[-1][1] + pad_offset)
        ]
    for number, location, shape in pads:
        module.children.append(
            SExpression('pad',
                        [number, identifier('smd'),
                         identifier(shape)], [('at', location),
                                              ('size', [pad_size, pad_size]),
                                              ('layers', 'F.Cu')]))
    descr = 'PCB inductor {}m x {}m {} turns {}m pitch'.format(
        si_prefix_format(side1 * 2e-3), si_prefix_format(side2 * 2e-3),
        args.turns, si_prefix_format(pitch * 1e-3))
    if args.fasthenry:
        descr += ' inductance {}H Q={:.1e} at {}Hz'.format(
            si_prefix_format(L), Q, si_prefix_format(args.frequency))
    descr += ' generated with https://github.com/ignamv/kicad_scripts'
    module.children.append(SExpression('descr', descr))
    module.write_to_stream(args.kicad_mod)
    args.kicad_mod.close()
    print('\nFootprint written to ' + args.kicad_mod.name)