1. Chapter 3.9 Simulation and Real-time Processing.
3.9 (a) Real-time Applications.
A real-time system is one that can react quickly enough to data input to affect the real
world. If this is true it implies that the output from the system must be produced quickly
enough to produce the effect on the world outside the computer before that world has
enough time to alter. Consider the case of the airline booking system. The “world” that
we are talking about is the world of the database that contains all the booking details. The
use of a real-time system here refers to the concept that if a ticket is bought by a member
of the public, the database must be updated before the next person has a chance to book a
ticket. Notice that the idea of working “incredibly fast” or “in billionths of a second” does
not apply here. In some real-time applications these comments may be reasonable, but it
depends on the „world‟ that the application is concerned with.
When asked to describe a real-time application the first thing that needs to be described is
the world of the application. Everything else falls into place. Students should then
describe the hardware necessary to allow input and output from that world and the
decisions that the software must take.
A nuclear reactor may start to react too violently and sensors inform the computer
controlling the reaction that this is happening. The computer takes the decision to insert
the graphite rods to slow the reaction down. This is a real-time application. The world of
the application has been identified, the input devices are the sensors that inform the
computer of the state of the reaction, the computer makes an immediate decision and the
graphite rods are now moved into place. Notice that the rods moving is not immediate but
will take place over a period of time, however the decision was taken immediately. Note
also that the sensors simply report on the state of the world, there is no hint at decision
making on the part of the sensors. Many students would phrase their answer in the form
of “The sensors spot that the reaction is too violent and the processor makes …”. Here,
the sensors are being credited with having processing power in that they can interpret the
readings that are produced.
Students should also be able to identify when a real-time system is appropriate as
opposed to a system where the decision making is in some way delayed.
3.9 (b) Sensors and Actuators
A sensor is a device that measures physical quantities. A physical quantity is something
that exists in the real world as opposed to the computer world. Examples would be
length, time, temperature, light, flow, pressure. Sensors can be divided into two groups,
one is analogue whilst the other is digital. Digital sensors produce an output that is
digital. For example, a burglar alarm may have a pressure pad by the front door which
produces a signal if it is trodden on. The signal is either that it has been trodden on, or
that it has not. It cannot be half trodden on. A thermistor which is measuring the
temperature for a chemical reaction will send different signals according to the
temperature that it detects. As the temperature increases the voltage produced by the
1
2. thermistor increases, it is this voltage which gives a measurement of the temperature.
Note that any temperature may be reported, hence the reading is analogue. The computer
will require the signals from such sensors to be passed through an analogue/digital
converter because the computers with which we are dealing are digital computers and
hence can only use digital signals as input.
Most sensors are surprisingly simple, relying on one of two methods to gain information.
They either use some type of spring mechanism to physically change the position of
something in the sensor, or a means of turning some reading into a variable voltage. The
spring ones are like the pressure pad, held open by a spring which is overcome by the
weight of the burglar. Similarly, a bumper around a robot vehicle can be kept away from
the body of the vehicle by springs which are overcome if the robot moves too close to
something blocking its path. A thermistor, used to measure the room temperature for a
central heating system converts the ambient temperature to a voltage so that a decision
can be made by the processor. A light meter at a cricket match converts the available
light to a voltage so that the processor can decide whether there is enough light for play.
Notice that the digital sensors are really switches. If the bumper around the robot is
depressed is it necessary for a processor to make a decision? Probably not, the switch
would simply switch off the motor. The question arises whether this is a sensor in the true
sense of a sensor in computing. The answer is that the action of turning the motor off
required no decision and hence no processing, but that the need to do so will be reported
to the processor because it now has to make a decision about what to do next and the
input from that sensor is going to be an important part of that decision.
One last point about sensors. There are as many different sensors as there are physical
quantities that need measuring, but their reports need to be kept as simple as possible to
allow the processor to make decisions quickly. The idea of a sensor being a TV camera
because it can show the processor what is going on in a large area is unrealistic because it
would provide too much information. What would be possible would be a TV picture
which could be scanned by a processor for any kind of movement in order to indicate the
presence of a burglar. Never lose sight of the idea that the processor is limited in the
amount of data that can be interpreted, as is the software that the processor is running.
When the processor makes its decisions it must be able to take some action. In the type of
scenario we are talking about it will probably be necessary to alter something in the
physical world. This may involve making the robot move in a different direction, it may
be a matter of switching on some lights or telephoning the police station to report an
intruder on the premises. Some of these are simple electric circuits that the computer can
trip by itself, however, making the robot change direction is rather more complex. Such
movement involves the use of an actuator. An actuator is the device that can accept a
signal from the computer and turn it into a physical movement.
3.9 (c) The Use of Robots
The first thing to understand is what constitutes a robot.
A robot is a mechanical device which is under the control of a processor.
2
3. Imagine a car production line. Each car is built on a flat bed which is on wheels and runs
along a track from one building process to the next. It stops at the area where the wheels
are fitted, then it moves along the track to have the engine put in, then moves again to
have the doors fitted and so on. This flat bed is not a robot it is simply a machine
following a preset course. Now imagine the same system but at the start of the production
line the computer controlling the flat bed is told the parameters for that particular car.
This is to be a 3 door coupe with the 1700cc engine. It stops to have the wheels fitted but
must then make a decision to go to the correct area for a 1700cc engine, from there it
must go to the area that has the correct body shell for a 3 door coupe. This machine is
now making decisions and can be considered a robot.
Why are robots used?
The first thing to consider is cost. Never say that robots are used because they are
cheaper. They are not. They are extremely expensive. What must be considered are two
types of cost. The first is the capital cost of buying the equipment, the second is the cost
of running the system, it is here that savings will probably be made in relation to the cost
of employing a person.
People can get tired and when they do get tired the work that they produce can be of a
poorer quality than it otherwise would have been. The robot will not necessarily do a
better job than the human (indeed, it is not as adaptable and therefore may produce worse
results) however, it is consistent. It never gets tired.
There are some places that are particularly hazardous for human beings, for instance the
inside of a nuclear reactor, but maintenance must still be carried out. These are natural
environments for a robot to work in because there is no human equivalent.
A robot does not need the peripheral things that a human being needs. There is no need
for light or air in a factory. There is no need for a canteen or for restrooms or for a
transport infrastructure to get the workers to work and home again. There is no need for a
car park or for an accounts department to work out the pay for all the workers. There is a
need, however, to employ technicians to service the machines and programmers to
program every task that they need to undertake. Notice the need for a human workforce
has not disappeared but the workforce is made up of different types of worker, generally
more skilled than was previously the case.
3.9 (d) Simulation.
A computer system has the ability to perform a large number of calculations in a short
space of time. If a physical action can be portrayed as the result of a series of formulae
and their results, acting upon one another, then the computer can, by doing the
calculations, pretend to be carrying out the physical action. This is what is meant by a
simulation.
The rate of growth of a sunflower is known from observations taken over many years.
The effects of different chemicals on the growth of sunflowers are known from simple
experiments using one chemical at a time. The effects of different combinations of the
chemicals are not known. If the computer is programmed with all the relevant formulae
dictating how it should grow in certain circumstances, the computer can play the part of
the sunflower and show how a real one can be expected to react. In this way the effects of
3
4. different growing conditions can be shown in seconds rather than waiting 6 months for
the sunflower to grow. One can imagine that in the course of a day a programmer can
come up with a suitable cocktail of additives to allow sunflowers to grow on the fringes
of a desert and consequently create a cash crop for farmers, in such conditions, where
they had no cash crop before. This is an example of the use of a computer simulation to
speed up a process in order to give results in a more reasonable time scale.
Simulation can be used to predict the results of actions, or model situations that would be
otherwise too dangerous. What will happen when a certain critical condition is exceeded
in a nuclear reactor? I don‟t want them to try it on the one down the road from where I
live and I‟m sure no one else does either. Program a computer to pretend to be a nuclear
reactor and it is no longer necessary to do it for real.
Some things are impossible. It is not possible to fly through the rings of Saturn. Program
a computer to pretend and a virtual reality world can be created to make it seem possible.
A car company is planning a new suspension system for a range of cars. One way of
testing different designs is to build prototypes and take them out in different conditions to
test how they work. This is very expensive, as well as time consuming. A computer can
be programmed to take the characteristics of each possible system and report how well
they will work, at a fraction of the cost. The same simulation can be made to vary the
conditions under which it operates. A fairly simple change to the parameters of one of the
formulae being used can simulate driving on a motorway or on a country lane.
People can have ideas which need testing to see if they are valid. An engineer may design
a new leaf spring for a suspension system. The hypothesis is that the spring will give
more steering control when travelling on rough surfaces. The computer can be set up to
simulate the conditions and give evidence to either support or contradict the hypothesis.
A financial package stores data concerning the economy. It can be used to provide
information about past performance of the various criteria being measured or it can be set
up to predict what will happen in the future. If the graph of a particular measure is linear
then extrapolation of what will happen in a year‟s time is not difficult, in fact you
certainly don‟t need a computer to provide the prediction. However, if the graph is non
linear the mathematics becomes more difficult. More importantly, economic indicators do
not exist in isolation. If the unemployment figures go up then there is less money in the
economy, so people can buy less, so firms sell less, so more people are laid off. Unless
the bank of England brings down interest rates which will encourage people to borrow
more and hence buy more, so firms need to employ more people in order to put more
goods in shops… When the relationships become intertwined like this the calculations of
predictions become very complex and computers are needed.
3.9 (e) The Need for Parallel Architecture
As mentioned before, if the predictions are best on a simple linear relationship between
two variables then there is little need for a computer because there is little to calculate
4
5. and the calculations are simple. If the predictions are based on a more complex
relationship then the computer becomes useful but only in terms of a glorified calculator.
However, if the predictions are based on complex, multiple, relationships the calculations
become immense and must be done quickly, if related to a time sensitive example like the
weather, otherwise, if tomorrow‟s weather forecast takes two weeks to compute, it
doesn‟t matter how accurate the results are, they are useless.
This combination of the vast quantities of data, the inter relationships and the consequent
volume of calculations means that computer power becomes essential to giving a sensible
result. Indeed, with something like the weather forecast, ordinary computers are too slow.
There is a need for high speed calculation, a need that is satisfied by the use of parallel
processing.
3.9 (f) Advantages of Simulation
This has already been discussed in this section. Briefly, the advantages of simulation to
testing are that tests can be carried out safely, at a fraction of the normal cost and in a
fraction of the time that the testing would otherwise have taken.
Limitations of Simulation
The syllabus no longer expects the limitations to be taught as a separate topic, but the
value of computer simulations cannot be appreciated without considering such
limitations. Those students with a mathematical background will know the difficulty of
coming up with true randomness and particularly in relation to physical events. In this
context random events must be interpreted as unpredicted or unpredictable events. The
previous sections have discussed problems associated with unpredicted events like the
effect of the sun storms on the weather. It is not suggested that the effects of these storms
could not be included in our model, simply that it was not considered when the model
was created, hence this is a fault of the model and not a suggestion that because of sun
storms it is impossible to predict the weather. However, there are some situations that are
not predictable. They are to do with events that are so complex that it is impossible to
design a model for them, or to do with human beings, the behaviour of which does not
normally follow easily interpreted relationships.
If it were possible to predict the outcome of the lottery draw then there would be some
very rich computer programmers. Mathematically, the outcome is not random and should
be predictable, perhaps by modelling the behaviour of the individual atoms inside the
machine that chooses the balls. However, this is impossible, certainly with present
technology.
If it were possible to predict accurately that human beings would all buy a particular song
in preference to another, then the record industry would not have to produce such a
volume of material in order to have a single hit. Human behaviour is very difficult to
predict.
5