Skip to content

013 Diode Rectifier ​

013-diode-rectifier.mc explicitly selects diode pins because reversing a diode changes the circuit. VIN connects to D_RECT.ANODE, and D_RECT.CATHODE feeds VRECT; R_LOAD then provides a path to GND. Descriptive member access is the same dot syntax used for switch pins, but here it makes semiconductor polarity unambiguous.

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

Source ​

text
// Example: Diode Rectifier
// Goal: Use a diode to define one-way current flow.
// Library focus: DIO, RES.

module main
{
    io GND
    io VIN
    io VRECT

    DIO D_RECT(0.7V, 100V, 1A)
    RES R_LOAD(1000R, 50V)

    // Named pins make the diode orientation explicit: current enters ANODE
    // and leaves CATHODE toward the rectified output.
    VIN -> D_RECT.A
    D_RECT.K -> VRECT
    VRECT -> R_LOAD -> GND
}

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