pcblib-param test page

"Do you remember the good old days? When I was
young, I said footprint=CONNECTOR 2 13
in gschem and got a 2*13 pin connector in PCB."

 
 

Syntax

In pcb-rnd, automatic footprint generation on the fly is called "parametric footprints". It is a smaller and more generic infrastructure compared to the m4 footprints in pcb. The goal was to fix three problems.

  • 1. Languages: m4 should not be mandatory for footprint generators - the user should be free to choose any language
  • 2. Simplicity: references to m4 should not be hardwired in pcb, gsch2pcb and gsch2pcb.scm, but footprint generation should be generic, transparent and external
  • 3. Unambiguity: gsch2pcb should not be guessing whether to use file elements or call a generator. Instead of complex heuristics, there should be a simple, distinct syntax for parametric footprints.

The new syntax is that if a footprint attribute contains parenthesis, it is a parametric footprint, else it is a file footprint. Parametric footprints are sort of a function call. The actual syntax is similar to the one in openscad : parameters are separated by commas, and they are either positional (value) or named (name=value).

For example a simple pin-grid connector has the "prototype" of connector(nx, ny, spacing), where nx and ny are the number of pins needed in X and Y directions, spacing is the distance between pin centers, with a default of 100 mil. The following calls will output the same 2*3 pin, 100 mil footprint:

  • connector(2, 3)
  • connector(2, 3, 100)
  • connector(nx=2, ny=3, spacing=100)
  • connector(spacing=100, nx=2, ny=3)
  • connector(ny=3, spacing=100, nx=2)
   

Generators available

Try it online

source:

Result

screw(3.2mm, 6mm, circle:hex)

     
Element["" "screw(3.2mm, 6mm, circle:hex)" "S1" "screw:3.2mm,6mm,circle:hex" 0 0 0 -10000 0 100 ""]
(
	Pin[0 0 18897 5000 8600 12598 "" "1" ""]
	ElementArc[0 0 11811 11811 0 360 1000]
	ElementLine[5905 10228 -5905 10228 1000]
	ElementLine[-5905 10228 -11811 0 1000]
	ElementLine[-11811 0 -5905 -10228 1000]
	ElementLine[-5905 -10228 5905 -10228 1000]
	ElementLine[5905 -10228 11811 0 1000]
	ElementLine[11811 0 5905 10228 1000]
#dimension -11811 0 11811 0 16535.4 head 
#dimension -6299 0 6299 0 14173.2 hole 
)

Downloads:
footprint file