Source code coming soon. The GitHub repository is private for now and opens to everyone very soon.
BetterSPICE Beta 0.8.0 Join the beta Download soon
Part VI  Parts and modelsReferenceContentsIndex
37

Devices: batteries, board parts and analog blocks

Batteries and supercapacitors, board parts, analog building blocks, sensor modules and RF parts. The parameter tables use the same columns as Devices: passives. Every part has labelled fields with units in the inspector and in All parameters, and the live stimulus of a sensor (light, temperature, field, strain, distance, load) is its main field, first in the list, with a slider range that fits it. A field that shows auto takes a value derived from other parameters until you type one (for example the must-operate voltage of a relay is 0.75 of its coil voltage). Clear it to go back. A variant placed from the library starts with its own typical values, such as 1 kΩ for a Pt1000 or 1.2 V dropout for an AMS1117. A part placed from the library can start with its own values, and a part made with the Part Wizard takes them from its datasheet fields (Part templates reference).

37.1Batteries and supercapacitors

Batteries and supercapacitors
TypePinsVariantsClass
battery (BT)+, -liion, lifepo4, nimh, alkaline, coin, leadacid, lipo_packapproximate

A battery with its chemistry's open-circuit voltage curve against state of charge, a series resistance and a polarisation R1-C1, and a state of charge that falls as it delivers charge. Drag soc to charge or discharge it at once. It warns when the terminal voltage falls below the cut-off.

Batteries and supercapacitors
ChemistryCell voltage from empty to full
Li-ion, LiPo pack3.0 → 3.6 at 20 % → 3.84 at 60 % → 4.2 V
LiFePO42.5 → 3.2 → 3.31 → 3.6 V
NiMH1.0 → 1.2 → 1.26 → 1.4 V
Alkaline0.9 → 1.2 → 1.4 → 1.6 V
Coin (lithium)2.0 → 2.8 → 2.95 → 3.2 V
Lead-acid1.75 → 1.95 → 2.06 → 2.15 V
Batteries and supercapacitors
ParameterKeyUnitDefaultRangeValue comes fromWhat it does
Cells in seriescells1 (lipo_pack 3)Default, inspector, part file
Capacitycapacity_ahAh2Default, inspector, part file
State of chargesoc0 to 10.8Live slider
Series resistancerΩ0.05 (coin 15)Default, inspector, part file
Polarisationr1, c1Ω, F0.02, 2000Default, inspector, part fileRecovery after a load step.
Fixed voltagevVnoneFile or All parametersIf set, a fixed EMF with no state of charge.

Key: the name in the circuit file, in a parameter step (R1.r) and for AI agents. Range: a value outside it is refused with E_PARAM. Value comes from: where you can set it. The All parameters tab and agents can set every parameter.

Try it
Watch a battery sag
  1. Place a battery (liion) and a 4 Ω load. Probe the battery voltage.
  2. Set the timebase to 1 s per second and run.

You should seeThe voltage steps down by I · r at once, then sags further over a minute as the polarisation charges, and recovers slowly when you remove the load.

A supercapacitor (capacitor variant supercap) is a main ESR-C branch with a slower R2-C2 branch and optional leakage: c 1 F, esr 0.1 Ω, r2 10 x esr, c2 0.1 x c, rleak none.

37.2Board parts

Board parts
PartTypePinsModel and parameters (default)
Connectorconn (J)1xN, 2xN, usb_c, usb_micro, usb_a, barrel, trs, trs_sw, rj45, sma, microsd, bat_holder, bananaNo electrical element. It only connects its pins to their nets.
Test point, mounting hole, fiducialtp, mhole, fiducialone pinNo element.
Net tienet_tie (NT)a, b (variant 3: a, b, c)Joins its nets into one.
Jumperjumper (JP)a, b (3way: a, b, c)state (0 open, 1 closed, click to toggle), r (1 mΩ closed).
Resistor networkrnet (RN)iso2, iso4, iso8: a1, b1, … bus4, bus8: com, r1 …r (10 kΩ).
Strain gaugestrain (R)a, bR = r0 (1 + gf · strain · 10-6): r0 (350 Ω), gf (2), strain (0 µε, live).
Ferrite beadferrite (FB)a, bdcr in series with L, R and C set by z100 (600 Ω at 100 MHz), dcr (0.15 Ω), f_srf (1 GHz). Its impedance falls with DC current above irated (0.5 A).
Feed-through capacitorcap3 (C)in, out, gndc (100 nF) to gnd, l_thru (2 nH), rdc (10 mΩ).
Common-mode chokecmc (L)a1, b1, a2, b2Two coupled windings: l (1 mH), k (0.995), dcr (50 mΩ).

37.3Analog building blocks

Analog building blocks
PartTypePinsWhat it doesParameters (default)
Darlington arraydarr (U)uln2003: in1 … in7, gnd, com, out7 … out1. uln2803: 8 channelsReal Darlington pairs with base resistors and clamp diodes to com.rin (2.7 kΩ), imax (0.5 A, warns)
556 dual timertimer556 (U)14 pinsTwo 555 timers sharing the supply.none
Dual potentiometerpot_dual (RV)a1, b1, w1, a2, b2, w2One wiper position moves both gangs.r (10 kΩ), pos (0.5, live), r_end, variant lin or log
Multi-winding transformerxfmr_multi (T)ct: p1, p2, s1, sct, s2. ct_pri, dual, flyback, currentCoupled windings, every pair coupled by k.lp (1 mH), ratio (1), ratio2, ratio_aux (0.2), n (100, current transformer), k (0.999, flyback 0.98), rp, rs
Bridge sensorbridge_sensor (U)exc+, exc-, out+, out-Four resistors unbalanced by the measurand: V(out) = (sens · x + zero) mV/V x V(exc).r_bridge (350 Ω), sens (2 mV/V), x (0 to 1 of full scale, live), zero (0)
Analog sensorasensor (U)VCC, GND, OUTOUT = offset + sens · x, optionally ratiometric.x (25, live), sens (10 mV per unit), offset (0), ratiometric (0), vcc_ref (5 V), rout (100 Ω), icc (60 µA), tau
Instrumentation amplifierinamp (U)rg: in+, in-, rg1, rg2, ref, out, v+, v-. fixed, diff: 6 pinsGain 1 + 2 rf / Rg with the real external Rg, or a fixed gain. Offset and common-mode error (vcm / CMRR) are input referred; large steps slew at slew.rf (24.7 kΩ), gain (1), gbw (1 MHz), slew (1.2 V/µs), vos (50 µV), cmrr_db (100), rail (1.2 V), iq (1.3 mA)
Current-sense amplifiercsa (U)uni: IN+, IN-, OUT, VS, GND. bidir: plus REF. hs: plus REF1, REF2OUT = gain · (V(IN+) - V(IN-) - vos) + reference, with bandwidth and output swing limits.gain (50 V/V), bw (350 kHz), vos (100 µV), rail (30 mV), ib (75 µA)
Hall current sensorisense_hall (U)ip+, ip-, vcc, gnd, out, filtACS712 class: OUT = VCC/2 + sens · I, ratiometric.sens (185 mV/A), r_ip (1.2 mΩ), bw (80 kHz)
Analog multipliermult (U)x1, x2, y1, y2, z, w, v+, v-AD633 class: W = (x1 - x2)(y1 - y2) / scale + z.scale (10 V), bw (1 MHz)
Audio amplifieraudioamp (U)btl, se, lm386Bridge-tied, single-ended, or the LM386 with its gain pins (20 open, 200 with a capacitor). btl / se: SD low shuts the amplifier down (outputs high impedance); SD open is on (300 kΩ pull-up).gain (20), iq (4 mA), rail (0.3 V)
Digital potentiometerdigipot (U)updown (X9C103), spi (MCP4131), i2cWiper set by code. Up/down counts on nINC. SPI takes 16-bit frames. I2C (MCP4017 rheostat W to B) answers at addr 0x2F: a write sets the wiper, a read returns it, and it ACKs on SDA.r (10 kΩ), steps (100, spi 129, i2c 128), code (50, live), r_w (75 Ω), addr (47, i2c)
OTAota (U)in+, in-, iabc, out, v+, v-LM13700 class: Iout = Iabc · tanh(Vin / 2 Vt); the output stays 0.8 V inside the rails.rout (10 MΩ at Iabc = 500 µA, scaling as 1 / Iabc, so at Iabc = 0 the output leaks next to nothing)

37.4Sensor modules and RF parts

Sensor modules and RF parts
PartTypePinsWhat it doesParameters (default)
PIR motion modulepir (U)VCC, OUT, GNDOUT high (3.3 V) while motion is on and t_hold after.motion (0, click), t_hold (2 s)
Ultrasonic rangerultrasonic (U)VCC, TRIG, ECHO, GNDHC-SR04: after a 10 µs TRIG pulse, ECHO is high for 2 · dist / 343 m/s.dist (0.5 m, live)
Touch sensor ICtouch (U)Q, VSS, I, AHLB, VDD, TOGTTP223: Q follows the touch, or toggles with TOG high. AHLB inverts.touch (0, click), t_resp (60 ms)
Microphonemic (MK)electret: out, gnd. mems_analog: VDD, GND, OUT. mems_pdm: VDD, GND, CLK, DATA, LRA test tone at spl dB SPL. The PDM mic outputs a real sigma-delta bit stream.sens (-42 dBV/Pa), spl (94 dB), tone_f (1 kHz), i_d (0.5 mA), vbias (0.9 V), sens_dbfs (-26)
IR receiverirrx (U)OUT, GND, VSWith code set, outputs an NEC frame starting at 10 ms, active low.code
Antennaantenna (AE)mono: feed. dipole: feed+, feed-. chip, pcb: feed, gndRadiation resistance with reactance at f0.r_rad (50 Ω), x (0), f0 (2.45 GHz)
RF attenuatorattenuator (AT)IN, OUT, GNDA matched pi network.atten_db (10 dB), z0 (50 Ω)
Balunbalun (T)UNBAL, GND, BAL+, BAL-Coupled inductors, 1:1, 1:2 or 1:4.lp (100 nH), k (0.98)
SAW filtersaw (FL)IN, OUT, GNDA series resonance at f0 with the bandwidth and insertion loss.f0 (433.92 MHz), bw (1 MHz), il_db (2.5 dB), z0 (50 Ω)
RF amplifierrfamp (U)IN, OUT, VCC, GNDGain with compression at p1db and a pole at f3db, 50 Ω in and out.gain_db (15), f3db (3 GHz), p1db (15 dBm), icc (30 mA)
Peltier (TEC)peltier (TEC)+, -Resistance plus a Seebeck voltage from the temperature difference it pumps.r (2 Ω), seebeck (50 mV/K), rth (1 K/W)
Gas sensorgas (U)h1, h2, a, bMQ-x: the sensing resistance falls with ppm and needs the heater warm.r_h (33 Ω), ppm (100, live), r0, ppm0, k (the variant’s datasheet curve, below), tau_heat (30 s)

The gas sensor (gas) has three variants, and each starts with its own datasheet curve: the sensing resistance is Rs = r0 · (ppm / ppm0)-k. The fields r0, ppm0 and k show auto with the variant's values until you type your own, and a value you typed wins.

Sensor modules and RF parts
VariantGasr0ppm0k
mq2LPG10 kΩ574 ppm0.45
mq135CO276.6 kΩ117 ppm0.361
mq7CO10 kΩ99 ppm0.659

The MQ-135 in 400 ppm of CO2 reads about 49 kΩ. The sensor still needs its heater warm (tau_heat 30 s) before the resistance follows the gas.