Programming an Analog Computer

Analogue computers have a special place in computing history. They don’t work the same way as digital computers. They aren’t programmable in the usual sense; instead, they are reconfigurable. Instead of building a fixed-function, general-purpose CPU and memory system and implementing the application in software, analogue computers are an analogue of the system they are simulating. This means they are somewhat limited in the types of problems they can solve, but for compatible problems, they are the perfect tool. Analogue computers originally were mechanical devices, and whole books have been written about them. But the more interesting (to me) kind are reconfigurable electronic simulators, programmed by wiring together fixed-function electronic building blocks such as integrators, summers, amplifiers, and related circuits.

The idea is to model the dynamics of a problem, for example, a car suspension system, write down the system equations that model the motion, then map those functions into electronic building blocks. Next, set initial conditions and run the model, watching the simulated variables trace a response on an oscilloscope or plotter. Then you have your answer. Tweak the conditions or parameters, then run again and again until you tune your system to perfection.

An EAI PACE TR-48 Analog Computer built in 1961

The TR-48 unit is so named because it contains 48 transistor-based operational amplifiers. It was intended to support applications in satellite and aerospace, chemical plants, control and power systems, and education and research.

The TR-48 does not actually have dedicated summers or integrator blocks, as my vague introduction implied; these 48 opamps are actually uncommitted, and can be configured into any desired operating mode at ‘programming’ time. This makes this device very flexible.

Construction

The TR-48 consists of 12 modules. Each module has five basic positions. Every module has two dual opamps and either one or two dedicated integrators. The integrator slots can be changed to swap in other nonlinear functions, such as comparators, multiplication, and ‘diode’ functions like log x and x2. Some slots also have ‘trunk’ input and output blocks and connect to the readout panel. The fifth slot hosts the connections to the potentiometer group for setting coefficients or other parameters. The potentiometer group contains five multi-turn potentiometers to improve accuracy. The potentiometers are the main interface to the device, used to set operating parameters, initial conditions, and other input variables for the system.

The machine’s patching area is removable, a common feature of these larger computers, to reduce labour-intensive patching. These ‘program boards’ can be stored until needed, enabling quick, easy switching between configurations for different use cases. This matters in a shared laboratory context, as the cost of the expensive machine may not justify individual projects or users.

Configuration

The machine is very flexible, with two slots in each group that can accept one of the alternative function modules. Changes like this obviously require coordination among the various users and projects that use the machine, but once a standard configuration is established, it should be straightforward to design around it. To swap a module out, remove the pre-patch panel from the machine (including its patching cables), then undo a couple of screws and slide the module out. The new module slides in place and is screwed down. Next, replace the matching part of the pre-patch panel to match the module. This ensures the correct signal configuration and matches the front-panel labelling to the actual connectivity.

The DFG (Diode Function Generator) modules can synthesise configurable transfer functions using a linear piecewise-approximation method. A series of potentiometers on the slide-out shelves behind the control panel sets the function’s breakpoints and slopes.

That configures the machine, but you can only do the second part of the configuration once you’ve mapped the problem into blocks and started patching. I will elaborate on that after we learn how to program this thing.

Programming

To program an analogue computer like this, you need a different mindset. Firstly, you need a mathematical model of your target simulation. This will likely be a system of differential equations. The first step in implementing these is to rewrite them as a set of first-order equations through a bit of mathematical manipulation. Next, select scaling factors that make sense for the variable and ensure it fits within the machine’s operating voltage range. Once you’ve rewritten all the equations and calculated the scaling factors for the coefficients, you can start to map the equations onto the amplifiers, configuring them as integrators where needed.

This is a critical point: analogue computers are nearly always integrating machines because the derivative operation quickly amplifies noise and can cause the simulation to ‘blow up.’ Shifting your mindset to view the problem as a set of linked integrations helps average out noise and keep the simulation within the operating voltage range.

Let’s illustrate this process with a non-trivial example: a damped, spring-coupled two-mass system.

x1 displacement of mass 1
x2 displacement of mass 2
m1, m2 masses
k1..3 spring constants
c1…3 damping factors
F1(t), F2(t) external forces

1. Build the model

The force-balance equation for m1 contains the sum of the forces acting upon it: the external force, the force due to spring k1 and damper c1, and finally the component forces from k2 and c2, which depend on the relative positions (x1-x2) and relative velocities (dx1/dt – dx2/dt). Using Newton’s second law of motion (F=ma), we equate this to the product of mass and acceleration. The equation for m2 is similar.

\begin{aligned} m_1 \ddot{x}_1 = F_1 - k_1 x_1 - c_1 \dot{x}_1 - k_2 (x_1 - x_2) - c_2 (\dot{x}_1 - \dot{x}_2)\\ m_2 \ddot{x}_2 = F_2 - k_3 x_2 - c_3 \dot{x}_2 - k_2 (x_2 - x_1) - c_2 (\dot{x}_2 - \dot{x}_1) \end{aligned}

2. Express as first-order systems

Next, we need to expand the expression and gather the state variables:

\begin{aligned} m_1 \ddot{x}_1 = F_1 - (k_1 + k_2) x_1 + k_2 x_2 - (c_1 + c_2) \dot{x}_1 + c_2 \dot{x}_2\\ m_2 \ddot{x}_2 = F_2 + k_2 x_1 - (k_2 + k_3) x_2 + c_2 \dot{x}_1 - (c_2 + c_3) \dot{x}_2 \end{aligned}

Now we have two equations with isolated factors for the variables x1, x2, and their derivatives; we can make a state-variable substitution. This is the critical step for expressing this problem in first-order terms. In short, if we have some terms that are second order or above, we substitute them for something else, like this:

\begin{aligned} y_1 = x_1\\ y_2 = \dot{x}_1\\ y_3 = x_2\\ y_4 = \dot{x}_2 \end{aligned}

Now, to complete the substitution for x1 and x2, the system is expressed purely in y terms:

\begin{array}{rcl} \dot{y}_1 & = & y_2\\ \dot{y}_2 & = & \frac{1}{m_1}[F_1 - (k_1+k_2)y_1 - (c_1+c_2) y_2 + k_2 y_3 + c_2 y_4]\\ \dot{y}_3 & = & y_4\\ \dot{y}_4 & = & \frac{1}{m_2}[F_2 + k_2 y_1 + c_2 y_2 - (k_2+k_3)y_3 -(c_2+c_3) y_4] \end{array}

It is now clear that to obtain y1, we need to integrate y2; to find y2, we integrate dy2/dt. Similarly, to find y3, we integrate y4; to find y4, we integrate dy4/dt. i.e. we just integrate both sides of all equations above. We now know our configuration requires four integrator stages, and we can move on to the next stage: scaling.

3. Determine State Variable Scaling

All voltages within the TR-48 must remain within ±10 V, ideally below ±8 V to allow some margin and prevent clipping, which would be disastrous. Let’s pick some sensible initial values for the simulation’s configurable elements and check the ranges of the system variables.

m1 = 1 kg; m2 = 0.5 kg
k1 = 6 N/m; k2 = 5 N/m; k3 = 10 N/m
c1 = 0.9 Ns/m; c2 = 0.3 Ns/m; c3 = 0.4 Ns/m

This gives the following fully determined system:

\begin{array}{rcl} \dot{y}_1 & = & y_2\\ \dot{y}_2 & = & F_1 - 11 y_1 - 1.2 y_2 + 5 y_3 + 0.3 y_4\\ \dot{y}_3 & = & y_4\\ \dot{y}_4 & = & 2 F_2 + 10 y_1 + 0.6 y_2 - 30 y_3 - 1.4 y_4 \end{array}

Currently, the units of the system variables (displacement, velocity, and acceleration) are 1 V/m, 1 Vs/m, and 1 Vs/m^2. First, check for large coefficient values; 10, 11, and 30 are a bit too large to leave as is, because reasonable values may be clipped. We need to set limits on the simulation ranges of these variables and determine scaling factors that map the physical parameters to simulation voltages.

Setting limits for the displacement at ± 0.1 m, velocity at ± 1 m/s and acceleration at ± 10 m/s2. This gives scale factors for displacement at 100 V = 1 m, velocity at 10 V = 10 m/s and acceleration at 1 V = 1 m/s2. Now we need to define some scaled system variables:

\begin{array}{rcl} X_1 & = & 100 x_1\\ X_2 & = & 100 x_2\\ V_1 & = & \dot{x}_1\\ V_2 & = & \dot{x}_2\\ A_1 & = & \ddot{x}_1\\ A_2 & = & \ddot{x}_2 \end{array}

The physical units are now scaled into volts.

Our corresponding state variable scaling looks like this:

\begin{array}{rcl} Y_1 & = & 100 y_1\\ Y_2 & = & y_2\\ Y_3 & = & 100 y_3\\ Y_4 & = & y_4 \end{array}

Finally, we rewrite the system as its scaled version:

\begin{array}{rcl} V_1 & = & Y_2\\ A_1 & = & F_1 - 0.11 Y_1 - 1.2 Y_2 + 0.05 Y_3 + 0.3 Y_4\\ V_2 & = & Y_4\\ A_2 & = & 2 F_2 + 0.1 Y_1 + 0.6 Y_2 - 0.3 Y_3 - 1.4 Y_4 \end{array}

This now shows a couple of problems: the coefficients 1.2Y2 and 1.5Y4 still exceed unity, so we need to scale again. These coefficients relate to the masses’ velocities, so we can divide them down and set the velocity scale factor to 10 V = 1 m/s. Now the new system looks like this:

\begin{array}{rcl} V_1 & = & Y_2\\ A_1 & = & F_1 - 0.11 Y_1 - 0.12 Y_2 + 0.05 Y_3 + 0.03 Y_4\\ V_2 & = & Y_4\\ A_2 & = & 2 F_2 + 0.1 Y_1 + 0.06 Y_2 - 0.3 Y_3 - 0.14 Y_4 \end{array}

Note: We haven’t yet considered scaling external force inputs, but we can address that when designing the simulation input stimulus.

4. Integration Scaling

Next, we consider integration scaling. Let me illustrate this by revisiting the relationship between the state variables and the scaled versions we’re actually going to program:

Y_1 = 100 y_1, Y_2 = 10 y_2\\ \text{therefore:}\\ \begin{array}{rcl} \dot{Y}_1 & = & 10 Y_2\\ \dot{Y}_3 & = & 10 Y_4\\ \dot{Y}_2 & = & 10 A_1\\ \dot{Y}_4 & = & 10 A_2 \end{array}

This is a little unhelpful, as it requires a 10x-gain stage before each integrator to satisfy the scaling. We can avoid this by scaling the machine’s local notion of time instead. As you might guess, we make another substitution, this time in the time domain:

\tau = 10t

Now, we have two notions of time, physical time (t) and machine time (τ), which doesn’t really matter, except that it’s another thing to track. Essentially, the machine is simulating at 10 times the real system’s speed to avoid overloading the integrators. To implement it physically, you would set the machine timescale with the vernier knob on the control section. Other machines may simply swap out physical capacitors, but the TR-48 is more sophisticated.

Since we changed the integration scale, we need to update our simulation equations accordingly. We do this by applying the chain rule for differentiation, like this:

\frac{dY_1}{d\tau} = \frac{dY_1}{dt} \cdot \frac{dt}{d\tau}\\[10pt] \text{because:}\\[10pt] \tau = 10t\\[10pt] \text{then:}\\[10pt] \frac{d\tau}{dt} = 10\\[10pt] \text{therefore:}\\[10pt] \frac{dY_1}{d\tau} = \frac{1}{10} \frac{dY_1}{dt}\\[10pt] \text{we already know:}\\[10pt] \frac{dY_1}{dt} = 10 Y_2\\[10pt] \text{so:}\\[10pt] \frac{dY_1}{d\tau} = \frac{1}{10} 10 Y_2 = Y_2

5. Hardware Mapping

Now, we can use a simple integrator to derive Y1 as the integral of Y2, similarly for Y3 and Y4. The symbolic flow looks like this:

A_1 \rightarrow \int d\tau \rightarrow Y_2 \rightarrow \int d\tau \rightarrow Y_1\\ A_2 \rightarrow \int d\tau \rightarrow Y_4 \rightarrow \int d\tau \rightarrow Y_3

Initially, the problem began by measuring the masses’ positions and calculating their associated velocities and accelerations. We then translated it into an analogue computer-friendly integral problem. We start with the forces on the masses, which are proportional to the accelerations, then integrate once to get the velocities, and then again to get the positions. This is typical of an analogue computer problem implementation.

The simulation model looks like this. This is a generic analogue computer layout; implementing it on the TR-48 requires a few more considerations, but this diagram shows which blocks are needed, the patching, and the coefficients to set.

The theoretical analogue computer realisation of the two-mass system

The five-input summer blocks cannot be implemented directly by a single adder. Each module has two summing amplifiers, but each one has only four usable summing inputs when the feedback ‘bottle plug’ is fitted. Two are x1 gain, and two are x10, so you also need to account for that. If you were pressed for input, you could scale the coefficients by 10 and use a 10x input. Also, the amplifier is inverting, so simply cascading one amplifier into the next needs a little thought. The TR-48 coefficients are simple resistor dividers, so to mix signed inputs into any one amplifier, it is common to use spare inverting amplifiers to provide inverted copies of the necessary state variables. Grouping like-sign inputs into separate amplifiers helps maintain control of the overall sign of the sum.

Integrators can’t be used on their own, as they are tied to the neighbouring amplifier slot. To enable an integrator, insert the T-shaped ‘bottle plug’ between the two slots. This connects the integrator into the neighbouring amplifier’s feedback path. However, since the bottle plug only ties up the feedback input, it frees an additional x1 input, making the integrator a five-input summing integrator, albeit with an inverted output. It’s quite common to see three chained integrators in a typical 2nd-order system, so the output signs alternate. As long as you compensate by either using inverted inputs or dedicated inverting buffer amplifiers, it should work fine.

TR-48 module 3: five slots, L-R, Dual inverting amp, DFG, second amp, Dual integrator, 5x potentiometers+refs

6. Apply Stimulus

In this example, we need to apply two simulated forcing inputs, with the correct scaling. The system will settle down to a static state after a short while without any input forcing. It is instructive to apply the stimulus to only one input at a time so you can observe energy transfer between the two masses. For this system, a variable-frequency, variable-amplitude sinusoidal waveform would be useful for measuring the system’s frequency response. Finally, applying a step waveform (equivalent to pushing a mass to a position and then suddenly releasing it) can be used to observe the corresponding transient response. For this system, we would expect some energy transfer between the two masses, but over a short time, all motion should cease due to dissipation in the modelled dampers.

Initial Conditions

Before running the simulation on an actual analogue computer, we need to determine suitable initial conditions. This is another way to set up for a transient response. The state variables come from integrators, and those integrators require initial values. We could just use 0 V for everything and run with a step stimulus, but it is cleaner to use the initial-condition mechanism to preset the state variables to sensible values and zero the force inputs.

Then use the repeated-run option, which sets the initial conditions, generates a scope trigger, and releases the computer into run mode before repeating. The user can then adjust the coefficients and see the system response in real time. When the desired response is seen, the machine can be switched back into ‘pot set’ mode and the coefficient values read out.

Resources and More Reading

There is quite a bit of love for these old analogue computers, so a reasonable number of preserved resources and museum display units exist beyond the TR-48 displayed at the NMoC.

One of the best places for such literature is the Analog Museum Library.

Another good resource is the online catalogue of the excellent Computer History Museum in Mountain View, California.

Documentation

EAI: A Practical Approach to Analog Computers

EAI: Handbook Of Analog Computation, 1971.

EAI: TR-48 Analog Computer Operators Manual, 1963.

EAI: TR-48 Maintenance Manual Volume1, 1963

EAI: PACE TR-48 Transistorized Analog Computer Specifications

EAI: Variable Breakpoint Variable Slope Diode Function Generator Brochure, 1964

EAI: Quarter-Square Multiplier Model 7.096, 1963