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)

     
li:pcb-rnd-subcircuit-v6 {
 ha:subc.2{
  ha:attributes {
   footprint = {screw:3.2mm,6mm,circle:hex}
   refdes = S1
  }
#dimension -118.11 0 118.11 0 165.354 head 
#dimension -62.9922 0 62.9922 0 141.732 hole 
  ha:data {
   li:padstack_prototypes {
# Round plated through hole 188.976mil/125.984mil
    ha:ps_proto_v6.0 {
     hdia = 125.984mil
     hplated = 1
     htop = 0
     hbottom = 0
     li:shape {
      ha:ps_shape_v4 {
       clearance = 0
       ha:ps_circ {
        x = 0mil
        y = 0mil
        dia = 188.976mil
       }
       ha:layer_mask {
        top = 1
        copper = 1
       }
       ha:combining {
       }
      }
      ha:ps_shape_v4 {
       clearance = 0
       ha:ps_circ {
        x = 0mil
        y = 0mil
        dia = 188.976mil
       }
       ha:layer_mask {
        intern = 1
        copper = 1
       }
       ha:combining {
       }
      }
      ha:ps_shape_v4 {
       clearance = 0
       ha:ps_circ {
        x = 0mil
        y = 0mil
        dia = 188.976mil
       }
       ha:layer_mask {
        bottom = 1
        copper = 1
       }
       ha:combining {
       }
      }
      ha:ps_shape_v4 {
       clearance = 0
       ha:ps_circ {
        x = 0mil
        y = 0mil
        dia = 86mil
       }
       ha:layer_mask {
        top = 1
        mask = 1
       }
       ha:combining {
        sub = 1
        auto = 1
       }
      }
      ha:ps_shape_v4 {
       clearance = 0
       ha:ps_circ {
        x = 0mil
        y = 0mil
        dia = 86mil
       }
       ha:layer_mask {
        bottom = 1
        mask = 1
       }
       ha:combining {
        sub = 1
        auto = 1
       }
      }
     }

    }
   }
   li:objects {

    ha:padstack_ref.7 {
     proto = 0
     x = 0mil
     y = 0mil
     rot = 0
     smirror = 0; xmirror = 0
     clearance = 25mil
     ha:attributes {
      term = 1
     }
     li:thermal { }
     ha:flags { clearline = 1; }
    }

   }
   li:layers {
    ha:subc-aux {
     lid = 0
     ha:type {
      top = 1
      misc = 1
      virtual = 1
     }
     li:objects {

      ha:line.4 {
       x1 = 0mil
       y1 = 0mil
       x2 = 39.3701mil
       y2 = 0mil
       thickness = 3.93701mil
       clearance = 0mil
       ha:attributes {subc-role = x}
       ha:flags {}
      }

      ha:line.5 {
       x1 = 0mil
       y1 = 0mil
       x2 = 0mil
       y2 = 39.3701mil
       thickness = 3.93701mil
       clearance = 0mil
       ha:attributes {subc-role = y}
       ha:flags {}
      }

      ha:line.6 {
       x1 = 0mil
       y1 = 0mil
       x2 = 0mil
       y2 = 0mil
       thickness = 3.93701mil
       clearance = 0mil
       ha:attributes {subc-role = origin}
       ha:flags {}
      }

     }
     ha:combining {
     }
    }
    ha:top-silk {
     lid = 0
     ha:type {
      top = 1
      silk = 1
     }
     li:objects {

      ha:text.3{
       scale = 100
       x = 0mil
       y = -100mil
       rot = 0
       string = %a.parent.refdes%
       fid = 0
       ha:flags {dyntext = 1;floater=1;}
      }

      ha:arc.8 {
       x = 0mil
       y = 0mil
       astart = 0
       adelta = 360
       thickness = 10mil
       clearance = 0mil
       width = 118.11mil
       height = 118.11mil
       ha:flags {}
      }

      ha:line.9 {
       x1 = 59.0551mil
       y1 = 102.287mil
       x2 = -59.0552mil
       y2 = 102.287mil
       thickness = 10mil
       clearance = 0mil
       ha:flags {}
      }

      ha:line.10 {
       x1 = -59.0552mil
       y1 = 102.287mil
       x2 = -118.11mil
       y2 = -4.84497e-08mil
       thickness = 10mil
       clearance = 0mil
       ha:flags {}
      }

      ha:line.11 {
       x1 = -118.11mil
       y1 = -4.84497e-08mil
       x2 = -59.0551mil
       y2 = -102.287mil
       thickness = 10mil
       clearance = 0mil
       ha:flags {}
      }

      ha:line.12 {
       x1 = -59.0551mil
       y1 = -102.287mil
       x2 = 59.0552mil
       y2 = -102.287mil
       thickness = 10mil
       clearance = 0mil
       ha:flags {}
      }

      ha:line.13 {
       x1 = 59.0552mil
       y1 = -102.287mil
       x2 = 118.11mil
       y2 = 9.68993e-08mil
       thickness = 10mil
       clearance = 0mil
       ha:flags {}
      }

      ha:line.14 {
       x1 = 118.11mil
       y1 = 9.68993e-08mil
       x2 = 59.0551mil
       y2 = 102.287mil
       thickness = 10mil
       clearance = 0mil
       ha:flags {}
      }

     }
     ha:combining {
     }
    }
   }
  }
  uid = Prm/rD8+hF74chASUYZEaHEY
 }
}

Downloads:
footprint file