Skip to content

PhotoPlotting

Julie Montoya edited this page Feb 27, 2021 · 11 revisions

Creating Photoplot Files

When the photoplotting program is run, first you will be asked for a design file name. At this prompt you can enter a filename, a star command such as *DRIVE 1 or *CAT, or -- even quicker than typing *. -- just press RETURN to display a disc catalogue. Anything you type that does not begin with a * will be taken as a filename.

If the selected file exists, you will next be prompted for the design description, which will be added as a human-readable comment to each of the plot files.

A menu will be displayed with the standard plotting options:

Standard Plot Menu

These will generate photoplots with the correct combination of features already included to match the description. (The single sided solder mask exposes vias on the underside for soldering, and the single sided silkscreen includes track segments on the topside. This allows wire links to be inserted into the design just by routing tracks on the topside.)

To generate a composite plot, select option 9 from the main photoplotting menu. The screen will change to look like this:

Composite Plot Menu

Enter a number 0-15 to toggle a design layer on or off, a letter A-K to turn a design feature on or off, or a full stop . when all desired options are indicated by a star between the brackets.

Silkscreen and Pads

Silkscreen outlines, bounding boxes and legends are all drawn with the aperture D70. Pads are flashed with their corresponding apertures. We step through each component in turn, seeing which side of the board it is mounted. Each pin has, along with its co-ordinates, a pad shape on the mounted side, a pad shape on the opposite side and a hole size. The hole size is used to determine a pad size to be used on inner layers, from the selection used for vias; if no suitable aperture is found, the pad on the non-mounted side will be used as a last resort.

DO NOT SELECT INNER LAYER PADS -- THIS IS BROKEN! A FUTURE VERSION WILL FIX THIS AND ALSO TREAT THROUGH-HOLE PADS (I.E. WITH HOLES) AND SURFACE-MOUNT PADS (WITHOUT HOLES) SEPARATELY.

Tracks and Vias

Via positions are implicitly embedded in the routed track data, since a waypoint can be either a vertex or a layer/width change, and are obtained by linearly stepping along routes. Vias necessarily appear on all layers, in order to give something for the metal through-hole plating to adhere to. We keep track of the current layer and width (which determines the aperture we will use to draw track segments) and send appropriate instructions to the photoplotter when the track is on a layer we are interested in. Vias, if we are drawing them, are flashed with the appropriate aperture chosen according to the larger of the widths of the tracks on the layers we came from and to.

Generating the Plot File

Once a plot has been selected, you will be asked for an oversize to be added to each aperture. For all except solder mask and solder paste stencils, this should be zero. For solder mask plots, an oversize can be added. This should be in hundredths of a millimetre, so use 50 for a 0.5mm. oversize. A negative oversize will be treated as an _under_size, for creating paste stencil plots.

Lastly you will be asked for an output filename. Again, *COMMANDS can be entered, and pressing RETURN is equivalent to *CAT. (If you type two pairs of speech marks with a space between them " ", nothing will be saved, but you will be able to see the output on screen. You might want to press CTRL+N to turn on paged mode.) The plot file will be displayed on screen as it is being spooled to disc, and afterwards you will be prompted to generate another plot or not.

Drill Files

The photoplotting program can also generate CNC drill files. Select option 10 from the standard menu. A drilling machine is inevitably mechanical in nature, so some care is taken to minimise unnecessary tool changes and head movements: we cannot simply output everything in the order in which it is found. Drilling machines also require logical tool numbers. Holes are sorted first on drill diameter, then the holes of each diameter are sorted in co-ordinate order, from smallest X to largest X and where holes share an X co-ordinate, from smallest Y to largest Y. Via drill sizes are determined by the wider of the connected tracks. The program will display information at each stage of building up the drill information.

Supplementary Information

The photoplot files produced by BCP contain embedded aperture definitions, so there is no need for a separate aperture wheel file. The aperture definitions are repeated in human-readable form, in case you are using a photoplotter that does not support embedded apertures. Human-readable comments will be inserted into the output, which might help if you need to edit the files later.

The drill files produced by BCP contain embedded drill rack information, in both machine and human readable forms, although the sorting of the holes to minimise head movements destroys the association between holes and their parents.

The photoplot and drill files produced by BCP have been tested against the most popular online viewers.

General Principles

Plotoplotting machines, as invented by the Gerber corporation, work by exposing a light-sensitive film to light. The film can be moved, the light can be switched on and off, and a shaped aperture can be selected through which the light is projected onto the film. It is possible to move the film while the light is on, to draw lines; or to "flash" the light briefly on and off again to create an image of the aperture, to produce pads.

The earliest mechanical photoplotters used a wheel with 24 positions for apertures, selected with the codes D10-D29 and D70-D73. Modern machines use a laser and create shapes under software control, but they use (an extended version of) the same command language to control them, in particular supporting the complete range of apertures D10-D99.

BCP uses D10-D19 for component pads, D20-D29 for rotated versions of the same shape pads, D70 for silkscreen outlines and track width 1 and D71-73 for track widths 2-4. It ideally would require also at least D80-D83 from the extended set, for vias corresponding to the relevant track widths, D30-D39 to support extra pad shapes and D74-D79 and D84-D99 to support extra track widths; but an aperture substitution mechanism exists to allow just the basic 24 apertures to be used. (I am not certain whether anybody is still using an ancient mechanical photoplotter, but I know for sure that people are still using BBC Micros ;) so I guess anything is possible.)

Aperture Mode Used For
D10-D19 Flash Pad shapes 1-10, 0° and 180°
D20-D29 Flash Pad shapes 1-10, 90° and 270°
D30-D34* Flash Pad shapes 11-15, 0° and 180°
D35-D39* Flash Pad shapes 11-15, 90° and 270°
D70 Draw Silkscreen outlines
D70-D73 Draw Track widths 1-4
D74-D79* Draw Track widths 5-10
D80-D89* Flash Vias on tracks of widths 1-4
D90-D94* Draw Track widths 11-15
D95-D99* Flash Vias on tracks of widths 11-15

Aperture Substitution -- NOT PRESENT IN THIS VERSION

This will be incorporated into a future version. To allow for the fact that some pads are circular or square and thus do not need two copies, it is possible to use positions in the range D20-D29 to substitute for other codes. For instance, if D10 is an oblong pad shape, D20 will need to be its rotated form; but if D11 is round, D21 becomes redundant and can be used as a substitute for D81, which would normally be used for the via associated with a track of width 2.

Plotting Options

The following plotting options are available:

  1. Underside Copper => pads on underside, tracks on layer 2, vias
  2. Topside Copper => pads on topside, tracks on layer 3, vias
  3. Underside Solder Mask for Single Sided Board => pads on underside, vias
  4. Underside Solder Mask for Double Sided Board => pads on underside
  5. Topside Solder Mask => pads on topside
  6. Topside Silkscreen for Single Sided Board => topside silkscreen, topside legends, tracks on layer 3
  7. Topside Silkscreen for Double Sided Board => topside silkscreen, topside legends
  8. Underside Silkscreen => underside silkscreen, underside legends
  9. Composite Plot (User Defined)

In the case of single-sided boards, vias will be included in the solder mask plot and copper tracks on the topside will be included in the silkscreen plot: this allows wire links to be routed directly as tracks on the topside, the pads used for them exposed for soldering (normally, vias would be left covered by solder resist) and their positions to be marked on the silkscreen (normally, they would just be copper tracks).

Composite Plots

If it is desired to create a composite plot with a non-standard combination of items, select option 9 from the menu to select any combination of component features, track routing layers and vias (which effectively exist on all layers, in order to give the through-hole plating something to adhere to).

  • Silkscreen outlines on the underside
  • Component legends on the underside
  • Component boundary boxes on the underside
  • Silkscreen outlines on the topside
  • Component legends on the topside
  • Component boundary boxes on the topside
  • Component pads on the underside
  • Component pads on the topside
  • Component pads on inner layers
  • Tracks on any layer or combination of layers
  • Vias

This would allow e.g. an assembly drawing to be produced showing the component outline overlaid on the track pattern.

Generating Triangles on the Photoplotter

The BBC Micro provides an instruction to draw a triangle just by specifying its vertices. A standard photoplotter does not support anything like this, so BCP's report generation program will have to do this itself.

Consider a triangle ABC where A and C are the horizontal extremes, and B is positioned somewhere between them horizontally. Now for any horizontal position between A and C, we can draw a vertical line from a point on AC to a point on either AB or BC. We can draw a series of such parallel lines, slightly less than a pen stroke's width apart so they overlap slightly, to shade in the complete interior of the triangle; and any roughness at the edges will be concealed by the outline, which we can draw first or last.

Obviously this means we are going to have to consider the equations of the lines AC, AB and BC somehow. The obvious straight-line equation

Y = M * X + C         (i)

is a problem if we have only integer mathematics available, but we can instead use a modified equation

M * X + N * Y = P     (ii)    
Y = (P - M * X) / N   (iia)
X = (P - N * Y) / M   (iib)

which moves the division step to the last minute, and so does not require us to store any fractions; it does require us to be able to handle 32-bit quantities, but this is not a problem as our multiply and divide routines already do this (it's pretty central to every scaling operation). Given two points (X1, Y1) and (X2, Y2) on a line, we can calculate its M, N and P values as follows:

M = Y2 - Y1           (iii)
N = X2 - X1           (iv)
P = M * X1 + N * Y1   (v)

During development, test that P also = M * X2 + N * Y2; if this is not the case, then we must have gone wrong in our maths. Use an acute-angled triangle so as to ensure we have both positive and negative slopes. This will give a quick litmus test that we are handling signed quantities correctly.

And then, given one co-ordinate (X or Y) of any point on the line, we can calculate the other co-ordinate. So all we need do is something like the following pseudocode:

X = Xa + Xs
.loop
    calculate Y1 on AC
    if X < Xb
        calculate Y2 on AB
    else
        calculate Y2 on BC
    tell photoplotter move X, Y1
    tell photoplotter draw X, Y2, D70
    X = X + Xs
if X < Xc, back to loop

There is a possible complication if AB or BC is vertical. In this case, the line equation will be of the form Y = (P - M * X) / 0. However, we need never actually attempt to evaluate this. We only need to find a Y co-ordinate to AB when X < Xb. If AB is vertical, the first value of X (= Xa + Xs) will already be greater than Xb; and obviously BC cannot also be vertical. On the other hand if BC is vertical then at the end of the loop, when we increase the X co-ordinate, we will have X greater than or equal to Xc and thus exited from the loop. So we will never have to worry about division by zero!

This works well if the triangle is taller than it is broad; the lines that fill its interior will be long and few in number. If the triangle's proportions are the other way, then we can do something similar with A, B and C ordered vertically and drawing horizontal lines to form the shading.

Since we have to perform comparisons on both the X and Y co-ordinates to get the extreme points and therefore the height and width, we might as well proceed according to the following pseudocode:

copy A, B and C to workspace
copy A, B, C again as D, E, F
sort A, B, C into order on X co-ordinates
sort D, E, F into order on Y co-ordinates
calculate height = Yf - Yd
calculate width = Xc - Xa
if width < height
    evaluate cross-sums and differences
    X = Xa + Xs
    .xloop
        calculate Y1 on AC
        if X < Xb
            calculate Y2 on AB
        else
            calculate Y2 on BC
        tell photoplotter move X, Y1
        tell photoplotter draw X, Y2, D70
        X = X + Xs
    back to xloop if X < Xc
else
    overwrite A,B,C with D,E,F
    evaluate cross-sums and differences
    Y = Ya + Ys
    .yloop
        calculate X1 on AC
        if Y < Yb
            calculate X2 on AB
        else
            calculate X2 on BC
        tell photoplotter move X1, Y
        tell photoplotter draw X2, Y, D70
        Y = Y + Ys
    back to yloop if Y < Yf
done

The reason for this is, we need to find the greatest Y difference and the greatest X difference in order to work out whether we are dealing with a "tall" triangle or a "wide" one; so we might as well make two copies of the points, sort one copy according to X, sort the other copy according to Y, and then we know where in workspace the smallest and largest X co-ordinates are and where the smallest and largest Y co-ordinates are. If we find the height greater than the width, we just use the points sorted by X as our working copies. If we find the width greater than the height, we overwrite the working copies of the points with the co-ordinates sorted on Y.

The calculation routines can have the addresses of the cross-sums, differences and (when evaluating the cross-sums) a point on the line passed in registers. (The known co-ordinate can be loaded into the multiplier before calling the subroutine to find the other co-ordinate, which will remain in the quotient.)

Generating Text on the Photoplotter

Text is rendered on the photoplotter as simple lines, using a vector font integral to BCP.

Some liberties have been taken with the character set as follows:

  • EOR SIGN ^ The exclusive-or / power sign ^ renders as a non-spacing overbar the width of a standard upper-case character, over the following character. For example ^K would render as K-bar; "not ready" might be represented ^R^D^Y.
  • OPEN POSH BRACKET { An opening "posh" bracket renders as a micro sign µ (Greek lower case mu).
  • VERTICAL BAR | A vertical bar renders as an earth sign ⏚.
  • CLOSE POSH BRACKET } A closing "posh" bracket renders as an ohms sign Ω (Greek upper case Omega).

Text is drawn using aperture D70, as used for the silkscreen and track width "1".

The Font Format

Each character 32-127 has a variable-length record and a 2-byte fixed-length record giving the address in memory and length of the variable portion, bit-packed so as to allow a 5-bit length and an 11-bit offset from the base address.

BYTE BITS MEANING
0 0-7 offset bits 0-7
1 0-2 offset bits 8-10
1 3-7 length

The variable-length portion is a series of bytes, each containing an X co-ordinate in the range 0 .. 7 and a Y co-ordinate in the range -12 .. +3. These co-ordinates are measured relative to the top left-hand corner of the character's bounding rectangle (chosen to be as on screen on the BBC Micro) and finishing at the intended top left-hand corner of the following character. Bit 7 is 1 for move, 0 for draw; bits 6-4 are the X co-ordinate, and bits 3-0 are the Y co-ordinate.

BITS MEANING
7 1 = move, 0 = draw
4-6 X
0-3 Y

The X and Y values are multiplied by the font size, and flipped and rotated as required to get the co-ordinates of each point in the character. The last co-ordinate pair, which indicates the starting point for the next character, is copied over the starting point ready for the next character to begin there.

Characters are based on lines constructed between a grid of 5 points across by 7 points high for a standard character; though not every character fills this width, and it is possible for, e.g., the "overbar" character and the tails of lower-case letters, to extend outside this range (X can be anything from 0 .. 7, Y can be anything from -12 .. 3). The font size thus represents one quarter of the height of a standard lower-case character.

Plotting Points

The workspace variable plotmode is used in the photoplotting subroutines to select a plotting mode as follows:

Value Meaning
4 Move to given co-ordinates (D02)
5 Draw to given co-ordinates using current aperture (D01)
69 Move to given co-ordinates and flash current aperture (D03)
85 Draw triangle based on given point and last 2 points visited (lots of D02 and D03 .....)