Integrated circuits · 5 V analog experiment
A buffer can follow a small sine wave and distort a larger wave at exactly the same frequency. Keep the circuit, offset and load fixed, change only amplitude, and compare the voltage slope the output must produce.
Verification scope: This is a complete proposed bench experiment with a tested offline analysis program. The plots and supplied captures are calculated or synthetic, meaning constructed from equations. They are not measurements of an LM358B. No circuit was assembled, oscilloscope operated or target firmware built or run for this package.
An operational amplifier, or op amp, changes its output in response to the voltage difference between two inputs. Negative feedback returns the output to the inverting, minus-marked input so the amplifier corrects that difference. Connecting the output directly to that input makes a voltage follower: its intended voltage gain, output change divided by input change, is one. This is also called unity gain.
Bandwidth describes how the response changes with frequency when the signal is small enough for approximately linear operation. Slew rate describes a large-signal limit on how quickly output voltage can change, expressed here in volts per microsecond (V/µs). One microsecond is one millionth of a second. A sine wave becomes steeper when either its frequency or amplitude increases. A frequency rating by itself therefore does not promise the same response at every amplitude.
Use the exact Texas Instruments (TI) LM358BIDR integrated circuit (IC), a chip containing two amplifier channels. The D package is an eight-pin small-outline integrated circuit (SOIC), a surface-mount package, on a passive adapter with 1.27 mm pad spacing. Follow the chip’s pin-1 mark and its top-view drawing; the adapter must expose the numbered pins without added circuitry. The B suffix matters. The older LM358 has different typical speed, and its name is not permission to substitute its specifications.
The current TI data sheet SLOS068AB, revised October 2024 gives the B part a 3–36 V recommended supply range, a conservative input range from the lower supply to 2 V below the upper supply, and typical values of 1.2 megahertz (MHz, million cycles per second) gain-bandwidth product and 0.5 V/µs slew rate. The gain-bandwidth product is the frequency scale used for approximate amplifier-bandwidth calculations. Its 40 V absolute supply maximum is a stress boundary, not an operating target. TI application note SLOA277B, section 4.1 explicitly identifies the speed figures as typical and not production-tested. They are references for this experiment, not guaranteed limits for your individual chip.
Use a regulated 5.00 V supply with a 20 mA current limit; one LM358BIDR and adapter; a 1.00 kΩ resistor; a 47 Ω resistor; three 10.0 kΩ resistors; a 100 nF ceramic capacitor; and a 10 µF polarized capacitor rated for at least 10 V. Resistors rated at least 0.125 W are sufficient here. The 100 nF capacitor supplies local rapid current changes; the larger capacitor supports the nearby supply wiring. A bypass capacitor is this local connection between supply and ground, not a capacitor inserted in the signal path.
A signal generator must provide a sine wave with adjustable amplitude and a 2.000 V direct-current (DC) offset, the fixed level about which the sine moves. Use a two-channel oscilloscope, an instrument that displays voltage against time, with at least 20 MHz analog bandwidth and an actual sample rate of at least 20 million samples per second in the chosen two-channel mode. Use compensated 10× probes with 10 MΩ input resistance and no more than 20 pF input capacitance. A 10× probe attenuates the signal tenfold; the scope’s probe factor must match so displayed volts are correct. Compensation adjusts the probe’s response to the scope input. A low-voltage meter is useful for checking the supply and midpoint.
Set both scope inputs to high impedance, their normal voltage-measurement mode, with DC coupling so the offset remains visible. A 50 Ω termination would heavily load this circuit. Confirm the generator’s high-impedance amplitude display setting, or verify the actual voltage with channel 1 before connecting the amplifier. A generator configured to display voltage into 50 Ω can deliver approximately twice that displayed amplitude into a high-impedance input. The measured pin-3 waveform is the experiment’s input, whatever the front panel says.
Ground is the common voltage reference and return path, labelled G0. The chip’s V+ symbol means its positive supply; V− means its lower supply, which is G0 here. Channel 1 and channel 2 of the scope are abbreviated CH1 and CH2 in the schematic. All +5V labels represent the same supply net, a set of electrically connected points. All G0 labels represent the same return net.
| Connection | Exact endpoints and purpose |
|---|---|
| Supply | Pin 8 V+ → +5V; pin 4 V− → G0. C1, 100 nF, goes directly across pins 8 and 4 close to the IC. C2, 10 µF, goes across the same rails, positive terminal to +5V and negative terminal to G0. |
| Input | Generator signal → R1, 1.00 kΩ → pin 3 IN1+, the non-inverting input. Generator return → G0. CH1 tip → pin 3, after R1. |
| Feedback | Pin 1 OUT1 → pin 2 IN1− directly with a short wire. The inverting input is the feedback input; it is not connected to ground. |
| Load and output probe | R3, 10.0 kΩ, from pin 1 OUT1 to G0. Pin 1 → R2, 47 Ω → CH2 tip. Feedback and R3 stay on the pin-1 side of R2. Both probe ground clips → G0. |
| Second channel | +5V → R4, 10.0 kΩ → MID → R5, 10.0 kΩ → G0. MID → pin 5 IN2+. Pin 7 OUT2 → pin 6 IN2− directly. Do not leave either unused input floating; pin 7 drives only its own feedback connection. |

R1 limits accidental input current and gives a defined source resistance; it does not make arbitrary input voltages safe. R2 separates the output from the probe’s small capacitive load; CH2 observes the voltage after it. With 20 pF, its simple resistance–capacitance time constant, a measure of the response time, is 47 Ω × 20 pF = 0.94 nanoseconds (ns, billionths of a second). The same estimate for R1 and the CH1 probe is 20 ns. Neither is a chip-speed specification, and the channel-1 measurement already includes source-side loading. Short wiring and correctly compensated probes still matter.
At the intended 1.5–2.5 V output, R3 draws 150–250 µA toward G0. Even the ideal 1 V peak-to-peak, 300 kHz sine needs only about 19 µA to charge 20 pF at its steepest point. The resistive current therefore keeps the intended output sourcing, meaning delivering current, rather than repeatedly reversing its current direction. This reduces output crossover distortion, an error when the driver changes between delivering and absorbing output current, as a competing explanation. It does not remove bandwidth, probe or wiring effects. TI discusses crossover and load termination in SLOA277B, sections 4.3–4.5.
Peak-to-peak voltage, Vpp, is the difference between a waveform’s highest and lowest voltages. For a sine, its peak amplitude A is half Vpp. Frequency f, in hertz (Hz), counts cycles per second. For an intended sine v(t) = Voffset + A sin(2πft), its largest voltage slope is:
Srequired = 2πfA = πfVpp.
This result follows by differentiating the sine: its slope is 2πfA cos(2πft), whose largest magnitude occurs as the sine crosses its offset. Divide volts per second by 1,000,000 to express volts per microsecond. The offset does not appear in the derivative, but it remains essential for input and output headroom, the room before a permitted voltage boundary.
| Frequency | 0.100 Vpp demand | 1.000 Vpp demand |
|---|---|---|
| 10 kHz | 0.00314 V/µs | 0.03142 V/µs |
| 100 kHz | 0.03142 V/µs | 0.31416 V/µs |
| 300 kHz | 0.09425 V/µs | 0.94248 V/µs |
The two 300 kHz inputs have the same frequency but tenfold different slope requirements. Comparing the larger requirement with the 0.5 V/µs typical reference motivates looking for amplitude-dependent distortion. Solving f = S/(πVpp) with that reference gives about 159 kHz for 1 Vpp and 1.59 MHz for 0.1 Vpp. Those are calculated intersections, not guaranteed clean-sine frequencies. A signal well below a typical slew-rate reference may still distort for other reasons.
For comparison, a deliberately simple continuous one-pole low-pass approximation with a 1.2 MHz corner gives gain 1/√(1 + (f/fc)²) ≈ 0.970 and phase −arctan(f/fc) ≈ −14.0° at 300 kHz. A pole here means one first-order response term; phase describes where one sine’s cycle sits relative to the other. This approximation describes an amplitude-independent response. It is not the full LM358B transfer function, and it does not include slew limiting.

t_s,vin_v,vout_v: time in seconds, measured CH1 volts, measured CH2 volts. Include the probe scale once, not twice. Preserve the raw export separately. Fill the blank observation sheet with your actual results.Compare both amplitudes at each frequency. An output slope that grows with demand is not yet limited. A more triangular output, rising and falling slope magnitudes that stop growing, amplitude loss and a larger sine-fit residual can be consistent with rate limiting. Check the input first: a distorted generator signal cannot establish an amplifier limit. Flat plateaus near a voltage boundary suggest clipping, a different mechanism. Ringing or unexpected oscillation calls for a wiring, probe and capacitive-load investigation. Return to the small signal and lower frequency as a control.
Use Python 3.9 or later; the delivered host checks ran with Python 3.9.6. No added library is required. Extract the reader contents and reproduction instructions so the files keep their relative paths. The complete program below is also code/slew_capture.py. Run it from the extracted package directory:
python3 code/slew_capture.py analyze your-capture.csv --frequency-hz 300000
python3 -m unittest discover -s code -p 'test_*.py'
python3 code/slew_capture.py demo generated-demo
python3 code/slew_capture.py analyze generated-demo/synthetic-large-300khz.csv --frequency-hz 300000
A fundamental is the sine component at the stated input frequency. The program uses a least-squares fit, choosing a constant offset plus sine and cosine terms that minimize the sum of squared errors. It reports fundamental gain and relative phase, plus the root-mean-square (RMS) residual: square the fit errors, average them, then take the square root. The residual ratio divides that value by the fitted fundamental’s RMS amplitude. It includes noise, harmonics, a wrong stated frequency and other errors. It is not a standardized total-harmonic-distortion measurement.
The slope results use every signed adjacent-sample difference, (next voltage − previous voltage)/(next time − previous time), converted to V/µs. p95 is the 95th percentile of that entire signed set: 95% of slopes are at or below it. p05 is its fifth percentile, normally negative for this sine. They are not percentiles calculated separately from positive-only and negative-only samples. Noise and finite sample spacing affect them; even a perfect sine’s p95 is slightly below its true peak slope. Neither number automatically certifies device slew rate.
The loader rejects wrong headers or cells, nonfinite numbers, fewer than 200 samples, non-increasing timestamps, sample intervals differing by more than 1%, fewer than 40 samples per stated cycle, and records shorter than eight cycles. It also rejects voltage magnitudes above ±10 V as a parser sanity bound for this 5 V fixture; that software bound is not a safe hardware-input rating. A tiny input fundamental is refused. Less extreme departures from the intended input/output range produce warnings. Inspect warnings and the traces rather than treating a successfully parsed file as a valid experiment.
#!/usr/bin/env python3
"""Analyze a two-channel sine capture or generate explicitly synthetic teaching data.
Python 3.9+, standard library only. CSV columns: t_s,vin_v,vout_v.
No hardware control, automatic chip characterization or physical-test claim.
"""
import argparse
import csv
import json
import math
from pathlib import Path
import statistics
import sys
def positive(value, name):
if not math.isfinite(value) or value <= 0:
raise ValueError(name + ' must be finite and positive')
return value
def required_slope(frequency_hz, vpp):
"""Peak derivative of an ideal sine, in volts per microsecond."""
return math.pi * positive(frequency_hz, 'frequency') * positive(vpp, 'vpp') / 1e6
def solve3(matrix, vector):
"""Solve the three fit normal equations with partial-pivot elimination."""
a=[list(row)+[rhs] for row,rhs in zip(matrix,vector)]
for col in range(3):
pivot=max(range(col,3),key=lambda row:abs(a[row][col]))
if abs(a[pivot][col]) < 1e-12:
raise ValueError('Singular sine fit; check frequency and sample record')
a[col],a[pivot]=a[pivot],a[col]
scale=a[col][col]
a[col]=[x/scale for x in a[col]]
for row in range(3):
if row != col:
scale=a[row][col]
a[row]=[x-scale*y for x,y in zip(a[row],a[col])]
return [a[i][3] for i in range(3)]
def fit(times, values, frequency_hz):
basis=[(1.0, math.sin(2*math.pi*frequency_hz*t),
math.cos(2*math.pi*frequency_hz*t)) for t in times]
matrix=[[math.fsum(row[i]*row[j] for row in basis) for j in range(3)] for i in range(3)]
vector=[math.fsum(row[i]*v for row,v in zip(basis,values)) for i in range(3)]
dc,sine,cosine=solve3(matrix,vector)
amplitude=math.hypot(sine,cosine)
residual=math.sqrt(math.fsum((v-dc-sine*row[1]-cosine*row[2])**2 for row,v in zip(basis,values))/len(values))
return dc,amplitude,math.atan2(cosine,sine),residual
def percentile(values, fraction):
ordered=sorted(values)
index=(len(ordered)-1)*fraction
low=math.floor(index);high=math.ceil(index)
return ordered[low]+(ordered[high]-ordered[low])*(index-low)
def read_capture(stream):
reader=csv.reader(stream)
if next(reader,None) != ['t_s','vin_v','vout_v']:
raise ValueError('CSV header must be exactly t_s,vin_v,vout_v (seconds, volts, volts)')
rows=[]
for number,row in enumerate(reader,2):
if len(row) != 3:
raise ValueError('CSV row '+str(number)+' must have exactly three cells')
try:
rows.append(tuple(float(x) for x in row))
except ValueError:
raise ValueError('CSV row '+str(number)+' contains a nonnumeric cell') from None
return rows
def analyze(rows, frequency_hz):
"""Return conditional metrics, without declaring a chip slew-rate specification."""
positive(frequency_hz,'frequency')
if len(rows) < 200:
raise ValueError('At least 200 samples are required')
if any(len(row)!=3 or any(not math.isfinite(x) for x in row) for row in rows):
raise ValueError('Every row needs three finite numbers')
if any(abs(value)>10 for row in rows for value in row[1:]):
raise ValueError('Capture voltage exceeds the +/-10 V parser sanity bound for this 5 V fixture; check units and probe factors')
# Subtract the first timestamp to keep trigonometric arguments well scaled.
times=[row[0]-rows[0][0] for row in rows]
vin=[row[1] for row in rows];vout=[row[2] for row in rows]
steps=[b-a for a,b in zip(times,times[1:])]
if min(steps) <= 0:
raise ValueError('Timestamps must be strictly increasing')
dt=statistics.median(steps)
if any(abs(step-dt)>max(1e-12,.01*dt) for step in steps):
raise ValueError('Timestamps must be uniform to within 1 percent')
if 1/dt/frequency_hz < 40-1e-9:
raise ValueError('At least 40 samples per stated sine cycle are required')
if times[-1]*frequency_hz < 8-1e-9:
raise ValueError('Record must span at least eight cycles at the stated frequency')
xi=fit(times,vin,frequency_hz);yo=fit(times,vout,frequency_hz)
if xi[1] < 1e-6:
raise ValueError('Input fundamental is too small to compare')
phase=(math.degrees(yo[2]-xi[2])+180)%360-180
slopes=[(b-a)/step/1e6 for a,b,step in zip(vout,vout[1:],steps)]
warnings=[]
if min(vin)<1.5-1e-9 or max(vin)>2.5+1e-9:
warnings.append('Input leaves the intended 1.5..2.5 V experiment range.')
if min(vout)<1.0 or max(vout)>3.0:
warnings.append('Output leaves the intended interior headroom check range.')
if xi[3] > xi[1]/math.sqrt(2)*.02:
warnings.append('Input fit residual exceeds 2 percent; inspect the source waveform or stated frequency.')
if yo[1] < 1e-6:
warnings.append('Output fundamental is tiny; phase and residual ratio are ill-conditioned.')
return {'sample_count':len(rows),'sample_rate_hz':1/dt,
'frequency_hz':frequency_hz,'record_span_cycles':times[-1]*frequency_hz,
'input_offset_v':xi[0],'input_fundamental_vpp':2*xi[1],
'output_offset_v':yo[0],'output_fundamental_vpp':2*yo[1],
'fundamental_gain':yo[1]/xi[1],'phase_deg':phase,
'input_fit_residual_rms_v':xi[3],'output_fit_residual_rms_v':yo[3],
'output_fit_residual_ratio':yo[3]/(yo[1]/math.sqrt(2)) if yo[1]>=1e-6 else None,
'ideal_input_sine_peak_slope_v_per_us':required_slope(frequency_hz,2*xi[1]),
'output_slope_p95_v_per_us':percentile(slopes,.95),
'output_slope_p05_v_per_us':percentile(slopes,.05),
'warnings':warnings,
'interpretation':'Fit residual includes noise, harmonics, frequency mismatch and other error. Finite-difference slope is not a certified device slew rate.'}
def synthesize(vpp=.1, frequency_hz=300000.0, sample_rate_hz=20000000.0,
bandwidth_hz=1200000.0, slew_v_per_us=.5):
"""Constructed one-pole/rate-limiter lesson model, NOT an LM358B macromodel.
At every sample, move toward the input using a one-pole discrete update,
then limit that change in both directions. Settle for 20 cycles first.
The model excludes offset, crossover, load, rail clipping, noise and wiring.
"""
for name,value in [('vpp',vpp),('frequency',frequency_hz),('sample rate',sample_rate_hz),
('bandwidth',bandwidth_hz),('slew',slew_v_per_us)]:
positive(value,name)
dt=1/sample_rate_hz
alpha=1-math.exp(-2*math.pi*bandwidth_hz*dt)
maximum_step=slew_v_per_us*1e6*dt
warm=math.ceil(20*sample_rate_hz/frequency_hz)
count=math.ceil(10*sample_rate_hz/frequency_hz)+1
output=2.0;rows=[]
for i in range(-warm,count):
t=i*dt;input_v=2+vpp/2*math.sin(2*math.pi*frequency_hz*t)
step=alpha*(input_v-output)
output+=max(-maximum_step,min(maximum_step,step))
if i>=0:
rows.append((t,input_v,output))
return rows
def main():
parser=argparse.ArgumentParser(description=__doc__)
sub=parser.add_subparsers(dest='command',required=True)
analyze_parser=sub.add_parser('analyze',help='analyze an actual or explicitly synthetic CSV')
analyze_parser.add_argument('csv_path',type=Path)
analyze_parser.add_argument('--frequency-hz',type=float,required=True)
demo=sub.add_parser('demo',help='write constructed model data; never physical measurements')
demo.add_argument('output_directory',type=Path)
args=parser.parse_args()
try:
if args.command=='analyze':
with args.csv_path.open(newline='')as stream:
result=analyze(read_capture(stream),args.frequency_hz)
print(json.dumps(result,indent=2,allow_nan=False))
else:
args.output_directory.mkdir(parents=True,exist_ok=True)
names=['synthetic-small-300khz.csv','synthetic-large-300khz.csv']
paths=[args.output_directory/name for name in names]
if any(path.exists()for path in paths):
raise ValueError('Demo refuses to overwrite existing captures')
for path,vpp in zip(paths,[.1,1.0]):
with path.open('w',newline='')as stream:
writer=csv.writer(stream,lineterminator='\n')
writer.writerow(['t_s','vin_v','vout_v'])
writer.writerows(synthesize(vpp=vpp))
print('Wrote synthetic teaching model files only: '+', '.join(names))
except (ValueError,OSError)as exc:
parser.exit(2,'Capture refused: '+str(exc)+'\n')
return 0
if __name__=='__main__':
raise SystemExit(main())
The supplied small and large synthetic captures were generated at 20 MS/s. Their model moves a stored output toward the input with the discrete update α = 1 − exp(−2πfcΔt), then limits each voltage increment to ±SΔt. Here Δt is the sample interval, 50 ns at 20 MS/s; fc = 1.2 MHz and S = 0.5 V/µs. It settles for 20 cycles and saves ten cycles. This is an intentionally simple numerical teaching rule, excluding chip offset, crossover, load dependence, rail clipping, noise and wiring. It is not TI’s device simulation model.
For these exact supplied files, the small-signal fundamental gain is about 0.970, phase about −11.5° and fit residual close to numerical zero. The large case has a lower gain and a larger residual, while its p95/p05 slopes reach the imposed ±0.5 V/µs rule. The discrete model’s phase differs from the continuous one-pole estimate of −14.0° because its finite-step update uses the current input sample. That difference is a model limitation, not a measured amplifier result. Read the complete generated summaries in small-analysis and large-analysis.
The 19 supplied host tests exercise known gain, phase, offset, harmonic residual, slope signs and units, timestamp and sampling failures, real command-line parsing, finite huge-cell refusal and actual model amplitude/rate-limit changes. They verify this code’s behavior. They do not verify an assembled circuit, an instrument’s calibration or a hardware performance guarantee.
Challenge: At 200 kHz, a nominal 0.5 V/µs rate reference permits what calculated peak-to-peak sine amplitude? If your 0.100 Vpp capture looks clean there, does that establish that 1.000 Vpp will also be clean?
Vpp = S/(πf) = 500,000/(π × 200,000) ≈ 0.796 Vpp. This is the intersection with a typical reference, not a guaranteed distortion threshold. The 0.100 Vpp sine requires about 0.0628 V/µs; the 1.000 Vpp sine requires about 0.628 V/µs, ten times more. A good small capture does not establish large-signal behavior. Repeat the larger capture with the same valid offset and load, then inspect the source, headroom, output slopes and residual.
TI’s exact LM358BIDR orderable record identifies the D eight-pin package. SLOS068AB sections 4, 5.1, 5.3, 5.5, 8.3 and 8.4 support the pinout, voltage conditions, typical speed and supply/layout decisions. SLOA277B sections 4.1–4.5 explain typical speed variation and crossover. The current product technical-document list was checked on December 3, 2026; no standalone silicon errata was linked there. That search observation is not proof that no errata exists; check for later manufacturer updates before building.
Continue with Tricky Circuit Learn and Circuitpedia for supporting terminology. Proposed dictionary terms in this package are candidates for coordinated translation, not claims of a live dictionary update. This article’s source and host checks are local preparation; independent review, browser delivery, hardware measurements and publication are separate gates.