201 Battery Input
201-battery-input.mc describes a small protected battery input.
DC.BAT BAT(3.7V, 1000mAh) gives the battery's nominal voltage first and its charge capacity second. mAh measures electric charge, while uF measures capacitance; the two units are not interchangeable. The library records this second value as the battery's capacity specification.
The battery positive pin is routed through F_BAT and then through the Schottky diode D_REVERSE. The diode anode is on the fused battery side, and the cathode creates the protected VBAT_PROTECTED rail. The battery negative pin is tied to GND. C_BULK connects from VBAT_PROTECTED to GND as a bulk input capacitor.
Parse 201-battery-input.mc:
bash
eval "$(../mcc/scripts/mcc-slot.sh)"
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 20-power-recipes/201-battery-input.mc --lib mcode --pass1 --pass2Generate HTML for 201-battery-input.mc:
bash
eval "$(../mcc/scripts/mcc-slot.sh)"
MCC_SYSTEM_ROOT="$(cd .. && pwd)" "$MCC_BIN" --local parse 20-power-recipes/201-battery-input.mc --lib mcode --viz -o 20-power-recipes/201-battery-input.htmlSource
text
// Example: Battery Input
// Goal: Represent a battery as the source for a board.
// Library focus: DC.BAT, FUSE, DIO.SCH, CAP.
module main
{
io GND
io VBAT_PROTECTED
DC.BAT BAT(3.7V, 1000mAh)
FUSE F_BAT(1A, 12V)
DIO.SCH D_REVERSE(0.3V, 40V, 2A)
CAP.ELEC C_BULK(100uF, 10V)
BAT.1 -> F_BAT -> D_REVERSE.A
D_REVERSE.K -> VBAT_PROTECTED
VBAT_PROTECTED -> C_BULK -> GND
BAT.2 -> GND
}