[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-user: My footprint generator



Hi all,

I coded up this footprint generator for SMT caps, with the data stored in a template file. It should be readily extensible for different types (the function= attribute is the name of the method to call). Would one of you be willing to look at the footprint to see if it is what you want to include in gEDA? I'm willing to perfect this tool and make it a valuable addition to gEDA.

Sorry Perl-heads, but I don't know it well enough so it's in Python.

You can generate all the footprints by feeding the .fpt file to the standard-in of the python program.

Datasheet for cap:
http://www.chemi-con.co.jp/pdf/catalog/al-e1001g/al-mva-e-060905.pdf

Thanks,
Cory Cross

p.s.
If attachments don't go across the list, I'll paste the (rather small) files to one of those sites and resend the link.
Element["" "MVA smt electrolytic cap, E55 case" "" "" 0 0 -15511 14433 0 100 ""]
(
	Pad[-11677 0 -6692 0 7874 1200 9074 "Positive" "1" "square"]
	Pad[11677 0 6692 0 7874 1200 9074 "Negative" "2" "square"]
	ElementLine [-17614 9389 -17614 -9389 1000]
	ElementLine [-17614 9389 -15614 12433 1000]
	ElementLine [-17614 -9389 -15614 -12433 1000]
	ElementLine [-15614 12433 17614 12433 1000]
	ElementLine [-15614 -12433 17614 -12433 1000]
	ElementLine [17614 12433 17614 -12433 1000]
	ElementLine [18614 6216 18614 -6216 2000]
)
system=mm
function=smt_polarized_cap
MVA_D55`MVA smt electrolytic cap, D55 case`4`5.2`4.3`4.3`5.1`2`1
MVA_E55`MVA smt electrolytic cap, E55 case`5`5.2`5.3`5.3`5.9`2`1.4
MVA_F55`MVA smt electrolytic cap, F55 case`6.3`5.2`6.6`6.6`7.2`2`1.9
MVA_F60`MVA smt electrolytic cap, F60 case`6.3`5.7`6.6`6.6`7.2`2`1.9
MVA_F80`MVA smt electrolytic cap, F80 case`6.3`7.7`6.6`6.6`7.2`2`1.9
MVA_HA0`MVA smt electrolytic cap, HA0 case`8`10.0`8.3`8.3`9.0`2.8`3.1
MVA_JA0`MVA smt electrolytic cap, JA0 case`10`10.0`10.3`10.3`11.0`2.8`4.5
MVA_KE0`MVA smt electrolytic cap, KE0 case`12.5`13.5`13.0`13.0`13.7`3.6`4.2
MVA_KG5`MVA smt electrolytic cap, KG5 case`12.5`16.0`13.0`13.0`13.7`3.6`4.2
MVA_LH0`MVA smt electrolytic cap, LH0 case`16`16.5`17.0`17.0`18.0`3.6`6.5
MVA_LN0`MVA smt electrolytic cap, LN0 case`16`21.5`17.0`17.0`18.0`3.6`6.5
MVA_MH0`MVA smt electrolytic cap, MH0 case`18`16.5`19.0`19.0`20.0`3.6`6.5
MVA_MN0`MVA smt electrolytic cap, MN0 case`18`21.5`19.0`19.0`20.0`3.6`6.5
#!/usr/bin/env python
from string import atof

class FpGenerator:
    def save( self ):
        f = open( self.SAVEDIR + self.filename, 'w' )
        f.write( self.element )
        f.close()
        if __name__ == '__main__':
            import sys
            sys.stderr.write('Saved to ' + self.SAVEDIR + self.filename + '\n' )

    def getMilth( self, value ):
        if ( self.system == 'inch' ):
            return int(value * 100000)
        elif ( self.system == 'mm' ):
            return int(value * 3937.0079)
        elif ( self.system == 'mil' ):
            return int(value * 100)

    def smt_polarized_cap(self, fileptr):
        for line in fileptr.readlines():
            ll = line.split('`')
            (diameter, height, width, length, pin_to_pin_length, pad_width, pin_spacing_length) = [self.getMilth(atof(inval.strip())) for inval in ll[2:]]
            filename = ll[0] + '.fp'
            #Set up the beginning of the element string, with description
            # and mark point of (0,0)
            element = 'Element["" "' + ll[1] + '" "" "" 0 0 '
            #Calculate where to place the text, append to element string, and add rest of header
            element += str( -10000 - pin_spacing_length ) + ' ' + str( 4000 + width/2 ) + ' 0 100 ""]\n('

            #Generate pads (square)
            ph = pad_header = '\n\tPad['
            extra_pad_length = 4000
            pad_length = extra_pad_length + pin_to_pin_length/2 - pin_spacing_length/2
            if(pad_width > pad_length):
                x_coord = pad_length/2 + pin_spacing_length/2
                y_coord = pad_width/2 - pad_length/2
                x2_coord = x_coord
            else:
                x_coord = pin_to_pin_length/2 + extra_pad_length - pad_width/2
                x2_coord = pin_spacing_length/2 + pad_width/2
                y_coord = 0
            trace_width = min(pad_length,pad_width)
            element += ph + ' '.join([str(i) for i in (-x_coord, y_coord, -x2_coord, -y_coord, trace_width, 1200, trace_width+1200)]) + ' "Positive" "1" "square"]'
            element += ph + ' '.join([str(i) for i in (x_coord, y_coord, x2_coord, -y_coord, trace_width, 1200, trace_width+1200)]) + ' "Negative" "2" "square"]'
            
            #Generate silkscreen outline
            sh = silk_header = '\n\tElementLine ['
            silk_line_space = 2000
            ##Left line, 
            element += sh + ' '.join([str(int(i)) for i in (-((pin_to_pin_length/2+extra_pad_length) + silk_line_space), .9*width/2, -((pin_to_pin_length/2+extra_pad_length) + silk_line_space), -.9*width/2, 1000)]) + ']'
            ##Mitered corners
            element += sh + ' '.join([str(int(i)) for i in (-((pin_to_pin_length/2+extra_pad_length) + silk_line_space), .9*width/2, -(pin_to_pin_length/2+extra_pad_length), width/2+silk_line_space, 1000)]) + ']'
            element += sh + ' '.join([str(int(i)) for i in (-((pin_to_pin_length/2+extra_pad_length) + silk_line_space), -.9*width/2, -(pin_to_pin_length/2+extra_pad_length), -(width/2+silk_line_space), 1000)]) + ']'
            ##Sides
            element += sh + ' '.join([str(int(i)) for i in (-(pin_to_pin_length/2+extra_pad_length), width/2+silk_line_space, (pin_to_pin_length/2+extra_pad_length)+silk_line_space, width/2+silk_line_space, 1000)]) + ']'
            element += sh + ' '.join([str(int(i)) for i in (-(pin_to_pin_length/2+extra_pad_length), -(width/2+silk_line_space), (pin_to_pin_length/2+extra_pad_length)+silk_line_space, -(width/2+silk_line_space), 1000)]) + ']'
            ##Negative End
            element += sh + ' '.join([str(int(i)) for i in ((pin_to_pin_length/2+extra_pad_length)+silk_line_space, width/2+silk_line_space, (pin_to_pin_length/2+extra_pad_length)+silk_line_space, -(width/2+silk_line_space), 1000)]) + ']'
            element += sh + ' '.join([str(int(i)) for i in ((pin_to_pin_length/2+extra_pad_length)+silk_line_space+1000, .5*(width/2+silk_line_space), (pin_to_pin_length/2+extra_pad_length)+silk_line_space+1000, -.5*(width/2+silk_line_space), 2000)]) + ']'
            #Ending
            element += '\n)\n'
            #Save element
            self.filename = filename
            self.element = element
            self.save()

    def load( self, fileptr ):
        self.system = fileptr.readline().split('=')[1][:-1]
        func = getattr(self, fileptr.readline().split('=')[1][:-1])
        func(fileptr)

    #Need trailing /
    SAVEDIR="/home/cory/gaf/pcb-elements/"


if __name__ == '__main__':
    import sys

    FpGenerator.SAVEDIR="/tmp/"
    n = FpGenerator()
    n.load(sys.stdin)

_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user