232 Photodiode Input
232-photodiode-input.mc is useful as the smallest readable photodiode input stage supported by the current library. It models a reverse-biased photodiode and a load resistor that turns sensor current into a voltage.
Topology:
V3V3 -> D_LIGHT.CATHODE
D_LIGHT.ANODE -> LIGHT_SENSE
LIGHT_SENSE -> R_LOAD -> GNDThe photodiode cathode is tied to V3V3, and the anode is the sensed node. This reverse-bias orientation follows the DIO.PHOTO pin names in the library: ANODE and CATHODE. R_LOAD connects LIGHT_SENSE to ground, so photocurrent through the diode develops a voltage at LIGHT_SENSE. A larger light-generated current would produce a larger load-resistor voltage until limited by the supply and the real diode/resistor behavior.
The example values are illustrative: DIO.PHOTO(0.5A/W, 1nA, 850nm) records a responsivity, dark current, and spectral range, while R_LOAD is 100 kΩ. For scale, 1 uA through 100 kΩ would be 0.1 V, but the example does not model a specific light level or guarantee linearity.
This is not a transimpedance amplifier. A resistor-only photodiode input is simple, but its bandwidth, noise, voltage swing, and sensitivity depend strongly on the diode capacitance, resistor value, ADC input loading, and ambient conditions. Use it as a beginner topology, not as a production optical receiver.
The explicit member paths mirror the polarity-sensitive diode style introduced in 01-basic-circuits/013-diode-rectifier.mc. The typed parameters and units are summarized in 90-language-reference/902-attributes-spec-typed-parameters.mc.
Parse 232-photodiode-input.mc:
eval "$(../mcc/scripts/mcc-slot.sh)"
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 23-sensor-recipes/232-photodiode-input.mc --lib mcode --pass1 --pass2Generate HTML for 232-photodiode-input.mc:
eval "$(../mcc/scripts/mcc-slot.sh)"
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 23-sensor-recipes/232-photodiode-input.mc --lib mcode --viz -o 23-sensor-recipes/232-photodiode-input.htmlSource
// Example: Photodiode Input
// Goal: Model a simple reverse-biased photodiode with a load resistor.
// Library focus: DC, DIO.PHOTO, RES.
module main
{
io GND
io LIGHT_SENSE
io V3V3
DC.SRC PWR(3.3V, 1mA)
DIO.PHOTO D_LIGHT(0.5A/W, 1nA, 850nm)
RES R_LOAD(100000R, 50V)
PWR.1 -> V3V3
PWR.2 -> GND
V3V3 -> D_LIGHT.K
D_LIGHT.A -> LIGHT_SENSE
LIGHT_SENSE -> R_LOAD -> GND
}