Download and extract the reader ZIP archive (a compressed collection of files). Links labelled “reader ZIP; extract …” download this archive; after extraction, open the named file. The archive includes full-size Portable Network Graphics (PNG) images, editable diagrams, complete code and worksheets.
Diodes · charging and discharging
Add a direction-sensitive path beside a resistor, then reverse it. The same capacitor can charge quickly and discharge slowly—or do the opposite. A third control, with the diode removed to open its branch, checks what the diode actually changed.
A resistor–capacitor (RC) network combines a resistor, which opposes current, with a capacitor, which stores electric charge. Resistance is measured in ohms (Ω): kΩ means a thousand ohms and MΩ a million ohms; capacitance, charge stored per volt, is measured in farads (F). Here the capacitor is 10 nanofarads (nF), or 10 × 10−9 F. A rising edge is a transition toward a higher voltage; a falling edge moves toward a lower voltage.
One ordinary RC path is nearly direction-symmetric when its source and load remain linear, with direction-independent resistive behavior. A diode is different: its anode and cathode are the two terminals, and it conducts readily when the anode is sufficiently more positive than the cathode. In the forward configuration below, a diode provides an additional charging path. Reversing it provides the additional path during discharge instead.
The reader includes a comma-separated values (CSV) worksheet, complete Python code and tests. Each figure has a full-size Portable Network Graphics (PNG) image and an editable Scalable Vector Graphics (SVG) original. Explanations, tables, and calculations remain searchable article text.
The two paths—and the one shared source resistance
IN is the physical input node at the fixture connector, and OUT is the capacitor node. The main path is IN → R1, 10 kΩ → OUT. The second path is IN → R2, 1 kΩ → D1 → OUT. In the forward configuration, D1’s anode faces R2 and IN; its black-band cathode faces OUT. C1 connects OUT to the common return, G0. R3, 1 MΩ, also connects OUT to G0 and provides a discharge path when the generator output is disabled.
Parallel branches join the same two endpoints, so current can split between them. The generator’s physical output resistance is before IN, shared by both parallel paths. It is not another 50 Ω resistor copied into each branch. Its voltage drop depends on the total current drawn by both paths and the input probe, so IN can differ from the generator’s unloaded command voltage during an edge.
Use an oscilloscope, or scope, to display voltage against time. A probe connects a circuit node to a scope input and also loads that node with some resistance and capacitance. This fixture uses two Tektronix TPP0100 fixed 10× probes on a TBS1052C: channel 1’s tip at IN and channel 2’s tip at OUT. Both probe ground leads go to G0. The generator’s bayonet Neill–Concelman (BNC) coaxial connector has a center conductor carrying IN and an outer shell connected to G0.
Both instruments use their specified, protective-earthed mains cords before any signal connection. The AFG1022 signal return is chassis referenced, and the scope ground leads are earth referenced. G0 is the same return everywhere. Never put a scope ground clip on IN, OUT, or opposite ends of the diode to measure “across” it; that would connect that point to the common earth return. Keep all power-cord earth connections intact. No other powered circuit or source is connected to this fixture.
The source is a Tektronix AFG1022 channel 1, with channel 2 OFF. Configure a 250 hertz (Hz) square wave: 250 cycles each second, a 4 millisecond (ms) period, and 50% duty cycle, meaning 2 ms high and 2 ms low. Set its load declaration to High Z, meaning a high-impedance load, then set 5 volts peak-to-peak (Vpp) and +2.5 V offset for target 0–5 V levels. Vpp is the difference between high and low; offset shifts their midpoint.
High Z changes the amplitude display convention; it does not remove the physical 50 Ω typical source resistance. With the wrong 50 Ω load declaration and no matching termination, the unloaded voltage can be twice the displayed amplitude. Do not install a separate 50 Ω terminator here. Verify actual IN on channel 1 before accepting any measurement, and verify it again with the full fixture connected.
Set both scope channels to direct-current (DC) coupling, which preserves the voltage level, and set their probe factors to 10×. Compensate both probes on the scope’s reference output according to its manual before connecting the fixture: adjust their compensation controls for the specified flat square-wave response. This matches the probe to the scope input; it does not calibrate this experiment’s pulse or timing. Do not use a 1× probe mode or substitute an unknown probe without revisiting loading.

circuit.svgExact parts and operating limits
The prefix micro, written µ, means one millionth; a microsecond (µs) is one millionth of a second.
| Item | Exact selection / role |
|---|---|
| D1 | Vishay 1N4148-TAP, axial DO-35 / DO-204AH; black cathode band |
| R1 | 10 kΩ ±1%, Vishay MRS25 family: the path present in every configuration |
| R2 | 1 kΩ ±1%, Vishay MRS25: current-limited diode branch |
| R3 | 1 MΩ ±1%, Vishay MRS25: permanent OUT-to-G0 bleeder |
| C1 | WIMA FKP2 polypropylene film/foil, 10 nF, 100 V DC, ±5%, 5 mm lead pitch; nonpolar |
| Generator | Tektronix AFG1022 CH1, High-Z declaration, 5 Vpp, +2.5 V offset, 250 Hz, 50% duty; CH2 OFF |
| Scope | Tektronix TBS1052C; two TPP0100 10× probes, DC coupling, 20,000-point record |
| Initial display | About 1 V/division vertically and 400 µs/division horizontally; this scope has 15 horizontal divisions. Read the actual sample spacing, not a guessed sample rate. |
| Connections | Short leads, insulated BNC-to-fixture connection, identified IN/OUT/G0 test points; no external supply or load |
The WIMA value table gives the 100 V, 10 nF body as 6.5 × 8 × 7.2 mm with 5 mm pitch and base ordering stem FKP2D021001I00____. Select the documented J tolerance option for ±5% and a suitable documented lead/packing option; the incomplete stem is not a complete order code. The capacitor has no anode or cathode. Do not replace it with a polarized electrolytic.
Vishay’s current 1N4148 document 81857, revision 1.6 of 7 November 2024, specifies the -TAP packing and DO-35 package. Current is measured in amperes (A); a milliampere (mA) is one thousandth of an ampere. The A terminal label beside D1 means anode, rather than the ampere unit. The document lists 75 V reverse, 300 mA continuous forward, and 150 mA average-forward absolute limits under their stated conditions. Those are stress limits, not operating targets. The observed screening window allows each of IN and OUT to range from −0.25 to 5.5 V, so their worst-case differential is 5.75 V. With the 1 kΩ branch resistor at its 990 Ω tolerance minimum, even a zero-drop branch is limited to about 5.81 mA. R1 can add at most about 0.581 mA at 9.9 kΩ. The same 5.75 V differential bounds the diode’s reverse stress within this screened window. This is a component current budget, not a promise that a generator limiter protects every wiring fault.
Power is energy per second, measured in watts (W); energy is measured in joules (J). A milliwatt (mW) is one thousandth of a watt, and µW/µJ mean microwatts/microjoules. The worst-case R2 power with that same deliberately conservative zero-drop differential bound is 5.75²/990 ≈ 33.4 mW, well below the chosen resistor family’s 0.6 W rating under its published conditions. R3 dissipates only about 30.6 µW. C1 stores about 0.16 µJ at 5.5 V. None of these numbers permits applying an unknown external source or shorting an instrument output.
Why one exponential is not the whole story
A time constant, written τ (tau), is the characteristic time of a single linear RC exponential: after one time constant, a charging voltage has covered about 63.2% of the distance to its final level. In the open-diode control, the loaded circuit is nearly one such exponential. With D1 fitted, its conducting state changes during an edge, so one resistance-times-capacitance value does not describe the entire transition.
During a forward rising edge, R2 and D1 add current while IN exceeds OUT by enough to forward-bias the diode. Forward bias means an anode-to-cathode voltage that allows appreciable current. As OUT approaches IN, diode current falls and the main 10 kΩ path finishes the tail. During the falling edge, this orientation blocks the fast branch and discharge is mainly through R1. Reversing the diode exchanges those roles, with the bleeder and probe loads still present.
Measure the early-to-middle part using actual OUT plateaus—the stable low and high voltage regions. If L is the observed low level and H the observed high level, define the 20% threshold as L + 0.2(H−L) and the 80% threshold as L + 0.8(H−L). On a rise, time the 20→80% crossings; on a fall, time 80→20%. These are edge durations within one channel, not input-to-output propagation delays. Do not silently use the scope’s default rise-time measurement, which may use other thresholds.
A picofarad (pF) is one trillionth of a farad; the calculation below uses 12 pF as an illustrative output-probe capacitance.
Open branch, conditional model using chosen nominal (label) values:
Rdrive = 10 kΩ + (50 Ω || 10 MΩ)
Rload = 1 MΩ || 10 MΩ
Ctotal = 10 nF + 12 pF
τ = (Rdrive || Rload) × Ctotal ≈ 99.52 µs
20–80% duration = ln(4) × τ ≈ 137.96 µs
ln means the natural logarithm.
The symbol || means parallel combination: Ra || Rb = 1/(1/Ra + 1/Rb).
The conducting diode branch has a voltage offset as well as resistance;
do not replace its entire edge by ln(4) × (R1 || R2) × C1.
The two probe inputs are about 10 MΩ each at DC; the TPP0100 specifies ±1.5% resistance and less than 12 pF typical input capacitance in its current datasheet. The model chooses 12 pF on OUT and a 10 MΩ input at both IN and OUT. Twelve picofarads (pF) are 12 × 10−12 F. This choice is an illustration, not a guaranteed bound on a real probe plus breadboard. Input-probe capacitance is omitted from the model; a nominal 50 Ω × 12 pF scale is only 0.6 nanoseconds (ns), far below these tens-to-hundreds of microseconds. Unmeasured wiring and probe behavior remain limitations.
The older TBS1000C manual’s probe compensation-range table differs from the current TPP0100/TPP0101 datasheet. The scope manual explicitly supplies TPP0100 with TBS1052C; use the actual correct model and compensate it rather than treating the conflicting table as a measured capacitance. The current probe datasheet identifies TPP0100 for nominal 1 MΩ/13 pF scope inputs.
The calculated graph is a model, not a capture
The program solves the shared source node and integrates capacitor current with the fourth-order Runge–Kutta (RK4) numerical method. Before calculating a trajectory, it requires the internal step to be at most one twentieth of the conservative fastest-pole scale (Ctotal divided by the sum of 1/R1, 1/R2, 1/R3 and 1/Rprobe,OUT). An unresolved numerical domain is refused, rather than returning a finite but unstable trace. This is a declared computational window; the nominal analytical and refinement checks do not certify every possible parameter combination. Its command voltage Vcmd is a finite 250 Hz square wave with an assumed 100 ns edge. VIN is the loaded model voltage at IN, and VOUT is the capacitor voltage. Only the model has direct access to Vcmd; on the bench, channel 1 measures IN.
The model diode has an assumed constant forward drop of 0.65 V, no reverse leakage or recovery, and no junction capacitance. Vishay’s 1 V maximum forward voltage is specified at 10 mA; it is not a fixed voltage for this smaller-current waveform. The datasheet’s typical current/temperature curves likewise do not turn a chosen 0.65 V into a calibrated prediction. The included 0.45/0.85 V and source-resistance variations are sensitivity examples, not manufacturer limits or confidence intervals.

signals.svg| Diode branch | Rise 20–80% | Fall 80–20% |
|---|---|---|
| Forward | 19.5 µs | 138.0 µs |
| Reversed | 138.0 µs | 20.0 µs |
| Open | 138.0 µs | 138.0 µs |
| Forward restored | 19.5 µs | 138.0 µs |
Those numbers come from the delivered model and its 0.5 µs output-sample grid; the code uses smaller internal integration steps. The open-control analytic calculation and a refined-step comparison are host checks. They are not tests of a diode, scope, probe, source impedance, or actual timing uncertainty.
Build and acquire the controls
- Prepare unpowered. Set the generator output OFF. Check both earth connections, the diode band, resistor values and capacitor marking. Wire the forward circuit. Keep the capacitor, resistor network, leads and probes fixed through the experiment except for the intended diode change.
- Check the instruments. Compensate both 10× probes, then return them to IN/OUT with both ground clips on G0. Set DC coupling and matching 10× channel factors. Verify the generator’s High-Z declaration before setting amplitude and offset. With the fixture connected, turn on only CH1’s output and inspect actual IN.
- Check the envelope. IN’s stable low should be within ±0.1 V and its stable high within 4.75–5.25 V. Inspect both traces for overshoot, undershoot and clipping. Stop if either leaves −0.25 to 5.5 V, if a channel clips, or if the source cannot produce the chosen levels. These are observed teaching screens, not pre-certified source bounds. The waveform must show 2 ms high and 2 ms low, with stable endpoint regions; do not use a narrow pulse that starts the next edge before the capacitor settles.
- Capture enough samples. Start around 400 µs/division with the 20,000-point record. This scope has 15 horizontal divisions, so the initial span is about 6 ms. Use channel 1 rising-edge triggering around 2.5 V and a stable single acquisition containing the required rising/falling edges and plateaus. Read the actual sample spacing: require 0.5 µs or finer for this worksheet. Zoom and adjust the acquisition if necessary; a setting label alone is not proof of sample spacing.
- Identify plateaus and crossings. Determine OUT’s L and H from stable regions after the preceding low/high interval. Check the initial endpoint is within 2% of that swing and plateau spread within 1%. Check IN’s own 20–80% edge is no longer than 2 µs. Mark the two output thresholds from the actual L/H values, not 0/5 V command labels.
- Keep the raw record. Save the numeric waveforms, setup, and an identifying screen image. The manual permits per-channel waveform CSV files on a Universal Serial Bus (USB) drive. A picture of a trace is not the numeric record. Preserve original files and inspect their actual channel, time units and sample columns before copying values; the supplied checker is not a Tektronix file importer.
- Bracket each crossing. From the sampled record, take the adjacent time values that straddle each threshold. Enter lower/upper brackets no wider than 0.5 µs. If a cursor estimate cannot justify such a bracket, improve the record or report it unresolved; do not invent precision. For a fall, the first crossing is 80% and the second 20%. Both use the same time reference.
After every configuration, turn the generator output OFF. With channel 2 still DC coupled, verify OUT has returned close to its G0 baseline and below the chosen 0.1 V discharge screen before touching D1. Temporarily use a more sensitive vertical range to inspect that low reading, then restore the measurement range before applying the waveform. R3 provides a discharge path; its nominal C1-only time constant is 10 ms, but no fixed waiting time is a universal discharge guarantee.
| Case | Only intentional change | Question |
|---|---|---|
| forward | Band toward OUT | Is rising faster than falling? |
| reverse | With output OFF/discharged, reverse only D1 | Does the faster direction swap? |
| open | With output OFF/discharged, remove D1, leaving R1 and all loads | Are the two durations comparable? |
| restore | With output OFF/discharged, return the same D1 to its original orientation | Does the original pattern return? |
Record rise and fall for every case: eight rows. Keep generator settings and probe positions unchanged. Require the recorded IN high/low plateaus across cases to agree within a selected 0.05 V budget; otherwise an altered source or connection is a competing explanation. The analyzer uses selected 5% similarity budgets for the open control and forward restoration. These are gross consistency controls, not device tolerances or a statistical confidence level.
What to do when the observation disagrees
- Both directions remain slow: check D1 orientation, an open lead, R2 value and the actual source levels. An unconnected fast branch should resemble the open control.
- Both directions are very fast: turn OFF and inspect for a bypassed resistor, shorted capacitor, wrong capacitor value, or an unintended low-resistance path. Do not improve a result by changing the scope ground connection.
- The reversed case does not swap: check whether the diode itself was reversed, rather than swapping IN/OUT or moving the probe. Changed wiring or loading can invalidate the comparison.
- Endpoints wander or the next edge arrives early: stop the comparison. Restore the intended frequency, duty cycle, source and capture window, then reacquire all affected controls. Do not fit one exponential to an unfinished transition.
- Several threshold crossings occur: inspect noise, ringing or clipping in the raw record. A bracket around one convenient crossing does not resolve ambiguity; improve the setup or keep the result indeterminate.
Complete model and conditional worksheet analysis
Run the standard-library CPython program below with Python 3.9 or later. The model command emits eight constructed rows; it does not contact an instrument. The check command reads the exact worksheet header and all eight ordered case/edge rows. source_kind=reported means a person reports the readings, not that the software verified acquisition. Never relabel the constructed example as measurements.
python3 diode_rc.py model > constructed-summary.csv
python3 diode_rc.py check constructed-summary.csv
python3 diode_rc.py model --vf 0.45 --rs 100 > sensitivity-example.csv
# Fill a copy of observations-blank.csv with your own record-derived values.
python3 diode_rc.py check your-observations.csv
python3 -m unittest -v test_diode_rc
Download the blank worksheet — reader ZIP; extract observations-blank.csv and the constructed nominal example — reader ZIP; extract constructed-summary.csv. Times are seconds and voltages are volts. initial_error_v is the absolute difference between the starting endpoint and its stable reference level; plateau_span_v is the largest observed spread in a chosen stable low/high region. input_edge_upper_s is the upper bracket on IN’s corresponding 20–80% edge duration. Note separately which raw files, units, windows and thresholds produced each row.
If the first crossing lies in [a,b] and the second in [c,d], the duration’s sampling bracket is [c−b,d−a]. It does not include all voltage-threshold, probe, timebase, interpolation, drift or cursor-position uncertainty. The worksheet’s brackets are declared observations; even a passing report does not prove the source envelope or absence of missed overshoot in the raw trace.
A valid JavaScript Object Notation (JSON) report exits 0 even when a quality or pattern screen is false. Read conditional_pattern_supported and every check. Malformed, incomplete, reordered, duplicate, nonfinite or unsupported input exits 2, with an error and no JSON report. The file limit is 65,536 bytes. The program always marks physical acquisition, full timing uncertainty and the physical power-off/wiring/source-impedance conditions as unverified.
Complete program: diode_rc.py
#!/usr/bin/env python3
"""Finite diode-steered RC teaching model; no hardware acquisition or calibrated timing."""
from dataclasses import dataclass, fields
from functools import lru_cache
import math
@dataclass(frozen=True)
class Parameters:
rslow: float = 10000
rfast: float = 1000
rbleed: float = 1000000
rpin: float = 10000000
rpout: float = 10000000
rs: float = 50
c: float = 10e-9
cp: float = 12e-12
vf: float = .65
def __post_init__(self):
if any(not math.isfinite(getattr(self,f.name)) for f in fields(self)):
raise ValueError('Parameters must be finite')
if any(getattr(self,n)<=0 for n in ('rslow','rfast','rbleed','rpin','rpout','c')):
raise ValueError('Resistances and C must be positive')
if not 0<=self.rs<=1000 or not 0<=self.cp<=1e-9 or not .1<=self.vf<=1.2:
raise ValueError('Model parameter outside declared teaching envelope')
CASES=('forward','reverse','open','restore')
PERIOD=.004
EDGE=.0000001
DT=.0000005
def source(t):
phase=t % PERIOD
if phase<EDGE:
return 5*phase/EDGE
if phase<PERIOD/2:
return 5.
if phase<PERIOD/2+EDGE:
return 5*(1-(phase-PERIOD/2)/EDGE)
return 0.
def nodes(vs,vo,orientation,p):
"""Nodal solution: IN voltage and net current into output capacitance.
The diode is an assumed constant-drop, one-way element. No leakage,
junction-capacitance/recovery or actual device V-I curve is implied.
"""
if orientation not in (-1,0,1):
raise ValueError('Orientation must be -1,0,+1')
gs=1/p.rslow
if p.rs==0:
vin=vs
else:
vin=(vs/p.rs+gs*vo)/(1/p.rs+gs+1/p.rpin)
on=orientation!=0 and orientation*(vin-vo)>p.vf
gf=1/p.rfast if on else 0.
if p.rs!=0:
vin=(vs/p.rs+(gs+gf)*vo+gf*orientation*p.vf)/(1/p.rs+gs+gf+1/p.rpin)
fast=orientation*max(0.,orientation*(vin-vo)-p.vf)/p.rfast if on else 0.
return vin,(vin-vo)*gs+fast-vo*(1/p.rbleed+1/p.rpout)
@lru_cache(maxsize=24)
def simulate(orientation,p=Parameters(),substeps=5):
"""Two finite source periods, sampled at 0.5us; initial output zero.
First period is settling. RK4 integration has smaller internal steps.
Source-IN capacitance is omitted; OUT includes explicit cp. These are
constructed conditional trajectories, not instrument/part predictions.
"""
if type(substeps) is not int or not 2<=substeps<=20:
raise ValueError('Use 2..20 integration subdivisions')
dt=DT/substeps
# Conservative fastest-pole bound: a zero source resistance and both
# branches conducting cannot be slower than this bound. Refuse an
# unresolved fixed-step domain; never return a finite unstable trace.
try:
tau_bound=(p.c+p.cp)/(1/p.rslow+1/p.rfast+1/p.rbleed+1/p.rpout)
except (OverflowError,ZeroDivisionError) as exc:
raise ValueError('Unsupported numerical RC domain') from exc
if not math.isfinite(tau_bound) or tau_bound<=0 or dt>tau_bound/20:
raise ValueError('Integration step exceeds fastest RC bound / 20')
count=16000
t=-.00425
vo=0.
result=[]
def slope(time,v):
return nodes(source(time),v,orientation,p)[1]/(p.c+p.cp)
for i in range(count+1):
t=-.00425+i*DT
vin,_=nodes(source(t),vo,orientation,p)
result.append((t,vin,vo))
for k in range(substeps):
a=t+k*dt
k1=slope(a,vo)
k2=slope(a+dt/2,vo+dt*k1/2)
k3=slope(a+dt/2,vo+dt*k2/2)
k4=slope(a+dt,vo+dt*k3)
vo+=dt*(k1+2*k2+2*k3+k4)/6
return tuple(result)
def average_window(trace,column,a,b):
vals=[r[column] for r in trace if a<=r[0]<=b]
if not vals:
raise ValueError('No plateau samples')
return sum(vals)/len(vals),max(vals)-min(vals)
def crossing(trace,column,level,edge,rising):
pairs=[]
for a,b in zip(trace,trace[1:]):
if a[0]<edge-10e-6 or b[0]>edge+.001:
continue
if (a[column]<level<=b[column] if rising else a[column]>level>=b[column]):
pairs.append((a[0]-edge,b[0]-edge))
if len(pairs)!=1:
raise ValueError('Crossing is missing or not unique')
return pairs[0]
def model_rows(case,p=Parameters(),substeps=5):
if case not in CASES:
raise ValueError('Unknown case')
ori={'forward':1,'reverse':-1,'open':0,'restore':1}[case]
trace=simulate(ori,p,substeps)
il,_=average_window(trace,1,-.00020,-.00005)
ih,_=average_window(trace,1,.0015,.0019)
ol,olspan=average_window(trace,2,-.00020,-.00005)
oh,ohspan=average_window(trace,2,.0015,.0019)
rows=[]
for edge,t0,rising in [('rise',0.,True),('fall',.002,False)]:
first,second=(.2,.8) if rising else (.8,.2)
a=crossing(trace,2,ol+first*(oh-ol),t0,rising)
b=crossing(trace,2,ol+second*(oh-ol),t0,rising)
ia=crossing(trace,1,il+first*(ih-il),t0,rising)
ib=crossing(trace,1,il+second*(ih-il),t0,rising)
rows.append({'case':case,'edge':edge,'source_kind':'constructed',
'off_out_v':0.,'in_low_v':il,'in_high_v':ih,
'out_low_v':ol,'out_high_v':oh,'initial_error_v':0.,
'plateau_span_v':max(olspan,ohspan),
'input_edge_upper_s':ib[1]-ia[0],
'first_lo_s':a[0],'first_hi_s':a[1],
'second_lo_s':b[0],'second_hi_s':b[1]})
return rows
def model_summary(case,p=Parameters()):
return {r['edge']:(r['second_lo_s']+r['second_hi_s']-r['first_lo_s']-r['first_hi_s'])/2
for r in model_rows(case,p)}
import argparse
import csv
import io
import json
import sys
from pathlib import Path
HEADER=('case','edge','source_kind','off_out_v','in_low_v','in_high_v',
'out_low_v','out_high_v','initial_error_v','plateau_span_v',
'input_edge_upper_s','first_lo_s','first_hi_s','second_lo_s','second_hi_s')
MAX_BYTES=65536
def number(value):
if isinstance(value,bool):
raise ValueError('Boolean is not a reading')
try:
result=float(value)
except (ValueError,TypeError,OverflowError) as exc:
raise ValueError('Blank or nonnumeric reading') from exc
if not math.isfinite(result) or abs(result)>1e6:
raise ValueError('Nonfinite or unsupported reading')
return result
def analyze_rows(rows):
if not isinstance(rows,(list,tuple)) or len(rows)!=8:
raise ValueError('Need all eight rows: forward/reverse/open/restore, rise/fall')
keys=[(case,edge) for case in CASES for edge in ('rise','fall')]
results=[]
origins=set()
for row,key in zip(rows,keys):
if not isinstance(row,dict) or set(row)!=set(HEADER):
raise ValueError('Exact worksheet fields required')
if (row['case'],row['edge'])!=key:
raise ValueError('Wrong, duplicate or out-of-order case/edge')
origin=row['source_kind'];origins.add(origin)
if origin not in ('reported','constructed'):
raise ValueError('source_kind must be reported or constructed')
v={n:number(row[n]) for n in HEADER[3:]}
a,b,c,e=(v[n] for n in ('first_lo_s','first_hi_s','second_lo_s','second_hi_s'))
if a>b or c>e or max(abs(x) for x in (a,b,c,e))>.001:
raise ValueError('Reversed or unsupported crossing bracket')
duration=[c-b,e-a]
swing=v['out_high_v']-v['out_low_v']
screens={
'reported_off_discharge':abs(v['off_out_v'])<=.1,
'reported_input_levels':abs(v['in_low_v'])<=.1 and 4.75<=v['in_high_v']<=5.25,
'reported_output_levels':abs(v['out_low_v'])<=.1 and 4.5<=swing<=5.35,
'reported_initial_state':0<=v['initial_error_v']<=.02*swing,
'reported_plateau_stability':0<=v['plateau_span_v']<=.01*swing,
'reported_fast_input':0<v['input_edge_upper_s']<=2e-6+1e-15,
'sample_brackets_resolved':duration[0]>0 and b-a<=.5e-6+1e-15 and e-c<=.5e-6+1e-15}
results.append({'case':key[0],'edge':key[1],'source_kind':origin,
'duration_sampling_bracket_s':duration,'declared_values':v,
'screens':screens,'passed':all(screens.values())})
if len(origins)!=1:
raise ValueError('Do not mix constructed and reported rows')
by={(r['case'],r['edge']):r['duration_sampling_bracket_s'] for r in results}
def near(a,b):
gap=max(0.,max(a[0],b[0])-min(a[1],b[1]))
return gap<=.05*max(a[1],b[1])+1e-15
values=[r['declared_values'] for r in results]
checks={'all_reported_quality_screens':all(r['passed'] for r in results),
'source_plateaus_comparable':all(max(v[n] for v in values)-min(v[n] for v in values)<=.05+1e-12
for n in ('in_low_v','in_high_v')),
'forward_rise_faster':by['forward','rise'][1]<by['forward','fall'][0],
'reverse_fall_faster':by['reverse','fall'][1]<by['reverse','rise'][0],
'open_symmetry':near(by['open','rise'],by['open','fall']),
'restoration':all(near(by['forward',e],by['restore',e]) for e in ('rise','fall'))}
return {'schema':'trickycircuit-diode-rc-1','valid_report':True,
'source_kind_declared':next(iter(origins)),
'physical_acquisition_verified':False,'full_timing_uncertainty_verified':False,
'poweroff_wiring_source_impedance_and_same_components_verified':False,
'conditional_pattern_supported':all(checks.values()),'checks':checks,'rows':results,
'limits':['Crossing intervals are declared sampling/cursor brackets only, not calibrated accuracy bounds.',
'Quality, input levels, origins, wiring, unchanged parts and power-off sequence are manual declarations.',
'Five-percent symmetry/restoration and other screens are chosen teaching controls, not device specifications.',
'No diode V-I fit, reverse-recovery, debounce, propagation-delay or bench certification.']}
def read_csv(path):
try:
with Path(path).open('rb') as f:
data=f.read(MAX_BYTES+1)
if len(data)>MAX_BYTES:
raise ValueError('Worksheet exceeds 65536 bytes')
parser=csv.reader(io.StringIO(data.decode('utf8'),newline=''),strict=True)
if next(parser,None)!=list(HEADER):
raise ValueError('Need exact unique ordered worksheet header')
rows=[]
for cells in parser:
if len(cells)!=len(HEADER):
raise ValueError('Wrong cell count or blank record')
rows.append(dict(zip(HEADER,cells)))
if len(rows)>8:
raise ValueError('More than eight rows')
return rows
except (OSError,UnicodeError,csv.Error) as exc:
raise ValueError('Cannot read strict UTF8 CSV: '+str(exc)) from exc
def main(argv=None):
parser=argparse.ArgumentParser(description=__doc__)
sub=parser.add_subparsers(dest='command',required=True)
model=sub.add_parser('model',help='emit eight constructed summary rows')
model.add_argument('--vf',type=float,default=.65,help='assumed constant diode drop, not a measured value')
model.add_argument('--rs',type=float,default=50.,help='assumed source resistance in ohms')
check=sub.add_parser('check',help='conditional analysis of all eight summary rows')
check.add_argument('worksheet')
args=parser.parse_args(argv)
try:
if args.command=='model':
p=Parameters(vf=args.vf,rs=args.rs)
rows=[r for case in CASES for r in model_rows(case,p)]
# Compute all rows before emitting any CSV.
output=io.StringIO(newline='');writer=csv.DictWriter(output,fieldnames=HEADER,lineterminator='\n')
writer.writeheader();writer.writerows(rows)
print(output.getvalue(),end='')
else:
result=analyze_rows(read_csv(args.worksheet))
print(json.dumps(result,indent=2,allow_nan=False))
except (ValueError,OSError,OverflowError) as exc:
print('Input error: '+str(exc),file=sys.stderr)
return 2
return 0
if __name__=='__main__':
sys.exit(main())
Complete constructed-summary.csv
case,edge,source_kind,off_out_v,in_low_v,in_high_v,out_low_v,out_high_v,initial_error_v,plateau_span_v,input_edge_upper_s,first_lo_s,first_hi_s,second_lo_s,second_hi_s
forward,rise,constructed,0.0,1.7709857683548284e-10,4.999703009414892,3.5596991042508896e-08,4.94530459540332,0.0,2.5288515814736456e-07,5.000000000005e-07,1.999999999999398e-06,2.499999999999898e-06,2.1499999999999818e-05,2.199999999999945e-05
forward,fall,constructed,0.0,1.7709857683548284e-10,4.999703009414892,3.5596991042508896e-08,4.94530459540332,0.0,2.5288515814736456e-07,5.000000000005e-07,2.199999999999945e-05,2.2499999999999083e-05,0.00015999999999999955,0.00016049999999999918
reverse,rise,constructed,0.0,3.5193471130213755e-11,4.999703008021518,7.0739228906440906e-09,4.945304315332609,0.0,1.3756402816866853e-06,5.000000000005e-07,2.199999999999945e-05,2.2499999999999083e-05,0.00015999999999999955,0.00016049999999999918
reverse,fall,constructed,0.0,3.5193471130213755e-11,4.999703008021518,7.0739228906440906e-09,4.945304315332609,0.0,1.3756402816866853e-06,5.000000000005e-07,2.4999999999990308e-06,2.999999999999531e-06,2.2499999999999083e-05,2.2999999999999583e-05
open,rise,constructed,0.0,1.7709857656493266e-10,4.999703008021518,3.559699098812799e-08,4.945304315332609,0.0,1.37564027902215e-06,5.000000000005e-07,2.199999999999945e-05,2.2499999999999083e-05,0.00015999999999999955,0.00016049999999999918
open,fall,constructed,0.0,1.7709857656493266e-10,4.999703008021518,3.559699098812799e-08,4.945304315332609,0.0,1.37564027902215e-06,5.000000000005e-07,2.199999999999945e-05,2.2499999999999083e-05,0.00015999999999999955,0.00016049999999999918
restore,rise,constructed,0.0,1.7709857683548284e-10,4.999703009414892,3.5596991042508896e-08,4.94530459540332,0.0,2.5288515814736456e-07,5.000000000005e-07,1.999999999999398e-06,2.499999999999898e-06,2.1499999999999818e-05,2.199999999999945e-05
restore,fall,constructed,0.0,1.7709857683548284e-10,4.999703009414892,3.5596991042508896e-08,4.94530459540332,0.0,2.5288515814736456e-07,5.000000000005e-07,2.199999999999945e-05,2.2499999999999083e-05,0.00015999999999999955,0.00016049999999999918
Executed host checks and their limits
The author ran the delivered 20 test methods on a host computer. The model checks use a separately calculated loaded open-control time constant, current conservation at the shared source node, reversal/open/restoration behavior, capacitance and source-resistance changes, assumed-drop sensitivity, and integration-step refinement, nominal passivity, and refusal of a capacitance too small for the fixed step. The analyzer checks include independent declared timing examples, failed restoration, failed symmetry, poor settling/source conditions, unresolved brackets, malformed headers, invalid encoding, blank/duplicate/extra rows and actual command-line behavior.
The development evidence records a failing model stage and a failing reduction stage before the passing implementations. These tests do not establish a real diode’s voltage curve, physical pulse fidelity, scope accuracy, or a completed experiment. No firmware, target binary, or instrument-control program is supplied or claimed.
Complete host tests: test_diode_rc.py
import math
import unittest
import diode_rc as d
class ModelTests(unittest.TestCase):
def test_two_branch_directions_and_open_control(self):
times = {case: d.model_summary(case) for case in ('forward','reverse','open','restore')}
self.assertLess(times['forward']['rise'], times['forward']['fall'] / 3)
self.assertLess(times['reverse']['fall'], times['reverse']['rise'] / 3)
self.assertAlmostEqual(times['open']['rise'], times['open']['fall'], delta=1e-6)
self.assertEqual(times['forward'], times['restore'])
def test_open_control_matches_loaded_analytic_time_constant(self):
p=d.Parameters()
drive=p.rslow + 1/(1/p.rs + 1/p.rpin)
load=1/(1/p.rbleed + 1/p.rpout)
tau=1/(1/drive+1/load)*(p.c+p.cp)
result=d.model_summary('open')
self.assertAlmostEqual(result['rise'], math.log(4)*tau, delta=1e-6)
def test_capacitance_and_source_resistance_matter(self):
a=d.model_summary('forward')
b=d.model_summary('forward',d.Parameters(c=20e-9))
self.assertGreater(b['rise'],a['rise']*1.9)
c=d.model_summary('forward',d.Parameters(rs=500))
self.assertGreater(c['rise'],a['rise'])
def test_assumed_diode_drop_changes_model_not_a_datasheet_bound(self):
a=d.model_summary('forward',d.Parameters(vf=.45))
b=d.model_summary('forward',d.Parameters(vf=.85))
self.assertGreater(b['rise'],a['rise'])
def test_unresolved_numerical_window_refused_before_trajectory(self):
# Actual pre-fix passive0..5V model overshot for this accepted C.
with self.assertRaises(ValueError):
d.simulate(1,d.Parameters(c=1e-15))
def test_nominal_passivity_for_each_orientation(self):
for orientation in (-1,0,1):
trace=d.simulate(orientation)
self.assertTrue(all(-1e-9<=r[2]<=5+1e-9 for r in trace))
def test_nodal_conservation_and_nonideal_input(self):
p=d.Parameters();vin,ic=d.nodes(5,0,1,p)
self.assertLess(vin,5)
self.assertAlmostEqual((5-vin)/p.rs, vin/p.rpin+ic, places=12)
import csv, io, json, subprocess, sys, tempfile
from pathlib import Path
HEADER=['case','edge','source_kind','off_out_v','in_low_v','in_high_v',
'out_low_v','out_high_v','initial_error_v','plateau_span_v',
'input_edge_upper_s','first_lo_s','first_hi_s','second_lo_s','second_hi_s']
def fixture():
rows=[]
# Independent declared timing examples: each duration bracket straddles 20 or 140us.
for case,edges in [('forward',(20,140)),('reverse',(140,20)),('open',(140,140)),('restore',(20,140))]:
for edge,duration in zip(('rise','fall'),edges):
rows.append(dict(zip(HEADER,[case,edge,'reported','0.003','0.000','5.000',
'0.000','4.940','0.002','0.001','0.000001','0.000010','0.0000105',
str((10+duration)*1e-6),str((10.5+duration)*1e-6)])))
return rows
def sheet(rows):
out=io.StringIO(newline='');w=csv.DictWriter(out,fieldnames=HEADER);w.writeheader();w.writerows(rows);return out.getvalue()
class ReductionTests(unittest.TestCase):
def test_all_eight_rows_support_conditional_pattern_not_acquisition(self):
result=d.analyze_rows(fixture());self.assertTrue(result['conditional_pattern_supported'])
self.assertFalse(result['physical_acquisition_verified'])
self.assertFalse(result['full_timing_uncertainty_verified'])
def test_wrong_orientation_pattern_not_forced_to_pass(self):
rows=fixture();rows[0]['second_lo_s']='.000150';rows[0]['second_hi_s']='.0001505'
self.assertFalse(d.analyze_rows(rows)['conditional_pattern_supported'])
def test_restoration_change_is_visible(self):
rows=fixture();rows[6]['second_lo_s']='.000050';rows[6]['second_hi_s']='.0000505'
self.assertFalse(d.analyze_rows(rows)['checks']['restoration'])
def test_open_control_asymmetry_is_visible(self):
rows=fixture();rows[4]['second_lo_s']='.000040';rows[4]['second_hi_s']='.0000405'
self.assertFalse(d.analyze_rows(rows)['checks']['open_symmetry'])
def test_input_initial_settling_and_source_spread_controls(self):
for key,value in [('off_out_v','.2'),('initial_error_v','.3'),('plateau_span_v','.2'),('input_edge_upper_s','.00001'),('in_high_v','5.20')]:
rows=fixture();rows[0][key]=value
with self.subTest(key=key):self.assertFalse(d.analyze_rows(rows)['conditional_pattern_supported'])
def test_duration_brackets_are_not_point_accuracy(self):
result=d.analyze_rows(fixture());br=result['rows'][0]['duration_sampling_bracket_s']
self.assertAlmostEqual(br[0],19.5e-6);self.assertAlmostEqual(br[1],20.5e-6)
def test_unresolved_sample_order_is_failed_screen(self):
rows=fixture();rows[0]['second_lo_s']='.000010';rows[0]['second_hi_s']='.0000105'
self.assertFalse(d.analyze_rows(rows)['conditional_pattern_supported'])
def test_missing_duplicate_reordered_mixed_origin_and_nonfinite_refused(self):
for kind in ('missing','duplicate','order','mixed','nan','blank','extra'):
rows=fixture()
if kind=='missing':rows.pop()
if kind=='duplicate':rows[1]=dict(rows[0])
if kind=='order':rows[0],rows[1]=rows[1],rows[0]
if kind=='mixed':rows[0]['source_kind']='constructed'
if kind=='nan':rows[0]['in_high_v']='nan'
if kind=='blank':rows[0]['off_out_v']=''
if kind=='extra':rows[0]['extra']='0'
with self.subTest(kind=kind):
with self.assertRaises(ValueError):d.analyze_rows(rows)
def test_reversed_bracket_refused(self):
rows=fixture();rows[0]['first_lo_s']='.000011'
with self.assertRaises(ValueError):d.analyze_rows(rows)
class CLITests(unittest.TestCase):
def cli(self,*args):
return subprocess.run([sys.executable,str(Path(d.__file__)),*args],capture_output=True,text=True)
def test_actual_good_and_failed_screen_exit_zero(self):
with tempfile.TemporaryDirectory() as td:
p=Path(td)/'x.csv';p.write_text(sheet(fixture()))
r=self.cli('check',str(p));self.assertEqual(r.returncode,0,r.stderr)
self.assertTrue(json.loads(r.stdout)['conditional_pattern_supported'])
rows=fixture();rows[0]['off_out_v']='.2';p.write_text(sheet(rows))
r=self.cli('check',str(p));self.assertEqual(r.returncode,0,r.stderr)
self.assertFalse(json.loads(r.stdout)['conditional_pattern_supported'])
def test_actual_malformed_and_blank_inputs_refused_without_json(self):
good=sheet(fixture())
variants=[b'"case,edge\n',b'"case"x,edge\n',b'\xff',b' '*65537,
good.replace('off_out_v','off_out_v,off_out_v',1).encode(),
good.replace('0.003','nan',1).encode(),
good.replace('0.003','',1).encode(),(good+'\n').encode()]
with tempfile.TemporaryDirectory() as td:
p=Path(td)/'x.csv'
for data in variants:
p.write_bytes(data);r=self.cli('check',str(p))
self.assertEqual(r.returncode,2,(data[:30],r.stderr));self.assertEqual(r.stdout,'')
self.assertNotIn('Traceback',r.stderr)
def test_actual_model_labels_and_parameter_refusal(self):
r=self.cli('model');self.assertEqual(r.returncode,0,r.stderr)
rows=list(csv.DictReader(io.StringIO(r.stdout)));self.assertEqual(len(rows),8)
self.assertEqual({r['source_kind']for r in rows},{'constructed'})
self.assertTrue(d.analyze_rows(rows)['conditional_pattern_supported'])
r=self.cli('model','--vf','nan');self.assertEqual(r.returncode,2);self.assertEqual(r.stdout,'')
def test_model_refinement_keeps_crossing_durations_within_one_sample(self):
a=d.model_rows('forward',substeps=5);b=d.model_rows('forward',substeps=10)
for x,y in zip(a,b):
tx=x['second_lo_s']-x['first_lo_s'];ty=y['second_lo_s']-y['first_lo_s']
self.assertAlmostEqual(tx,ty,delta=d.DT)
if __name__=='__main__':unittest.main()
Challenge: can a fast first half still have a slow finish?
The forward trace rises much faster through its 20–80% region than the open-control trace. Is it valid to assign the whole forward edge a single time constant based only on R1 parallel R2? What would reversing and then removing D1 tell you?
Reveal the answer
No. While D1 conducts, it adds a path with both a resistance and a current-dependent voltage drop. As OUT approaches IN, that path weakens and the 10 kΩ path finishes the tail. The actual diode drop is not a universal 0.7 V. Reversing D1 should move the faster region to the opposite edge; removing it should restore approximate direction symmetry. Returning the same diode to its original orientation checks that the comparison survived the intervention. Those observations support direction-dependent current steering under the recorded conditions, not a calibrated diode model or a debounce guarantee.
Primary references and related experiments
Primary documents were accessed on 29 November 2026. No separate current Vishay 1N4148 errata document was located in the bounded official search; recheck the current exact part documentation rather than treating that as universal absence.
- Vishay 1N4148, document 81857, revision 1.6, 7 November 2024: -TAP ordering, DO-35 cathode band and conditional ratings.
- WIMA FKP2 data, 03.26: nonpolar film/foil construction, 10 nF / 100 V body and tolerance options.
- Vishay MRS16 / MRS25 resistor data: resistance and power-rating conditions.
- Tektronix AFG1000 family specifications: 50 Ω typical output and load-display convention; sine-wave accuracy conditions are not applied as a square-wave guarantee here.
- AFG1022 quick-start manual, 077-1097-00 and AFG1000 safety instructions, 071-3434-00.
- TBS1000C user manual, 077-1571-00: probe compensation, acquisition, grounding, cursors and numeric waveform files.
- Current TPP0100 / TPP0101 probe specifications and TBS1000C specifications.
For a slower single-path comparison, see Watch a Capacitor Charge: Measure a 4.7-Second Time Constant. For a different diode behavior and a blank-fixture control, see Measure Diode Reverse Leakage Against an Empty Fixture. Neither related experiment supplies measured results for this circuit.
Download the reader ZIP and extract it first. It contains the complete article, original editable figures, program, tests and worksheets. Manufacturer PDFs remain linked to their publishers and are not redistributed.