The scripts pcb-matrix and sch-matrix replicate PCB and schematic
structures by copying an input file to an output file multiple times
incrementing the (x,y)
position of each copy. The copied
structures are arranged in a matrix as specified in a configuration
file.
N.B. These scripts may not work for all layouts. I wrote
sufficient code to copy the schematic and PCB elements for one of my
designs not for all possible designs. I am almost certain that
sch-matrix
will break for schematics with embedded
symbols.
parameter | Replace with the value of parameter |
verbatim text | Verbatim text when associated with a command or contents of a file. |
sch-matrix | The current version of the schematic matrix program. |
pcb-matrix | The current version of the PCB matrix program. |
sch-matrix_ version | Version version of the schematic matrix program. |
pcb-matrix_ version | Version version of the PCB matrix program. |
gschpcb
on the input schematic and create a PCB
layout (which will be the input PCB layout).
sch-matrix
and pcb-matrix
.
sch-matrix
pcb-matrix
sch-matrix
and
pcb-matrix
use the same algorithm to update reference
designators.
sch-matrix_0
<configuration filename>
sch-matrix
script creates a new layout by coping each
component
, text
value, net
,
line
and circle
to an output file multiple
times. Each structure is positioned as defined by the parameters in
the configuration file. For each component
the reference
designator is updated to maintain unique reference designators in the
output file.
gschem
. Prior to running sch-matrix
all of
the reference designators (refdes's) must be
assigned. sch-matrix
dies if the refdes does not match an
alphabetic string followed by integer (which is the regular
expression [A-Za-z]+\d+
).
xoffset
and
yoffset
a single continous net will be created in the
output file. For a matrix a combination of net names and continuous
nets may be best.
sch-matrix
is run the output schematic is overwritten. If
you embed the output schematic in your design using a heirachical
block then this problem is eliminated. Since connections to the block
are by net names no changes are required when sch-matrix
is re-run.
pcb-matrix_0
<configuration filename>
pcb-matrix
script creates a new layout by coping each
Element
, Polygon
, Via
and
Line
from an input file to an output file multiple
times. Each layout, from the input file, is positioned as defined by
the parameters in the configuration file. For each
Element
the reference designator is updated to maintain
unique reference designators in the output file.
In a PCB file there is a variety of data prior to the start of the
layout ({\em e.g.} user interface settings, character symbols) . It
does not seem desirable to replicate all of that data. Rather than try
to guess where the layout starts the pcb-matrix
program requires a
marker line in the input file to indicate the start of the layout.
The marker line is a line containing only the string
#####__PCB__#####
which is a legal PCB comment line. This marker
line has to be reinserted each time you save the PCB layout.
The start of the layout seems to reside after all of the symbol
declarations and before the vias. pcb-matrix
will copy
all of the lines prior to the marker to the output file
verbatim. After the marker line is read the remaining lines will be
output r
x c
times in a matrix (where
r
is the number of rows and c
is the number
of columns specified in the configuration file).
pcb-matrix
is run
the output layout is overwritten.
If you embed the output layout in your design using the
load layout data to paste-buffer
command then you can reload it if changes need to be made. Since the
output layout is self-contained only the peripheral connections will
need to updated. To reload an output layout into your design:
load layout data to paste-buffer
to add the output layout
sch-matrix
and pcb-matrix
. Each file can contain comments, empty
lines and lines that set parameters. Comments start with a
#
and proceed to the end of the current line. Comments
and empty lines are ignored by the parser. The lines that set
parameters are in the format:
name | parameter value where parameter name is one of the names listed in parameter table.
Name | Type | Description |
x0 | Integer | the x coordinate (in mils) of the starting position in the output file |
y0 | Integer | the y coordinate (in mils) of the starting position in the output file |
xoffset | Integer | the center-to-center column spacing (in mils) |
yoffset | Integer | the center-to-center row spacing (in mils) |
last_col | Ordinal | the ordinal of the last column (column ordinals start at 0) |
last_row | Ordinal | the ordinal of the last row (row ordinals start at 0) |
input_filename | String | the name of the file containing the structure that will be replicated |
output_filename | String | the name of the file that contains the replicated stuctures |
xoffset
value of 3200 in
the configuration will overlap the nets in the output file.
Prior to running sch-matrix
all of the reference
designators need to be assigned. sch-matrix
will uniquely
number all of the components in the output file based upon the
assigned values in the input file.
The configuration file for sch-matrix
is shown
here. xoffset
defines the cell
spacing for columns and yoffset
defines the cell spacing
for rows. The lastcol
and lastrow
values
define a 1x4 matrix.
The output schematic shown in Figure 2 is the result of running
sch-matrix
using the schematic
configuration file. Notice that the horizontal nets have been
connected and the reference designators of the copied cells have been
uniquely assigned.
gsch2pcb
and
create a layout for a single load-cell. An example load-cell layout is
shown in Figure 3.
In the load-cell layout the two high current traces are running
parallel on the component side of the board along the top of the cell.
The op-amp power and positive-input traces are running parallel on the
solder side of the board at the bottom of the cell. All of the
parallel traces are ≈950 mils long. Setting an
xoffset
of 900mils will create an overlap between the
cells in the output file.
Running pcb-matrix
with the PCB configuration file produces the layout in
Figure 4.
# x0 the x coordinate of the starting position in the output file # y0 the y coordinate of the starting position in the output file # xoffset the column spacing # yoffset the row spacing # last_col the ordinal of the last column (column ordinals start at 0) # last_row the ordinal of the last row (row ordinals start at 0) # input_filename the name of the file containing the schematic # that will be replicated # output_filename the name of the file that contains the schematic matrix x0 | 500 #%\label{lst:cfg-sch x0}% y0 | 100 #%\label{lst:cfg-sch y0}% xoffset | 3200 #%\label{lst:cfg-sch xoffset}% yoffset | 0 #%\label{lst:cfg-sch yoffset}% last_col | 3 #%\label{lst:cfg-sch lastcol}% last_row | 0 #%\label{lst:cfg-sch lastrow}% input_filename | load-cell.sch #%\label{lst:cfg-sch infile}% output_filename | load.sch #%\label{lst:cfg-sch outfile}%
# x0 the x coordinate of the starting position in the output file # y0 the y coordinate of the starting position in the output file # xoffset the column spacing # yoffset the row spacing # last_col the ordinal of the last column (column ordinals start at 0) # last_row the ordinal of the last row (row ordinals start at 0) # input_filename the name of the file containing the PCB layout # that will be replicated # output_filename the name of the file that contains the PCB matrix x0 | 500 y0 | 100 xoffset | 900 yoffset | 0 last_col | 3 last_row | 0 input_filename | load-cell.pcb output_filename | load.pcb