aktos-io / aecad

Open Source Circuit Board Design Software that runs on the browser and desktop
https://aktos.io/aecad
54 stars 10 forks source link

Provide `.interconnected-pins` property for components #80

Closed ceremcem closed 2 years ago

ceremcem commented 2 years ago

Some components (like MCU) have duplicate labeled pins (like gnd) but that doesn't actually mean those pins are internally connected because these kind of devices are designed to be supplied by multiple pins. It's not sufficient to connect one of those pins to its relevant network, all pins have to be connected.

Some other components, on the other hand, have duplicate labeled pins (like pcb type power terminals or zero-ohm resistors) but those pins are actually internally connected and it's sufficient to connect any of those pins to their corresponding network.

There are 2 kinds of situations that have same visual but needs different action. What should schema think when it sees a duplicate label?

We need a property, like .interconnected-pins: Array. All pins have to be connected by default and the array is interpreted as "connecting one of those pins are sufficient for this label".

data = 
  ...
  interconnected-pins: <[ gnd vdd ]> 

Original credit: @mesutevin

ceremcem commented 2 years ago

Partially interconnected pins for dynamic components

Sometimes pointing the interconnected pins by labels are not sufficient because those labels can be assigned within the targeting circuit, the inner array of the footprint might be calculated dynamically and only some pins might be physically interconnected. Here is an example component: DG142V-5.08-XXP

image

Size of this component is determined within the targeting circuit, say 6 terminals. Now this component has 12 pins (2 for each cable input). User might perfectly give all pins the same gnd label. If this component would simply declare the distinct labels as "interconnected" (interconnected-pins: "gnd"), result would be wrong because this would define all of the 12 pins as "interconnected". However only 1 and 2, 3 and 4, ...and so on are connected as pairs.

Solution

interconnected-pins must also support pin numbers. With this approach, we could declare array of array of the pins that are interconnected. In our scenario, value would be:

interconnected-pins: 
  <[ 1 2 ]> 
  <[ 3 4 ]> 
  <[ 5 6 ]> 
  <[ 7 8 ]> 
  <[ 9 10 ]> 
  <[ 11 12 ]> 

If value of text2arr interconnected-pins is:

ceremcem commented 2 years ago

Example working footprint: DG142V_5_08_XXP

provides class DG142V_5_08_XXP extends Footprint
    @rev_Conn = 1
    (data, overrides) ->
        value-regex = /^([0-9]+)\s[tT]erminal(s)?/

        columns = if data.value.match value-regex
            that.1
        else if data.pin-count
            that
        else
            10

        labels = {}
        interconnected-pins = []
        for i in [0 to columns]
            label = data.labels?[i+1] or i+1
            pinA = 2*i + 1
            pinB = 2*i + 2
            labels[pinA] = label
            labels[pinB] = label

            interconnected-pins.push [pinA, pinB]

        super data, overrides `based-on` {
            +allow-duplicate-labels
            interconnected-pins
            labels
            columns
        }

    create: (data) ->
        x = new PinArray do
            parent: this
            pad:
                drill: 1.3mm
                dia: 1.3mm * 2
            cols:
                count: 2
                interval: 7.62mm
            rows:
                count: data.columns
                interval: 5.08mm
            dir: 'x'
            labels: data.labels
            allow-duplicate-labels: data.allow-duplicate-labels

        @iface = x.iface

Note that the interconnected-pins must be calculated inside the constructor because the .create() method will not be called after the first creation time (thus will not be processed).

Result

image