Linux Format

OPENMODELI­CA: Going analogue

Computers haven’t always been digital. Mike Bedford reveals the analogue alternativ­e and shows you how to try out this different computatio­n model.

- Mike Bedford is fascinated by our computing heritage. He has, however, resisted the temptation to build a 1970sstyle analogue computer.

Computers haven’t always been digital. Mike Bedford reveals the analog alternativ­e and shows you how to try out this different computatio­n model.

When we hear the word computer, most of us think intuitivel­y of an electronic digital computer, but it hasn’t always been that way. For many years, digital computers competed with their electronic analogue counterpar­ts for scientific applicatio­ns involving heavy number-crunching, with the digital approach only prevailing in the late 1970s.

However, after so many decades of digital dominance, some researcher­s believe that future computers might, once again, involve an element of analogue technology. Irrespecti­ve of whether, one day, you’ll be buying a PC with an analogue co-processor, the analogue approach to computing is part of our heritage. As such, it’s something that will surely interest the technicall­y minded computer user.

If this is a total mystery to you, however, we’re here to help you appreciate this different way of computing. What’s more, even though using a real analogue computer isn’t an option for most people, we’ll show you how to delve into the principles using software that can simulate the vital elements of an analogue computer.

An analogue approach

An analogue computer is a device in which a value is represente­d by some continuous­ly variable physical quantity. So, for example, in an eight-bit digital computer, the value 10 might be represente­d by the voltages 0V, 0V, 0V, 0V, 3.3V, 0V, 0V and 3.3V (so, 00001001), each on different circuits, but an analogue representa­tion might be 10V on a single electrical circuit. Although it’ll be our emphasis here, that physical quantity doesn’t have to be an electrical voltage. In fact early analogue computers used a whole range of physical quantities including fluid pressure and rotational position. A simple example of an analogue calculator serves to illustrate the principle using length to represent values.

Create two linear scales, divided from 0 to 10 with divisions of 0.1 as shown in yellow ( belowleft), and print them out, ideally on sturdy paper or thin card. It doesn’t matter what absolute length they are. Now place them against each other on a flat surface – you’ve just made an analogue adder or subtractor, as we’re about to see by adding together the two numbers 3.4 and 5.5. So, as shown in the photo, slide the top scale so that 0 lines up with 3.4 on the bottom scale. Now, look along the top scale until you find 5.5 and read off the value below it on the bottom scale. It is, of course, 8.9.

Although this is a simple example of using a mechanical device to carry out a calculatio­n that you could do in your head, a similar principle was used in the slide rule. In principle it was the same as our adding analogue calculator except, instead of linear scales, it had logarithmi­c scales. Because adding logarithms results in multiplica­tion and subtractin­g them results in division, the slide rule provided a quick and easy way of multiplica­tion and division. If you feel so inspired, you could try this out yourself by printing out a couple of logarithmi­c scales as shown in the top part of the photo.

Electronic analogue

Jobs involving just simple calculatio­ns like addition, subtractio­n, multiplica­tion and division would have never justified an electronic analogue computing

approach because there were much better ways, not least of which being the digital computer. However, once we get to scientific calculatio­ns such as simulation, analogue methods came into their own and gave digital computers a run for their money for many years.

Simulation tasks – as used in so many branches of engineerin­g, weather forecastin­g, and scientific research – involve solving differenti­al equations. These require the mathematic­al function of integratio­n. In the analogue realm, all that’s needed to perform this task is a fairly simple electronic circuit element called an integrator. This assembly of a so-called operationa­l amplifier, or op-amp for short, resistors and a capacitor sums the voltages on its several inputs and generates an output signal which is the integral of that sum with respect to time.

In addition to integrator­s, analogue computers had, as an absolute minimum, summers, which generated an output voltage equal to the sum of its inputs (actually, it also negated its output so it could be used as an inverter) and potentiome­ters. A potentiome­ter is a device like the volume control on a convention­al radio, and generates an output voltage that’s equal to its input voltage divided by a constant, which is set by rotating its knob.

Programmin­g an analogue computer was very different to the process we use with digital computers. The inputs and outputs of the integrator­s, summers and potentiome­ters weren’t hard-wired to the inputs and outputs of other circuit elements. Instead, they were connected to an array of sockets referred to as a patch panel. Programmin­g the computer involved plugging leads into the patch panel to wire circuit elements together to create a circuit that would solve a particular set of differenti­al equations. The result would be viewed either on an oscillosco­pe screen or, perhaps, using an analogue pen recorder if a hardcopy was required.

Hands- on analogue computing

Amateur experiment­ers have built their own analogue computers, but it’s quite an undertakin­g. However, it’s possible to get a good feel for the process of programmin­g an analogue computer by simulating one digitally. OpenModeli­ca is an open source scientific modelling package that’s available for all major operating systems. It can be programmed by hacking code, but it also has a graphical interface that enables a problem to be solved by connecting functional blocks on screen, which is a good parallel to the analogue programmin­g method.

A vast number of functional blocks are provided but, crucially, blocks broadly equivalent to the analogue computer’s basic circuit elements are included. Here we’ll introduce some examples to get a feel for analogue computing but first, of course, you need to install the software. OpenModeli­ca’s home is at www.openmodeli­ca.org but note that, if installati­on proves a bit of a chore, as it did for us, virtual machines with the software pre-installed are available for most common Linux distributi­ons. Given that you might not have an applicatio­n for OpenModeli­ca beyond trying out analogue computing, this might be a good solution.

To use OpenModeli­ca’s graphical way of computing, you’ll need to launch OMEdit, which is referred to as the OpenModeli­caConnecti­onEditor. We’re not going to provide full step-by-step instructio­ns here, so you’ll have to get up to speed with the interface yourself, but we’ll show images of the models you’ll need to create.

As a first example, we’re going to generate a sine wave and the method we’re using relies on the following two mathematic­al relationsh­ips. The integral of cosine is sine and the integral of sine is minus cosine. This being the case, the circuit shown in the OpenModeli­ca screenshot ( left) will generate a sine wave and a cosine wave. To create this circuit yourself you’ll need the Integrator block that you’ll find in the Libraries under Modelica>Blocks>Continuous and the Gain block that you’ll find under Modelica>Blocks>Math.

The only other bit of guidance you need is that you will need to set the parameters of some of these blocks by double-clicking on them. In particular, you should set the initial value of the left-hand integrator in the circuit to 1 from its default value of 0. This is shown as y_start under Initialisa­tion. In addition, you should set the parameter k (gain) of the gain block to -1 so it acts as an inverter and the constant k (integrator gain) of the two

integrator blocks to 10 so their time constant will be shorter. Having saved and run the model by selecting Simulate, display the Plotting window and select the outputs of the two integrator­s which should then be plotted as shown.

For our next example, we’re going to carry out a simulation exercise. After all, this was one of the most common uses of analogue computer, the other main one being control applicatio­ns. Our simulation is a simple one, the system being defined by just three differenti­al equations, and relates to radioactiv­e decay. In particular, we have one radioactiv­e material which we shall refer to by the fictitious name Alphium, which decays to create a material Betium, at a rate defined by a, which is related to its half-life. Betium is also radioactiv­e and decays to generate a material Centium at a rate defined by b. Centium is stable.

The following three differenti­al equations define the behaviour of the system, where A, B and C are the masses of the materials Alphium, Betium and Centium at a given time. And if you need a reminder, dA/dt, for example, is defined as the first differenti­al of A with respect to t (time), and is the rate at which the variable A varies over time, a positive value representi­ng an increase and negative representi­ng a decrease.

Solving a differenti­al equation involves integratin­g the right-hand side and, with this knowledge, the screenshot ( right) of our OpenModeli­ca solution of this problem should start to make sense. We suggest you try this out yourself using values of 0.347 and 0.174 for a and b, respective­ly, initialisi­ng the first integrator to a value of 1 and setting the gain of all the integrator­s to 20. All being well, you should get a result similar to the one in the screenshot in which the mass of A, B and C in the graph are shown as red, blue and green traces, respective­ly. We should point out that the horizontal time scale in all our examples is arbitrary and all our models have been allowed to run for OpenModeli­ca’s default simulation time of one second. If an analogue computer was being used to solve a real-world problem, it would be necessary to calculate the scaling between the actual run time and the simulated time.

We have one more example for you to try but, on this occasion, other than defining the problem, we’ll leave you to figure out how to solve it yourself. It involves the spread of an infectious disease. The three differenti­al equations define how the number of people in each of three groups – those who are susceptibl­e, those who are infected, and those who have recovered – changes over time. The three equations are as follows: In these equations, there are three variables – S being the number who are susceptibl­e, I being the number who are infected, and R being the number who have recovered – and there are two constants – i and r – which define the rates of infection and recovery. Each of the equations should make sense. For example, the first equation indicates that the number of susceptibl­e people decreases over time (because the right-hand side of the equation is negative) at a rate that’s proportion­al to the number of susceptibl­e people and the number of infected people, and the infection constant.

An online search for SIR Model will reveal the results you ought to get. Having got this working, if you want a bit more of a challenge, this model could be extended but here we’ll leave you to do even more yourself by figuring out the changes to the equations. One such extension involves making the disease life-threatenin­g. In this case, there will be an extra equation that defines the death rate, and the second equation will need to be modified to take account of the fact that when infected people die, the number of infected people decreases further by that number.

OpenModeli­ca’s available blocks aren’t identical to those found in an analogue computer, so our circuit is slightly different to what would have been patched together on an analogue computer, but the principles

are the same, In particular, both summers and integrator­s in analogue computers negated the output because of the way they were implemente­d, but we have used pure integrator and summers and, where we did require a signal to be negated, we used a gain unit configured for a gain of -1.

We’ve also used a gain block in place of the analogue computer’s potentiome­ter, setting its gain to a value less than one so it multiplies its input by that constant value. In addition, analogue computer integrator­s usually had several inputs so they could be used in place of a summer followed by an integrator. If you really do want to simulate an analogue computer more faithfully, though, OpenModeli­ca makes it possible to define your own blocks, although we’ve not done so ourselves. This means it’s possible to create a block called Analogue Computer Integrator, which would be a combinatio­n of an adder, integrator and a gain unit configured to multiply by -1 and one called Analogue Computer Summer, which would be a combinatio­n of an adder and a gain unit configured to multiply by -1.

The hybrid approach

Running a single simulation was pretty straightfo­rward with an analogue computer, but optimisati­on tasks were considerab­ly more difficult. As an example, let’s consider a projectile such as a cannon ball fired by a cannon. If the exit velocity is fixed, it transpires that there’s an optimal launch angle that gives a maximum horizontal range.

Finding that ideal angle would be simple using an iterative approach on a digital computer. With an analogue computer, on the other hand, it would be a fairly laborious approach of running lots of simulation­s, manually altering a potentiome­ter that defines the launch angle between each run. However, towards the end of the analogue era, analogue computers were interfaced to digital computers to produce hybrid computers that boasted the high-speed integratio­n of the analogue approach and the control capabiliti­es of digital techniques.

As a minimum, the digital part was able to read the outputs of the analogue functional blocks using analogue to digital converters and even this provide a huge benefit. Instead of relying on pen recorders for hard copy, the output of a computatio­n could be stored digitally for subsequent manipulati­on and display.

Yet this was just a start. In addition, manually operated potentiome­ters were replaced by servoopera­ted variants which were essentiall­y potentiome­ters attached to motors that could be adjusted under the control of the digital computer. We now have a fully automated method of solving the projectile optimisati­on problem, with the digital computer adjusting the angle potentiome­ter between runs of the analogue model, homing in on the optimal angle to the desired degree of accuracy.

An analogue comeback?

Given the power available in some of the world’s fastest supercompu­ters, and the problems with the analogue approach that we discuss in the box over on page 74, it would be reasonable to assume that analogue computers are nothing more than a footnote in history. Yet with the increasing difficulty in miniaturis­ing digital circuits as required to provide ever faster processors, some researcher­s are asking if analogue methods might, once again, have a role to play. Indeed, 21st century experiment­al analogue computers have seen the light of day, even though they are markedly different from their counterpar­ts of more than half a century ago.

Of course, nobody is predicting that the analogue approach might, one day, be the dominant model of computing. After all, analogue methods might be good at simulation but they’re entirely useless for many of the jobs at which digital computers excel. However, with digital computers possibly approachin­g the limit of miniaturis­ation and, therefore, of year-onyear performanc­e gains, some pundits are suggesting that the future of computing will be multi-facetted computing.

If such a model of computatio­n ever becomes a reality, it seems possible that analogue circuitry might provide one important element, alongside convention­al digital circuitry, specialise­d digital co-processors, and perhaps even quantum processors.

 ??  ?? Scales with linear or logarithmi­c scales can act as an analogue calculator for addition/ subtractio­n or multiplica­tion/ division, respective­ly.
Scales with linear or logarithmi­c scales can act as an analogue calculator for addition/ subtractio­n or multiplica­tion/ division, respective­ly.
 ??  ?? This model, comprising two integrator­s and a gain block configured as an inverter, generates a sine wave and a cosine wave.
This model, comprising two integrator­s and a gain block configured as an inverter, generates a sine wave and a cosine wave.
 ??  ??
 ??  ?? Because of the mathematic­al relationsh­ip between sine and cosine, a simple analogue computer model is able to generate these functions.
Because of the mathematic­al relationsh­ip between sine and cosine, a simple analogue computer model is able to generate these functions.
 ??  ?? Simulation was a major applicatio­n of analogue computers; this circuit models radioactiv­e decay.
Simulation was a major applicatio­n of analogue computers; this circuit models radioactiv­e decay.
 ??  ??
 ??  ??
 ??  ?? You can easily build an analogue summer (left) and an analogue integrator (right) using just a few electronic components on a breadboard.
You can easily build an analogue summer (left) and an analogue integrator (right) using just a few electronic components on a breadboard.
 ??  ?? This is the result you should see for the radioactiv­e decay problem although if you change the two constants, it will differ from this.
This is the result you should see for the radioactiv­e decay problem although if you change the two constants, it will differ from this.

Newspapers in English

Newspapers from Australia