Page tree
Skip to end of metadata
Go to start of metadata

Named connectors provide an alternative to direct wiring and can provide an advantage when wiring elements in a dense schematic. When wiring elements in a schematic one concern is adding a wire segment which overlaps the node of another element. If the wire segment crosses over a node on another element it will be connected, possibly creating an unintentional connection. For example consider the following program which adds four elements and attempts to connect them in pairs.

 ' Code Module
Sub Main
        Dim schem As Schematic
        Dim ele1 As Element, ele2 As Element, ele3 As Element, ele4 As Element


        Set schem = Project.Schematics("Schematic 1")
        Set ele1 = schem.Elements.Add("MLIN", 0, 1000, -90)
        Set ele2 = schem.Elements.Add("MLIN", 0, 0, 90)

        Set ele3 = schem.Elements.Add("MLIN", -1000, 0, 180)
        Set ele4 = schem.Elements.Add("MLIN", 1000, 0, 0)

        schem.Wires.Add(ele1.Nodes(1).x, ele1.Nodes(1).y, ele2.Nodes(1).x, ele2.Nodes(1).y)
        schem.Wires.Add(ele3.Nodes(1).x, ele3.Nodes(1).y, ele4.Nodes(1).x, ele4.Nodes(1).y)
End Sub


The result of running this program looks like Figure 1. Note that because a wire segment overlapped a node on element MLIN.TL2 the wire connected to that element and instead of being connected in pairs all four of the elements are connected together.

Figure 1 Elements mis-connected because wire segment overlapped element node

To avoid this we can use connection by name to reduce the number of wires required to connect the elements. A named connector is an element that provides connectivity by name, so any two or more named connectors in a schematic with the same name will form a connection. For example:

 ' Code Module
Sub Main
        Dim schem As Schematic
        Dim ele1 As Element, ele2 As Element, ele3 As Element, ele4 As Element
        Dim nconn1 As Element, nconn2 As Element

        Set schem = Project.Schematics("Schematic 2")

        ' Add four elements
        Set ele1 = schem.Elements.Add("MLIN", 0, 1000, -90)
        Set ele2 = schem.Elements.Add("MLIN", 0, 0, 90)

        Set ele3 = schem.Elements.Add("MLIN", -1000, 0, 180)
        Set ele4 = schem.Elements.Add("MLIN", 1000, 0, 0)

        ' Add wire connecting the first two elements.
        schem.Wires.Add(ele1.Nodes(1).x, ele1.Nodes(1).y, ele2.Nodes(1).x, ele2.Nodes(1).y)

        ' Add named connectors to connect the second two elements.
        Set nconn1 = schem.Elements.Add("NCONN", ele3.Nodes(1).x, ele3.Nodes(1).y)
        Set nconn2 = schem.Elements.Add("NCONN", ele4.Nodes(1).x, ele4.Nodes(1).y)

        ' Set the connector name property to match so they connect.
        nconn1.Parameters("Name").ValueAsString = "ele3_ele4"
        nconn2.Parameters("Name").ValueAsString = "ele3_ele4"

End Sub


In this example we initially do the same operations adding elements to the schematic:

      Set schem = Project.Schematics("Schematic 2")

        ' Add four elements
        Set ele1 = schem.Elements.Add("MLIN", 0, 1000, -90)
        Set ele2 = schem.Elements.Add("MLIN", 0, 0, 90)

        Set ele3 = schem.Elements.Add("MLIN", -1000, 0, 180)
        Set ele4 = schem.Elements.Add("MLIN", 1000, 0, 0)


Followed by adding a wire to connect the first two elements.

 ' Add wire connecting the first two elements.
        schem.Wires.Add(ele1.Nodes(1).x, ele1.Nodes(1).y, ele2.Nodes(1).x, ele2.Nodes(1).y)


Then instead of adding another wire which might connect with the existing elements we add two named connectors to the nodes of the elements we want to connect.

' Add named connectors to connect the second two elements.Set nconn1 = schem.Elements.Add("NCONN", ele3.Nodes(1).x, ele3.Nodes(1).y)Set nconn2 = schem.Elements.Add("NCONN", ele4.Nodes(1).x, ele4.Nodes(1).y)


Then to ensure correct connection we give the named connectors a name which is unique in the schematic but matches between the two so they will be connected together by having the same name.

      ' Set the connector name property to match so they connect.
        nconn1.Parameters("Name").ValueAsString = "ele3_ele4"
        nconn2.Parameters("Name").ValueAsString = "ele3_ele4"

 

The results of running this program looks like Figure 2

Figure 2 Elements connected together with named connectors. Here the name value is "ele3_ele4"

Named connectors allow element nodes to be connected directly together with a unique name. As shown this can be useful when connecting elements in dense schematics but it can also be useful when you need to make a large number of connections at different locations within a schematic to a single pin or port such as with a power or clock signal line.