Skip to content

011 Voltage Divider ​

011-voltage-divider.mc connects two equal 10 kΩ resistors between V5V and GND. VOUT is their shared midpoint, so its unloaded voltage is about 2.5 V. No new language construct is needed: the example shows how repeated named nodes make a circuit's important measurement point visible.

bash
eval "$(../mcc/scripts/mcc-slot.sh)"
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 01-basic-circuits/011-voltage-divider.mc --lib mcode --pass1 --pass2
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 01-basic-circuits/011-voltage-divider.mc --lib mcode --viz -o 01-basic-circuits/011-voltage-divider.html

Source ​

text
// Example: Voltage Divider
// Goal: Create a mid-supply analog output node with two resistors.
// Library focus: DC, RES.

module main
{
    io GND
    io V5V
    io VOUT

    DC.SRC PWR(5V, 10mA)
    RES R_TOP(10000R, 50V)
    RES R_BOTTOM(10000R, 50V)

    PWR.1 -> V5V
    PWR.2 -> GND

    V5V -> R_TOP -> VOUT
    VOUT -> R_BOTTOM -> GND
}

MCode Bench is the public face of the MCode stack. Closed capabilities are served through the MCode gateway.