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

Re: gEDA-user: footprints needed



Below is the footprint for a Belton VT8 tube socket and the Perl script
that created it (my perl library Pcb_8 is required). You should be
able to generate
similar footprints by updating the data section. I will add the script
to my website in a few weeks.

NB: This was a quick hack with numerous interruptions. If you decide to
use the script or the footprint you need to carefully verify the output.

--
http://www.luciani.org


---------- footprint -----------
Element[0x0 "TH" "" "" 0 0 29527 -83740 0 100 0x0]
(
   Pin[11580 -31816 10000 2000 12000 6700 "" "1" 0x0101]
   Pin[-14309 -30686 10000 2000 12000 6700 "" "2" 0x01]
   Pin[-31816 -11580 10000 2000 12000 6700 "" "3" 0x01]
   Pin[-30686 14309 10000 2000 12000 6700 "" "4" 0x01]
   Pin[-11580 31816 10000 2000 12000 6700 "" "5" 0x01]
   Pin[14309 30686 10000 2000 12000 6700 "" "6" 0x01]
   Pin[31816 11580 10000 2000 12000 6700 "" "7" 0x01]
   Pin[30686 -14309 10000 2000 12000 6700 "" "8" 0x01]
   ElementArc[0 0 59055 59055 0 360 1000]
   ElementArc[0 -78740 19685 19685 210 122 1000]
   ElementLine[-17047 88582 -51143 29527 1000]
   ElementLine[17047 88582 51143 29527 1000]
   Pin[0 -78740 13779 2000 15779 13779 "" "8" 0x01]
   ElementArc[0 -78740 7889 7889 0 360 1000]
   ElementArc[0 78740 19685 19685 30 122 1000]
   ElementLine[-17047 -88582 -51143 -29527 1000]
   ElementLine[17047 -88582 51143 -29527 1000]
   Pin[0 78740 13779 2000 15779 13779 "" "9" 0x01]
   ElementArc[0 78740 7889 7889 0 360 1000]
)

----------- script -------------------
#!/usr/bin/perl

# Copyright (C) 2005 John C. Luciani Jr.

# This program may be distributed or modified under the terms of
# version 0.1 of the No-Fee Software License published by
# John C. Luciani Jr.

# Creates a footprint for a Belton VT8 series tube socket

use strict;
use warnings;
use Math::Trig;

use Pcb_8 qw(:DEFAULT PIN_MOUNTING_HOLE);

use constant LINE_THICKNESS => 0.254; # 10 mils
use constant MASK_CLEARANCE => 0.254;
use constant COPPER_CLEARANCE => 0.254;

my $Pcb = Pcb_8 -> new(debug => 0);

my @Fields; # field names that are defined in the data section
my @Def;    # definitions that are common to all components

while (<DATA>) {
    s/\#.*//; # Remove comments
    s/^\s*//; # Remove leading spaces
    s/\s*$//; # Revove trailing spaces
    next unless length;    # Skip empty lines
    if (s/\\\s*$//) {      # Remove the continuation backslash and
	$_ .= <DATA>;      # append the next line to $_ then
	redo unless eof;   # restart the loop block after the conditional
    }

    # Lines that contain an '=' are global definitions.

    @Fields = split(/\s+/, $1), next if /^\s*fields\s*=\s*(\S.*)/;
    push(@Def, $1, $2), next if /(\S+)\s*=\s*(\S.*)/;

    my @values = split /\s*\|\s*/;

    # hash for each footprint

    my %f = ( @Def,
	      map { $_ => shift(@values) } @Fields);

    $Pcb -> element_begin(description => 'TH',
			  output_file => "tmp/" . &package_name(%f),
			  dim   => 'mm',
			  pin_one_square => 1);

    my $angle = $f{start_angle};
    my $pin_num;
    foreach (1..$f{pin_count}) {
	$pin_num = $_;
	&place_pin(radius => $f{pin_placement_diameter}/2,
		   angle => $angle,
		   pad_thickness => $f{pad_thickness},
		   drill_hole => $f{drill_hole},
		   pin_number => $pin_num);
	$angle += $f{delta_angle};
    }

    # body circle

    $Pcb -> element_add_arc(x => 0,
 			    y => 0,
 			    width => $f{body_diameter}/2,
 			    height=> $f{body_diameter}/2,
 			    start_angle => 0,
 			    delta_angle => 360,
 			    thickness => LINE_THICKNESS);

    # add the tabs and the mounting holes.

    foreach my $y (-$f{mounting_hole_spacing}/2, $f{mounting_hole_spacing}/2) {
	&add_tab(%f, x => 0, y => $y);
	$Pcb -> element_add_pin(x => 0, y => $y,
				thickness  => $f{mounting_hole_diameter},
				drill_hole => $f{mounting_hole_diameter},
				mask       => MASK_CLEARANCE,
				clearance  => COPPER_CLEARANCE,
				pin_number => $pin_num++,
				pin_flags  => PIN_MOUNTING_HOLE);
	$Pcb -> element_add_arc(x => 0, y => $y,
				width      => $f{mounting_hole_diameter}/2 + LINE_THICKNESS,
				height     => $f{mounting_hole_diameter}/2 + LINE_THICKNESS,
				start_angle => 0,
				delta_angle => 360,
				thickness => LINE_THICKNESS);
    }

    $Pcb -> element_set_text_xy(x => $f{body_diameter}/4,
 				y => -$f{mounting_hole_spacing}/2);

    $Pcb -> element_output();
}

sub add_tab {
    my %v = @_;
    my $y_sign = $v{y} > 0 ? 1 : -1;
    my $tab_radius = ($v{body_length} - $v{mounting_hole_spacing}) / 2;
    my $body_radius = $v{body_diameter} / 2;
    $Pcb -> element_add_arc(x => $v{x},
			    y => $v{y},
			    width => $tab_radius,
			    height=> $tab_radius,
			    start_angle => $y_sign > 0 ? 30 : 210,
			    delta_angle => 120+2,
			    thickness => LINE_THICKNESS);

    my ($x1, $y1) = &xy_pos(angle => 30,
 			    radius => $tab_radius);
    my ($x2, $y2) = &xy_pos(angle => 30,
			    radius => $body_radius);

    foreach my $x_sign (-1, 1) {
	$Pcb -> element_add_line(x1 => $x_sign * $x1,
				 y1 => $y_sign * ($y1 - $v{mounting_hole_spacing}/2),
				 x2 => $x_sign * $x2,
				 y2 => $y_sign * $y2,
				 thickness => LINE_THICKNESS);
    }

}


sub xy_pos  {
    my %v = @_;
    my $angle = deg2rad($v{angle});
    return(  $v{radius} * cos($angle),
	    -$v{radius} * sin($angle));
}

sub place_pin  {
    my %v = @_;
    my ($x, $y) = &xy_pos(%v);
    $Pcb -> element_add_pin(x => $x, y => $y,
			    thickness  => $v{pad_thickness},
			    drill_hole => $v{drill_hole},
			    mask       => MASK_CLEARANCE,
			    clearance  => COPPER_CLEARANCE,
			    pin_number => $v{pin_number});
}


sub package_name (%) {
    my %f = @_;
    sprintf("CON_TUBE__%s",
	    $f{mfg_pn});
}

__DATA__

drill_hole = 1.7018   # 67 mils
pad_thickness = 2.54  # 100 mils

# the tube socket consists of a circular body with tabs.
# the body_length is tab-to-tab. the body_diameter is the diameter
# of the circular body.

# mfg_pn
# pin_count  ............. number of pins
# pin_placement_radius ... radius that the pins are centered on
# start_angle ............ for pin one (0deg is on the positive
X-axis, angle increases ccw)
# delta_angle ............ angle between pins
# body_diameter .......... diameter of the circular body
# body_length ,,,,,....... tab-to-tab
# mounting_hole_spacing ..
# mounting_hole_diameter .

fields = mfg_pn pin_count pin_placement_diameter start_angle delta_angle\
         body_diameter body_length mounting_hole_spacing mounting_hole_diameter

CON_TUBE__Belton_VT8-PT | 8 | 17.2 | 70 | 45 |\
   30 | 50 | 40 | 3.5