# pick and place - origin

## A. simplest case: rectangular board, implicit outline, implicit P&P origin

Assume a board of 775*725 mils needs to be created. The P&P fab says coord 0;0 is the lower left corner. The board fab says they need the centerline of tool-path on the outline layer for milling.

By far the simplest way to handle this board is to rely on builtin defaults:

- board size (width and height) specifies the outline of a rectangular board
- if the outline layer exists but is empty, an implicit rectangular outline is drawn, matching board sizes
- implicit P&P origin is the lower left corner

Setting it up:

- 1. start pcb-rnd with no board - this gets the default board template
- 2. change board width & height (gtk: file/preferences/user PoV/sizes)
- 3. do the layout
- 4. when exporting Gerber, enable the 'all layers' option to get the implicit outline layer
- 5. export the xy

Pros | Cons
--- | ---
easy to set up no need to draw the outline | limited drawing area - unsuitable for editing small boards supports rectangular shapes only

## B. rectangular board, explicit outline, explicit P&P origin

Assume another board of 775*725 mils needs to be created. The P&P fab says coord 0;0 is the lower left corner. The board fab says they need the centerline of tool-path on the outline layer for milling.

This time the virtual board (canvas, drawing area) will be larger and the board outline of a 775*725 will be manually drawn. Since pcb-rnd won't make a guess of where the lower-left corner is, an explicit origin mark needs to be added for the pick&place process. Setting it up, assuming the GTK HID:

- 1. start pcb-rnd with no board - this gets the default board template
- 2. draw the 775*725 mils box on the outline layer anywhere in the drawing area
- 3. do the layout within this box
- 4. draw a short line on a random layer - this will be the P&P mark
- 5. drag&drop move the endpoint of the unselected mark line to its other endpoint - this will result in a 0 long line, which looks like a filled circle; with 's' increase the size so that it's easily visible
- 6. select the mark, drag&drop move it to the lower left corner of the outline box
- 7. the mark still selected, press ctrl+e and click on the "add attribute" button in the property editor
- 8. type in "pnp-origin" in the "Attribute key" and "yes" in the "Attribute value" field; click ok and close the property editor
- 9. export the Gerber and xy files

There is a video tutorial available on steps 4..8.

Note 1: the mark is not explicitly visible in the XY file. It is not explicitly passed to the P&P fab. Instead, all subcircuit coordinates are calculated considering the mark's center as 0;0.

Note 2: still, the mark is not hidden or suppressed by pcb-rnd from any of the output. It must be a line, but it can be on any of the layers. Thus the mark potentially would show up on the board. There are multiple options to make the mark disappear:

- make the mark diameter smaller that the router mill bit diameter and place the mark on a copper layer; the board fab will have the copper dot, but it will be milled away.
- same trick should work with silk as well
- or even on the solder mask layer where this object would be a small cutout over void
- make a new (copper) layer, place the mark there and don't send this layer's Gerber export (later on pcb-rnd will support documentation layers which are more dedicated for this sort of use)

Pros | Cons
--- | ---
drawing area (canvas) is bigger than the board: easier to edit can handle slots, cut-outs on the outline layer if the pick and place fab requires a slight offset on the placement, it is easy to move the mark | requires more steps to set up

## C. round board, explicit outline, explicit P&P origin

Assume a third board shaped as a 700 mil diameter circle. The P&P fab says coord 0;0 is the lower left corner of the bounding box of the circle. The board fab says they need the centerline of tool-path on the outline layer for milling.

The process is the same as in example B. The only extra consideration is how to find the coords of the P&P origin mark; for this the P&P fab house needs to be consulted.

There is a video tutorial available on using temporary lines to aid placing the mark for a round lower-left corner.

## D. different P&P origin for different fabs

If the same board is populated by two different fabs who want different origins, as long as they are also using different file formats, it is possible to use two marks. The mechanism for finding the relevant mark is this:

- look for a line that has attribute pnp-origin-FORMAT where FORMAT is the name of the format, e.g. gxyrs or Macrofab
- if that's not found, look for a line that has attribute pnp-origin
- if that's not found, use the bottom-left corner of the drawing area

This means the origin can be a different mark per format and/or a fallback mark can be also added.

## E. mark shapes

In the above examples we used a zero-length line for the mark, which looked like a filled circle. The code will find the first line with the right attribute and use the center point of that line. For a zero-length line the center point is the same as the two endpoints or the center of the filled circle it produces on the screen.

It is possible to use non-zero-length lines for the mark. For example two lines arranged in a + or x shape, either or both lines having the pnp-origin attribute. If the mark is symmetrical, the crossing point happens to be the middle of the line, which is what the code is after.

Of course it's also possible to use a single, non-zer-length line as mark, but then it's harder to see the middle point as an user. It may still work in some simple cases, e.g. a 45 degree short line segment symmetrically placed on the corner of a 90 degree outline corner.