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

gEDA-user: Element Creation using Perl



I have created a Perl package (Pcb.pm) to aid in the
creation of newlib PCB elements. Below is an example
of a script that creates a TO-263 SMD power package.

Parameters are passed to each of the functions using
key-value pairs. Order does not matter.

The main commands are:

element_begin 

   start a new element.

element_add_pad_rectangle 

   create a pad that is bounded by two corners of a
   rectangle. A "Pad" command is generated and the    

   thickness is automatically calculated.

element_add_outline

   create a silkscreen outline rectangle around the  
   component. The  extents of the component are  
   calculated automatically each time a "Pad" or 
   "Pin" command is created. These extents are used in

   creating the outline.
   
element_add_mark

   generate a "Mark" command.

element_output

   output the Pcb element commands to a file.

If there is any interest in this package I will move
it
to an appropriate location. 

Some things to add ---

* better outline procedure(s)
* conversion of element commands to Metapost commands
  so that Postscript symbols may be created. This will
  allow the creation of a document that contains all
of
  the symbol packages.


### ------------ cut here --------------

#!/usr/bin/perl

use strict;
use warnings;

use Pcb;

my $Pcb = Pcb -> new;

$Pcb -> element_begin(description => 'TO263', 
                      output_file =>
'packages/TO263');

# The TO-263 surface mount power package 
# consists of a heatsink tab and seven signal pins. 
# The centroid for the package is the center of
# the heatsink tab.

# All dimensions are in mils. Data is from the 
# National Semiconductor LM2676 datasheeet.

### Create the signal pads

my $Pad_width    = 86; # one mil larger than the spec
to
                       # avoid rounding error that 
                       # would produce a smaller pad
my $Pad_height   = 36; 
my $Pad_spacing  = 50; # in the Y direction

# The distance from the centroid to pad column is
0.328". 
# There is one pad on center, three below and three
above.

my $X = 328; 
my $Y = 0 - 3 * $Pad_spacing;

foreach my $pin (1..7) {
    $Pcb -> element_add_pad_rectangle(x1 =>
$X-$Pad_width/2, 
                                      y1 =>
$Y-$Pad_height/2, 
                                      x2 =>
$X+$Pad_width/2, 
                                      y2 =>
$Y+$Pad_height/2,
                                      name => '', 
                                      pin_number =>
$pin);
    $Y += $Pad_spacing;
}

# Create the tab

my $Tab_width  = 410;
my $Tab_height = 426;
$Pcb -> element_add_pad_rectangle(x1 =>
0-$Tab_width/2, 
                                  y1 =>
0-$Tab_height/2, 
                                  x2 =>
0+$Tab_width/2, 
                                  y2 =>
0+$Tab_height/2, 
                                  name => 'Tab', 
                                  pin_number => 8);

# Add an outline around the component that is 10mils 
# thick and offset by 20 mils on each side.

$Pcb -> element_add_outline(xoffset => 20, yoffset =>
20, 
                            thickness => 10);

# Set the component mark to the center of the heatsink

#  tab (0,0)

$Pcb -> element_add_mark(x => 0, y => 0);

# Change the text position for the reference
designator 
# to the upper left corner of the component. The
component 
# extents are saved in x_min and y_min

my ($X1, $Y1) = $Pcb -> element_get('x_min', 'y_min');


$Pcb -> element_set(text_x => $X1 - 20, 
                    text_y => $Y1 - 80);

# Write the element commands to the element file.

$Pcb -> element_output; 





		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail