Skip to content
LIBRARY
Analog.Basic.Tests.VCC.md

Analog.Basic.Tests.VCC

Test circuit for VCC (voltage-controlled current source).

A sine voltage source (amplitude=1 V, frequency=1 Hz) drives the VCC input port (port 1). A 10 Ω resistor loads the output port (port 2). VCC transConductance = 0.5 S.

Expected (algebraic, holds for all t):

  • v1 = sin(2π·t)

  • i1 = 0 (infinite input impedance)

  • i2 = transConductance·v1 = 0.5·sin(2π·t)

  • v2 = −R_load·i2 = −5·sin(2π·t)

Usage

ElectricalComponents.Analog.Basic.Tests.VCC()

Behavior

[connect(sine+y,vs+V)connect(vs+p,vcc+p1)connect(vs+n,gnd1+g)connect(vs+n,vcc+n1)connect(vcc+p2,rload+p)connect(rload+n,vcc+n2)connect(vcc+n2,gnd2+g)sine.y(t)=sine.offset+sine.amplitudeifelse(tsine.starttime,sin(sine.phase+6.283185307179586sine.frequency(sine.starttime+t)),sin(sine.phase))vs.v(t)=vs.n.v(t)+vs.p.v(t)vs.i(t)=vs.p.i(t)vs.n.i(t)+vs.p.i(t)=0vs.v(t)=vs.uVvs.V(t)vcc.v1(t)=vcc.p1.v(t)vcc.n1.v(t)vcc.v2(t)=vcc.p2.v(t)vcc.n2.v(t)vcc.i1(t)=vcc.p1.i(t)vcc.i2(t)=vcc.p2.i(t)0=vcc.p1.i(t)+vcc.n1.i(t)0=vcc.n2.i(t)+vcc.p2.i(t)vcc.i2(t)=vcc.transConductancevcc.v1(t)vcc.i1(t)=0rload.v(t)=rload.n.v(t)+rload.p.v(t)rload.i(t)=rload.p.i(t)rload.n.i(t)+rload.p.i(t)=0rload.v(t)=rload.Rrload.i(t)gnd1.g.v(t)=0gnd2.g.v(t)=0]

Source

dyad
"""
Test circuit for VCC (voltage-controlled current source).

A sine voltage source (amplitude=1 V, frequency=1 Hz) drives the VCC input
port (port 1). A 10 Ω resistor loads the output port (port 2).
VCC transConductance = 0.5 S.

Expected (algebraic, holds for all t):
- v1 = sin(2π·t)
- i1 = 0  (infinite input impedance)
- i2 = transConductance·v1 = 0.5·sin(2π·t)
- v2 = −R_load·i2 = −5·sin(2π·t)
"""
test component VCC
  "Sine signal: amplitude=1, frequency=1 Hz"
  sine = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 0, "y1": 310, "x2": 100, "y2": 410, "rot": 0}
      },
      "tags": []
    }
  }
  "Input voltage source"
  vs = ElectricalComponents.Analog.Sources.VoltageSource() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 410, "x2": 260, "y2": 310, "rot": 90}
      },
      "tags": []
    }
  }
  "VCC with transConductance=0.5 S"
  vcc = ElectricalComponents.Analog.Basic.VCC(transConductance = 0.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 320, "x2": 550, "y2": 420, "rot": 0}
      },
      "tags": []
    }
  }
  "Output load resistor"
  r_load = ElectricalComponents.Analog.Basic.Resistor(R = 10) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 730, "y1": 410, "x2": 830, "y2": 310, "rot": 90}
      },
      "tags": []
    }
  }
  "Input-side ground"
  gnd1 = ElectricalComponents.Analog.Basic.Ground() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 580, "x2": 260, "y2": 680, "rot": 0}
      },
      "tags": []
    }
  }
  "Output-side ground"
  gnd2 = ElectricalComponents.Analog.Basic.Ground() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 520, "y1": 570, "x2": 620, "y2": 670, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(sine.y, vs.V) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(vs.p, vcc.p1) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 210, "y": 250}, {"x": 391, "y": 250}, {"x": 391, "y": 321}],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(vs.n, gnd1.g) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(vs.n, vcc.n1) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [
            {"x": 210, "y": 470},
            {"x": 390, "y": 470},
            {"x": 390, "y": 420},
            {"x": 451, "y": 420}
          ],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(vcc.p2, r_load.p) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [
            {"x": 551, "y": 320},
            {"x": 620, "y": 320},
            {"x": 620, "y": 250},
            {"x": 780, "y": 250}
          ],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(r_load.n, vcc.n2) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 780, "y": 470}, {"x": 571, "y": 470}, {"x": 571, "y": 420}],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(vcc.n2, gnd2.g) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 570, "y": 420}], "E": 2}]
    }
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://ElectricalComponents/Example.svg"},
    "tests": {
      "case1": {"stop": 1, "expect": {"signals": ["vcc.v1", "vcc.i1", "vcc.i2", "vcc.v2"]}}
    }
  }
}
end
Flattened Source
dyad
"""
Test circuit for VCC (voltage-controlled current source).

A sine voltage source (amplitude=1 V, frequency=1 Hz) drives the VCC input
port (port 1). A 10 Ω resistor loads the output port (port 2).
VCC transConductance = 0.5 S.

Expected (algebraic, holds for all t):
- v1 = sin(2π·t)
- i1 = 0  (infinite input impedance)
- i2 = transConductance·v1 = 0.5·sin(2π·t)
- v2 = −R_load·i2 = −5·sin(2π·t)
"""
test component VCC
  "Sine signal: amplitude=1, frequency=1 Hz"
  sine = BlockComponents.Sources.Sine(amplitude = 1, frequency = 1) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 0, "y1": 310, "x2": 100, "y2": 410, "rot": 0}
      },
      "tags": []
    }
  }
  "Input voltage source"
  vs = ElectricalComponents.Analog.Sources.VoltageSource() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 410, "x2": 260, "y2": 310, "rot": 90}
      },
      "tags": []
    }
  }
  "VCC with transConductance=0.5 S"
  vcc = ElectricalComponents.Analog.Basic.VCC(transConductance = 0.5) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 450, "y1": 320, "x2": 550, "y2": 420, "rot": 0}
      },
      "tags": []
    }
  }
  "Output load resistor"
  r_load = ElectricalComponents.Analog.Basic.Resistor(R = 10) {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 730, "y1": 410, "x2": 830, "y2": 310, "rot": 90}
      },
      "tags": []
    }
  }
  "Input-side ground"
  gnd1 = ElectricalComponents.Analog.Basic.Ground() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 160, "y1": 580, "x2": 260, "y2": 680, "rot": 0}
      },
      "tags": []
    }
  }
  "Output-side ground"
  gnd2 = ElectricalComponents.Analog.Basic.Ground() {
    "Dyad": {
      "placement": {
        "diagram": {"iconName": "default", "x1": 520, "y1": 570, "x2": 620, "y2": 670, "rot": 0}
      },
      "tags": []
    }
  }
relations
  connect(sine.y, vs.V) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(vs.p, vcc.p1) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 210, "y": 250}, {"x": 391, "y": 250}, {"x": 391, "y": 321}],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(vs.n, gnd1.g) {"Dyad": {"edges": [{"S": 1, "M": [], "E": 2}], "renderStyle": "standard"}}
  connect(vs.n, vcc.n1) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [
            {"x": 210, "y": 470},
            {"x": 390, "y": 470},
            {"x": 390, "y": 420},
            {"x": 451, "y": 420}
          ],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(vcc.p2, r_load.p) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [
            {"x": 551, "y": 320},
            {"x": 620, "y": 320},
            {"x": 620, "y": 250},
            {"x": 780, "y": 250}
          ],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(r_load.n, vcc.n2) {
    "Dyad": {
      "edges": [
        {
          "S": 1,
          "M": [{"x": 780, "y": 470}, {"x": 571, "y": 470}, {"x": 571, "y": 420}],
          "E": 2
        }
      ],
      "renderStyle": "standard"
    }
  }
  connect(vcc.n2, gnd2.g) {
    "Dyad": {
      "renderStyle": "standard",
      "edges": [{"S": 1, "M": [{"x": 570, "y": 420}], "E": 2}]
    }
  }
metadata {
  "Dyad": {
    "icons": {"default": "dyad://ElectricalComponents/Example.svg"},
    "tests": {
      "case1": {"stop": 1, "expect": {"signals": ["vcc.v1", "vcc.i1", "vcc.i2", "vcc.v2"]}}
    }
  }
}
end


Test Cases

Test Case case1

julia
plt

julia
plt

julia
plt

julia
plt