Skip to content

231 NTC Temperature Divider ​

231-ntc-temperature-divider.mc is useful when a controller wants a simple analog voltage that changes with the resistance of an NTC thermistor. It is a conceptual divider, not a complete temperature-measurement design.

Topology:

text
V3V3 -> R_FIXED -> TEMP_SENSE
TEMP_SENSE -> RT_NTC -> GND

R_FIXED is the upper resistor and RT_NTC is the lower resistor. TEMP_SENSE is the divider midpoint that an ADC input could measure in a larger design. The chosen nominal resistance is 10 kΩ, and 3950 is an illustrative beta coefficient for the NTC. If the thermistor is 10 kΩ at the measurement temperature, the unloaded midpoint is about half of 3.3 V, or 1.65 V.

For a typical NTC thermistor, resistance falls as temperature rises. With this orientation, TEMP_SENSE = V3V3 * RT_NTC / (R_FIXED + RT_NTC), so the output voltage falls as temperature rises. The MCode library records nominal resistance, beta coefficient, and voltage rating, but it does not provide the beta reference temperature, ADC reference accuracy, or a calibration curve. This example therefore does not claim an exact temperature conversion.

The syntax follows the voltage-divider pattern from 01-basic-circuits/011-voltage-divider.mc. RES.NTC(10000R, 3950, 50V) matches the current library constructor: the arguments set nominal resistance, beta coefficient, and voltage rating.

Parse 231-ntc-temperature-divider.mc:

bash
eval "$(../mcc/scripts/mcc-slot.sh)"
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 23-sensor-recipes/231-ntc-temperature-divider.mc --lib mcode --pass1 --pass2

Generate HTML for 231-ntc-temperature-divider.mc:

bash
eval "$(../mcc/scripts/mcc-slot.sh)"
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 23-sensor-recipes/231-ntc-temperature-divider.mc --lib mcode --viz -o 23-sensor-recipes/231-ntc-temperature-divider.html

Source ​

text
// Example: NTC Temperature Divider
// Goal: Create a simple analog voltage from an NTC thermistor divider.
// Library focus: DC, RES, RES.NTC.

module main
{
    io GND
    io TEMP_SENSE
    io V3V3

    DC.SRC PWR(3.3V, 5mA)
    RES R_FIXED(10000R, 50V)
    RES.NTC RT_NTC(10000R, 3950, 50V)

    PWR.1 -> V3V3
    PWR.2 -> GND

    V3V3 -> R_FIXED -> TEMP_SENSE
    TEMP_SENSE -> RT_NTC -> GND
}

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