circuit

A canvas environment holding a direct-current circuit the reader operates: components in series and parallel, or placed by hand on a grid.

circuitNode
A cell, a closed breaker and two bulbs in series round a loop, with an ammeter reading 300 mA; both bulbs glow dimly.A cell, a closed breaker and two bulbs in series round a loop, with an ammeter reading 300 mA; both bulbs glow dimly.

#Loops, series and parallel

circuit draws a direct-current circuit and solves it. What is written in its body is one loop: each component joined to the next, and the last back to the first. The loop is drawn round a rectangle, cut into top, right, bottom and left runs in the order written.

A parallel holds branches joined between the same two points, drawn as rungs between two rails: the first on the line the group sits on, the rest inside the loop. A branch with more than one component is a series. A parallel standing alone in the body is its own circuit, branch against branch.

A cell and an ammeter on the top of a loop, and along the bottom three rungs between two rails: a bulb, a resistor in series with a second bulb, and a voltmeter reading 6 V. The first bulb glows brighter than the second.A cell and an ammeter on the top of a loop, and along the bottom three rungs between two rails: a bulb, a resistor in series with a second bulb, and a voltmeter reading 6 V. The first bulb glows brighter than the second.
circuit{
    cell#c{$6$ V}(emf: 6)
    ammeter#a{}
    parallel{
        bulb#l1{$L_1$}(resistance: 10)
        series{
            resistor#r{$R$}(resistance: 10)
            bulb#l2{$L_2$}(resistance: 10)
        }
        voltmeter#v{}
    }
}

#Placing a circuit by hand

A circuit series and parallel cannot express, such as a bridge, is placed by hand. Every component names the grid points its ends land on, from: (2, 0); to: (1, 1), x across and y down, and is drawn on the straight line between them at any angle. A lead joins two points with a bare wire. Ends that land on the same point are joined there, with a dot where three or more meet.

A Wheatstone bridge placed by hand: a cell on the left, four resistors in a diamond and an ammeter across its middle reading 0 A.A Wheatstone bridge placed by hand: a cell on the left, four resistors in a diamond and an ammeter across its middle reading 0 A.
circuit{
    cell#c{$5$ V}(from: (0, 2); to: (0, 0); emf: 5)
    lead(from: (0, 0); to: (2, 0))
    lead(from: (0, 2); to: (2, 2))
    resistor#r1{$R_1$}(from: (2, 0); to: (1, 1); resistance: 100)
    resistor#r2{$R_2$}(from: (2, 0); to: (3, 1); resistance: 200)
    resistor#r3{$R_3$}(from: (1, 1); to: (2, 2); resistance: 100)
    resistor#r4{$R_4$}(from: (3, 1); to: (2, 2); resistance: 200)
    ammeter#g{$G$}(from: (1, 1); to: (3, 1))
}

The compiler refuses a circuit that mixes the two:

  • a group in a placed circuit: A 'series' cannot be used in a circuit placed by hand — its components name their own ends with 'from:' and 'to:'
  • a placed component missing an end: This circuit is placed by hand, so every component names both its ends — 'resistor' is missing 'to:'

#Components and their values

Warning
A bare ammeter#a with neither body nor attributes does not parse as a component. Give it an empty body, ammeter#a{}: a meter's letter already names it.

A component's body is its label. Its value is a number in the attribute's SI unit, with an optional prefix letter straight after it: p, n, u (micro), m, k, M, G. So resistance: 4.7k is 4700 ohms and capacitance: 100u is 100 microfarads. A value may instead be an expression in the scene's parameters, resistance: r, which a slider then moves.

  • cell and battery: emf, in volts, and an internal resistance. The long plate is the positive end and faces the way the source drives the current: along the loop, or towards to. A negative emf turns it round.
  • resistor: resistance, in ohms, drawn as the IEC box.
  • bulb: resistance, and rated, the voltage it glows full at.
  • breaker: closed, a switch.
  • ammeter and voltmeter: ideal meters. An ammeter takes no voltage and goes in series; a voltmeter takes no current and goes in a parallel with what it measures.
  • capacitor: capacitance, in farads, and initial, the voltage it starts charged to.
Warning
An ideal cell joined across a closed breaker or an ammeter, with nothing to resist the current, has no solution. The canvas says the circuit is a short circuit and the meters read a dash.

#Meters, bulbs and live values

Every wire a current runs through is lit in the environment's colour, yellow unless written, as strongly as its share of the circuit's largest current, with the current seen flowing along it the way it runs. So is everything the current passes through: a resistor's box, an ammeter's ring, a capacitor's plates while it charges. A wire that carries nothing, such as the leads to a voltmeter, stays grey.

A bulb glows by the power it takes, full at its rated voltage, or at the circuit's whole emf when none is written. A meter writes its reading beneath its label, in amperes or volts with a prefix. Every component with an id publishes current, voltage and power, so {{#a.current}} reads the current in prose and follows the circuit as it changes. A current runs from a component's first end to its second; a voltage is the drop along that current, or a source's rise.

A loop drawn round a rectangle: a 6 V cell, a closed breaker and a bulb across the top, a resistor and an ammeter along the bottom reading 300 mA; the bulb glows dimly.A loop drawn round a rectangle: a 6 V cell, a closed breaker and a bulb across the top, a resistor and an ammeter along the bottom reading 300 mA; the bulb glows dimly.
circuit{
    cell#c{$6$ V}(emf: 6)
    breaker#s{$S$}(closed: true)
    bulb#l{$L$}(resistance: 10)
    resistor#r{$R$}(resistance: 10)
    ammeter#a{}
}

#Breakers, cues and the reader

The reader opens and closes a breaker by clicking it, or by focusing it and pressing Enter or Space, and its blade swings. fixed keeps the reader's hands off a breaker only the prose should move. A !cue.to on closed moves it at a step, and one on a value changes the value:

breaker#s{$S$}(closed: false !cue.to{true}(at: 1) !cue.to{false}(at: 2))

A component taken out by a cue, or hidden, leaves a gap, and the circuit is open there, as a bulb unscrewed from its holder leaves it. The reader's flips last until the step changes.

#Capacitors charging

A capacitor charges and discharges through the circuit. When a step entered forwards, a breaker the reader flips, or a slider changes the circuit, the change is shown happening: six of its slowest time constants played over three seconds, with how far it has got in circuit time read out in the footer. A millisecond membrane and a second-long flash circuit are both seen charging. A step reached by going back or by jumping lands settled, as does every change for a reader who has asked for less motion.

Three frames of an RC circuit as a cue closes its breaker: the breaker open and the capacitor at 0 V, then the breaker closed and the voltmeter across the capacitor part way up, then nearly at the cell's 10 V.Three frames of an RC circuit as a cue closes its breaker: the breaker open and the capacitor at 0 V, then the breaker closed and the voltmeter across the capacitor part way up, then nearly at the cell's 10 V.
circuit{
    cell#c{$10$ V}(emf: 10)
    breaker#s{$S$}(closed: false !cue.to{true}(at: 1 + 300ms))
    resistor#r{$1\,\mathrm{k}\Omega$}(resistance: 1k)
    parallel{
        capacitor#k{$1\,\mathrm{mF}$}(capacitance: 1m)
        voltmeter#v{$V_C$}
    }
}

A capacitor cut off from everything keeps its charge, so where it stands depends on what happened before. Each step replays the breakers' changes in the order they fired, so a capacitor charged at one step and isolated at the next still holds its voltage, however the reader arrived.


#Attributes

title
The caption set over the top-left of the environment, on the environment's own ground.
colour
The hue a wire carrying a current is lit in, along with what the current passes through; a bulb glows in it unless it has a colour: of its own.
colour
Also written: color
Defaultyellow
continue
An earlier circuit environment this one continues: continue: #that-environment. Nothing of the circuit carries: its breakers start where this environment's own closed:s put them.

#Allowed content

#Allowed in

#Examples

Two frames of a series loop as a cue takes its second bulb out: both bulbs glowing dimly, then a gap where the second bulb stood and the first bulb dark, the ammeter at 0 A.Two frames of a series loop as a cue takes its second bulb out: both bulbs glowing dimly, then a gap where the second bulb stood and the first bulb dark, the ammeter at 0 A.
circuit{
    cell#c{$6$ V}(emf: 6)
    bulb#l1{$L_1$}(resistance: 10)
    cue{
        bulb#l2{$L_2$}(resistance: 10)
    }(
        out: 1 + 300ms
    )
    ammeter#a{}
}
A cell with an internal resistance of 2 Ω across a 4 Ω resistor: the voltmeter across the cell reads 4 V, less than its 6 V emf.A cell with an internal resistance of 2 Ω across a 4 Ω resistor: the voltmeter across the cell reads 4 V, less than its 6 V emf.
circuit{
    parallel{
        cell#c{$6$ V, $2\,\Omega$}(emf: 6; resistance: 2)
        voltmeter#v{}
    }
    resistor#r{$4\,\Omega$}(resistance: 4)
    ammeter#a{}
}

#Notes

  • What the body holds is one loop: each component joined to the next, and the last back to the first. A parallel standing alone is its own circuit.
  • A circuit placed by hand names every component's ends with from: and to: and joins points with leads; it cannot also use series or parallel.
  • The circuit is solved whenever anything changes, and every wire a current runs through is lit, with the current seen flowing along it.
  • A capacitor's charging is shown happening, slowed so its time constant can be seen.

#Writing guidance

  • Selecting canvas content — A mark belongs on the canvas when seeing it changes what the reader understands, and the detail holds as a picture on its own.

Last updated