Enter RPN

Files in r47/OpAmp/ of trunk
Login

Files in r47/OpAmp/ of trunk

Files in directory r47/OpAmp from the latest check-in of branch trunk


OpAmp Helpers

Usage

The provided Makefile calls on rejig to translate the plaintext program file into the P47 form. It then calls on the R47 simulator's T47 scripting language via the provided script to bind the following subroutines to a custom MyMenu. That assemblage can then be applied to your C47/R47 whole via the provided state file.

Subroutines

_INIT/OpAmp

An initialization routine that you can call by either name1 to set up default variable names, a desirable numeric display mode, etc.

RJnoise

Calculate the Johnson noise of a resistor Ri over a given bandwidth B1-B0, at a given temperature TK in Kelvin:

`R_j = sqrt(4 * k_B * T_K * (B_1-B_0) * R_i`

If you set the bandwidth to 1 — as by giving B1=2 and B0=1 — the result is in the V/√Hz unit commonly used with op-amp noise specs.

A useful fact we can learn from this is that a 1 kΩ resistor is approximately equal to 4 nV/√Hz, a common jellybean2 “low-noise” op-amp spec. Hence, using much larger resistors around such an op-amp wastes its capability.

VOS

Compute the output voltage offset of an op-amp given these datasheet specs…

…plus the resistances around the op-amp…

This reports the expected output offset voltage as:

`V_(OS)=(R_f/R_g+1)*(V_(IO)+abs([I_(IB)(R_(pf)-R_i)]-[I_(IO)/2(R_(pf)+R_i)]])`

The first term is simply the op-amp’s gain, which magnifies both VIO plus the current-based effects3 calculated by the big absolute-valued term. Rpf is the parallel resistance of the feedback resistors, calculated separately because it’s used twice.

GNI

Front end for the included “Gain” program to set the operating mode flag (01) that causes it to calculate the gain of an op-amp in the non-inverting configuration given the feedback resistor value Rf and the resistor from there to ground, Rg.

GINV

Same idea, but for the inverting configuration.

||R

Compute parallel resistance for the simple 2-resistor DC case. The R47 includes the similarly-named || function under its ELEC menu, but it takes complex numbers to include phase, and it produces a complex impedance result. This version is technically a subset of that functionality which ends up more useful when you do not care about reactance, phase, etc. (This function is used internally by the suite — in the VOS routine above — making it “free” to end users.)

Rdiv

Calculate the output voltage from a resistor divider given the input voltage Vi, the “input” resistor value Ri and the “ground” resistor Rg.

License

This work is © 2026 by Warren Young and is licensed under CC BY-NC-SA 4.0


  1. ^ It has two names because I want to call this subroutine from our example MyMenu as _INIT but save the program suite from the simulator as OpAmp.p47, where the basename comes from the label you select on WRITEP. If I cater only to the second wish, the 🟦 F6 menu item gets called OpAmp, which doesn’t describe what it does.
  2. ^ Slang for a component bought in bulk bags and consumed by the handful without a lot of up-front discretion over which “flavor” each one has.
  3. ^ That part of the equation comes from Design with Operational Amplifiers and Analog Integrated Circuits 3rd edition by Sergio Franco. It is the modified form of equation 5.11 on page 219, reworked using this program’s symbols.