Title: How does a long distance receiver work?

Author: Eric Brasseur


How does a long distance receiver work?



How do space probes or good radio receivers manage to communicate over huge distances ? Here is a clear description of the fundamental mechanism used. Just a warning : this text contains almost no precise formula. If you want to be able to do serious calculations, you will have to get a book for telecommunication engineers.



  1. Introduction
  2. The signal/noise ratio
  3. Integration
  4. The precision of the clocks
  5. Bandwidth
  6. Accumulator atenuation
  7. The super-heterodyne receiver
  8. Common ways to enhance communications
  9. A practical software example



1. Introduction

Suppose I have a little device capable of emitting a beep sound. It's just a little box, with a loudspeaker and an on/off switch. When you turn the switch on, the device emits a continuous beep sound. When you turn the switch off, the device becomes silent. This device is an emitter.

Secondly, suppose I have another little device capable of hearing the beep sound. It is also a little box, with a microphone and a lamp. When the microphone hears a beep sound, the lamp glows. When the microphone hears no beep sound, the lamp stays dark. This device is a receiver.

You can play with those two little devices as much as you want :

When you turn the switch of the emitter on, the lamp of the receiver begins to glow. When you turn the switch of the emitter off, the lamp of the receiver darkens. And so on.

Has the receiver having been build a classic way, then the distance over which the communication works will be a few meters or a few tens of meters :

If you put the receiver, say 50 meters away of the emitter, then there will be no more communication. When you turn the switch of the emitter on, the lamp of the receiver will not begin to glow. It will remain dark.

But, if you build a long distance receiver, then the distance may be a lot more than 50 meters :

Suppose you are in a noisy city. You put the emitter somewhere, then walk away. At a few tens of meters distance your ears no more hear the sound of the emitter. But, after 1 kilometre walking away, the long distance receiver still manages to hear the sound of the emitter. Amazingly, the communication works : when the switch of the emitter is pulled to on; the lamp of the receiver begins to glow. And when the switch of the emitter is pulled to off, the lamp of the receiver darkens. At 1 kilometre distance ! That's magic.

There is only one drawback : the communication is now rather slow. When the switch of the emitter is pulled to on, you have to wait 1 minute until the lamp of the receiver begins to glow. And when you push the switch of the emitter to off, you have to wait again 1 minute till the lamp of the receiver darkens.

It is thanks to the technology of the long distance receiver that communication with space probes going outside the solar system has been possible.

Our purpose is thus now to explain how this little miracle works.



2. The signal/noise ratio

Suppose we take a microphone and connect it to an oscilloscope tuned appropriately. (If you don't have an oscilloscope at hand, you may use a PC with a sound card and a sound recording program).

The emitter is put a few centimetres away from the microphone.

When the emitter is switched off, the oscilloscope will show a straight line, no signal :



When the emitter is switched on, the oscilloscope will show a sine wave :



So, a deaf person will be able to tell wether the emitter is switched on or off. Just by looking at the screen of the oscilloscope.

Suppose now we put the emitter two times further from the microphone.

When the emitter is on, the signal shown by the oscilloscope will be two times weaker :



So, in order to still see the signal clearly, we will increase the amplification of the oscilloscope to make it show the sine wave again at a correct size :



No problem. The more we put the emitter further from the microphone, the more we ask the oscilloscope to amplify the signal. That way the signal remains clearly visible, whatever the distance.

Well, in fact this is not true. Once we have put the emitter, say 5 meters away from the microphone and the amplification has become relatively important, we see the noise appear :

This is what the oscilloscope shows when the emitter is off :



And this is what it shows when the emitter is on :



The emitter may be on or off, it makes no difference. The noise remains the same. When the emitter is on, the sine wave simply adds itself to the noise.

Noise is something you cannot avoid. Whatever you measure, if you amplificate it enough, you always get a noise. In fact it was there since the beginning, but it was so weak that we didn't notice it. It became visible once we amplificated it enough.

Let's put the emitter again two times further. We have to increase two times the amplification. Now the noise has the same amplitude as the sine wave :



From now on, when we will put the emitter further, we will no more increase the amplification. Because the noise fills the screen of the oscilloscope. Any increase in amplification would be useless : it would simply make the noise go outside the boundaries of the screen of the oscilloscope.

This is what appears when we put the emitter 10 meters away :



This is what appears when we put the emitter 20 meters away :



And this appears when we put the emitter 40 meters away :



We are no more able to see the sine wave. (You may have the impression to see pieces of sine wave, but it is only an illusion.)

The emitter may be on or off, the oscilloscope will show exactly the same thing : a noise.

Thus, at a distance of 40 meters our system does not work any more. A deaf person can no more use the oscilloscope to tell wether the emitter is on or off.

The key is the intensity of the signal versus the intensity of the noise. That's why we use the concept of signal/noise ratio.

The signal/noise ratio is a number. You obtain this number by dividing the number of the measure of the intensity of the signal by the number of the measure of the intensity of the noise.

Examples :

When the emitter was at a distance of 5 meters, the intensity of the signal was 1 and the intensity of the noise was 0.5. The signal/noise ratio was thus 2.

When the emitter was at a distance of 10 meters, the intensity of the signal was 1 and the intensity of the noise was 1. The signal/noise ratio was thus 1.

When the emitter was at a distance of 40 meters, the intensity of the signal was 0.25 and the intensity of the noise was 1. The signal/noise ratio was thus 0.25.

When the emitter is very close to the microphone, the intensity of the signal is 1 and the intensity of the noise is certainly less than 0.01. The signal/noise ratio is thus greater than 100.

We can say this :



3. Integration

The question is thus : what is the trick to determine the presence of the signal when the signal/noise ratio is a lot less than 1 ?

Answer : you must cut what you receive in exact pieces and make the sum of those pieces.

Like this :

Let's use what we received when the signal/noise ratio was 1. We had 4 periods of sine wave.



We cut these 4 periods away from each other :



Then we put them one above the other and make the sum of them :



Finaly we divide by four the result of that sum (just to scale it) :



As you can see, the noise is now two times weaker. (Compare with any of the four periods we summed.)

We have increased our signal/noise ratio by two !

How comes ?

Here is the explanation :

When you make the sum of four sine periods, the result is a sine period four times bigger.



That's because when you make the sum of n precise numbers, you get a result that is precisely n times bigger.

 7 +  7 +  7 +  7 =  28

-5 + -5 + -5 + -5 = -20

When you make the sum of four noise "periods", the result is only two times bigger.

That's because the noise is sometimes positive, sometimes negative, at random. When you add random positive and negative numbers together, they "eat" each other up.

8 +  3 + -5 + -10 = -6
1 + -5 + 11 +  -8 = -1

The sum of n sine periods of amplitude a is sine period of amplitude n . a

The sum of n noise "periods" of amplitude a is a noise "period" of amplitude n . a.

Thus, when we made the sum of four periods, the sine wave grew four times, but the noise grew only two times. The signal/noise ratio was thus increased by two.

When we make the sum of n periods,the signal/noise ratio is increased by a factor n.

A sum of periods is a very important object. Because it tells us if the sine wave was there or if it was not there. That allows us for example to transmit morse code. Here are the results of 27 successives results of sums calculated by a receiver :

absent absent there absent there absent there absent absent there there absent there there absent there there absent absent there absent there absent there absent absent

Transcribed with more readability, a space for absent and an underscore for there, it gives us this :


  _ _ _  __ __ __  _ _ _  


It's the morse code for S.O.S. (or perhaps O.S.O. ?).

The same way, you can transmit modern digital code.

The space probe Galileo is curently in orbit around the planet Jupiter. The radio signal we receive from the probe is cut into one billion periods each tenth of a second. All those periods are carefully summed to generate an information flow of ten bits per second. That makes one text character per second. Character afther character, word afther word, sentence afther sentence, the probe transmits a description of what it sees or measures.

More refined systems do measure the intensity of the sine wave. Each time a sum is calculated, the size of the sine wave is measured and that measure is transmitted to whatever needs it. AM long wave and short wave receivers you can by in any store work that way. By calculating several thousand sums per second and transmitting the result to a loudspeaker they make that loudspeaker reproduce a certain sound, voice or music.

You may now stop reading this text if you want, the rest of it are technical details.



4. The precision of the clocks

When the sine wave is visible in the signal, it is not difficult to know where to cut the signal to get successive periods.

A few periods may even be hidden by the noise, you still know where to cut just by looking at the position of the other periods near them. (That's what a PLL does.)

But what if the sine wave is completely hidden by the noise ? Where should we cut ?

There is only one solution : rely uppon a clock.

If we know that one period takes a milionth of a second, we make a clock give a tick each milionth of a second. Each time we hear a tick, we cut a period out of the received signal, blindly. And when we have accumulated enough periods, the sum of them will tell us wheter there was a sine wave hidden inside the noise or not.

OK. But that clock must have a certain accuracy. Let's take for example the following signal :



If the clock runs perfectly, we will get the following sixteen neat pieces :



But if the clock runs 5% too fast, and the periods are thus cut each time 5% earlier, we get this :



Compare the first period and the tenth. They are each others' opposite. If you make the sum of them, you get zero as result. In fact, the sum of all the periods will give, perhaps not precisely zero, but in any case something very little. We will not see a beautiful sine period emerge.

The more periods we want to cut and sum, the more accurate the clock will have to be.

If we want to sum hundred periods, we need a clock with a precision better than one hundredth. (This means that afther a time of say 100 seconds it deviates of less than a second.)

Attention : we have spoken about the precision of the clock used by the receiver. The clock of the emitter must have the same precision. It wouldn't help that the receiver cuts accurately the signal in periods, if the signal send by the emitter is unreliable. Both clocks must be accurate.



5. Bandwidth

Imagine we have a receiver that makes sums of, say, 1000 periods.

And the radio frequency he is made to hear is 10,000,000 Hz (10 MHz). That makes 10,000 sums calculated each second.

It will hear perfectly an emitter emitting at 10,000,000 Hz. Of course.

It will also hear an emitter emitting at 10,002,000 Hz. Nearly perfectly.

But il will not hear an emitter emitting at 10,500,000 Hz. For the obvious reason given in chapter 4. (Well in fact it may hear it if it emits a very powerful signal, but let's no think about that.)

So, an emitter at 10,500,000 Hz will not disturb our receiver working at 10,000,000 Hz.

Thus we can use a second receiver, receiving at 10,500,000 Hz, to hear that emitter at 10,500,000 Hz.

That receiver at 10,500,000 Hz will not be disturbed by the emitter at 10,000,000 Hz.

That's wonderful. Each emitter receives the signal emitted by the emitter using the same frequency, but is not disturbed by the other emitter using another frequency.

If a receiver can be tuned it will be able to choose to which emitter it listens. It can be tuned to listen to the emitter emitting at 10,000,000 Hz or to listen to the emitter emitting at 10,500,000 Hz. Or any other frequency. It's just a matter of clock frequency.

We work at about 10 MHz and we do 10,000 sums per second. We have the ability to use several frequencies at the same time to allow different emitters and receivers to work at the same place without disturbing each other. But, if we use frequencies between 9 MHz and 11 MHz, how many different couples of receivers ans emitters will be able to work simultaneously ?

The answer depends on several things. Commonly a difference in frequency of ten times the transmission rate is taken. We transmit 10,000 informations per second, so we will rely upon a difference of 100,000 Hz between each emitter-receiver couple. Thus : 9,000,000 Hz, 9,100,000 Hz, 9,200,000 Hz... up to 11,000,000 Hz, that makes 20 couples of emitter and receiver talking to each other at the same time without disturbing each other.

10,000 is the bandwidth. It is the number of elementary informations elements that are transmitted each second. That is, the number of times per second you calculate the sum of the periods received.

The broader the bandwidth,

This method that allows several emitters to emit at the same time, is called "frequency multiplexing". It is not the only one. Another is "time multiplexing" : all emitters use the same frequency (or do not use any frequency at all) but emitting time is shared amongst them. Each his turn. These two methods have their advantages and disadvantages, which one is choosed for a given application is a mather of engineering choice.



6. Accumulator atenuation

The description that is given above of a receiver is good but a bit theoretical. In reality, common receivers work not exactly that way.

The method we described can be sumarized this way :

At the beginning of a series of periods, an accumulator is set to null. Then, each period received is added to the accumulator. Ones n periods have been received and added, the content of the accumulator is looked at. If it draws a sine period, we state the signal was on. If it draws pure noise, we state there was no signal. (Or we measure the size of the sine.)

The method that is most commonly used is this one :

The accumulator is never set to null. Each period received is added to it, then the content of the accumulator is shrinked a little bit (it is multiplicated by 0.999, say). The content of the accumulator is looked at continuously. If it draws a sine period, we state the signal is on. If it draws pure noise, or a too little sine period, we state there is no signal. (Or we measure the size of the sine.)

This second method is less mathematicaly correct, but it is more physicaly realistic, smoother, and easier to use.

The first method has three practical drawbacks :

First method Second method
It requires perfect memories, that are not disturbed afther n periods. That can only be done with digital memories or with delay lines. It only requires simple components like a guitar string, a tuning fork or a condensator and a self.
When you look at how frequencies different from the perfect frequency are received, you get unregular results : a frequency slightly different will not be received at all, but another frequency further away from the perfect frequency will be heared a little bit. You get a smooth behaviour : the further away from the perfect frequency, the less it is received.
You must know when a series of periods starts (for digital transmissions) and when it ends. This requires circuits or algorithms in order to allow the receiver to be phased with the emitter. Because the accumulator is looked at continuously, you don't bother to be synchronised with the emitter.

The first method was characterised by the number n of periods summed. Everything depends on the number n. You may wonder what characterises the second method. Answer : the number by which the content of the accumulator is multiplicated each time a period is added. That is 0.999 in our example above.

Now let's look at some practical aspects of this second method :

Simple electronic receivers that use a rudimentary LC circuit as their heart work that way naturally. The LC circuit (one capacitor and one self latched together) works as a resonator : if it receives pure noise, it will just oscillate a little bit at low amplitude. But if the noise contains a signal that has the same frequency as the resonance frequency of the circuit then the circuit will begin resonating and will thus oscillate at higher and higher amplitude. Once the amplitude reaches a given threshold, that will trigger a transistor and "make a lamp glow". The LC circuit acts as a memory that sums the oscillations.

Mechanical receivers work the same way too. Early radio command devices used little tuning forks to determine if a given beep sound was being received : if the beep sound was there the appropriate tuning fork would begin vibrating so strongly it's end would touch an electric contact.

If you want to build some mechanical device to visualize what's happening, here are two suggestions. I tried out none of them so if you do please mail me your remarks and recomendations.



7. The super-heterodyne receiver

The super-hetrodyne receiver is the most widespread type of radio receiver. It works on a mathematical trick :

When you multiply a sine wave by a sine wave with a slightly different frequency, you get a result that is the sum of two other sine waves :



The two sine waves inside the result have frequencies that are higher and lower than the frequencies of the sine waves that have been multiplicated.

The lowest frequency is equal to the difference between the frequencies of the two initial sine waves. If the first frequency was of 1,000,000 Hz and the second was of 999,000 Hz then the sine wave will have a frequency of 1,000 Hz.

That sine wave with the lowest frequency is the one we are going to use. The sine wave with the highest frequency is filtered away.

What is that low frequency good for ? A lot of things :

Here you have a short program in BASIC that draws two sine waves and the result of their multiplication :

screen 1

frequency1 = .2
frequency2 = .24

FOR t = 0 TO 254 STEP .1

   sine1 = SIN(t * frequency1)
   sine2 = SIN(t * frequency2)
   sinem = sine1 * sine2
   PSET (t, sine1 * 10 + 10)
   PSET (t, sine2 * 10 + 50)
   PSET (t, sinem * 10 + 100)

NEXT t


8. Common ways to enhance communications

8.1 Directivity of the emitter

A device is added to the emitter to make as much as possible of the signal go towards the receiver. So there is no waste in useless directions. That's what you do when you put your hands around your mouth when you whant to shout at somebody far away or in a noisy environment.

The device best known is the parabolic antenna, but there are a lot of other ways to achieve directivity. For example sets of common antennas connected together trough wires of acurately calculted length.

The bigger the antenna, the more directivity you will get.

The bigger the wavelength of the signal you transmit, the bigger the antenna you will need to achieve the same directivity.


8.2 Directivity of the receiver

A device is added to the receiver to make him listen as much as possible only to the signal coming from the direction of the emitter. That's what you do when you put your hands back your ears to hear better a weak sound. The device best known is again the parabolic antenna, but there are a lot of other ways to achieve directivity. Like using several antennas and adding their signals. The bigger the device, the more directivity you get.

A parabolic antenna acts for radio waves just like a solar oven acts for the sunlight, concentrating what it receives on one given point.

The considerations about antenna size, directivity and wavelength are the same as for point 8.1 just above.


8.3 Reduction of the internal noise of the receiver

You can imagine for sure that making a receiver work in a noisy environment reduces its performances. But a receiver also produces it's own "internal noise" : every electronic component inside a receiver produces a noise. That's why those components must be carefully choosed or manufactured to produce the less possible noise.

Metalfilm resistors are prefered over carbon resistors, FET transistors are prefered over bipolar transistors, and so on.

To decrease even more the remaining amount of noise, and it can physically not be done another way, the receiver must be cooled down. It can be plunged into liquid nitrogen or even liquid helium. This is true whatever the type of communication system you are using : radio waves, light, light trough fibre optics, sound, electric signals trough wires, even interstellar gravitational waves...

Inside a simple component like a resistor, the noise is simply due to the electrons moving around inside the resistor. The hotter the resistor, the faster the electrons move thus the more noise. The higher the impedance, the higher the noise tension (this is compensated by the fact the noise is limited by the higher impedance).

If you want to hear directly such a noise, just put your ear inside an empty glass. Or both ears (inside two separate glasses, not inside the same glass).


8.4 Increase of the emitted power

The louder you shout, the farther one may hear you...

Here is some data for amateur electronics. Let's talk about the basic straight antenna.

You may consider an antenna as behaving like a simple electric resistance connected to the ground (picture below). But it has two differences with a common electric resistance :



Thus there are two ways to increase the emitted power :

One last reminder : don't forget that if the frequency generator is to be placed a certain distance away from the antenna, you must make use of a well defined type of electric wire to link them. Coaxial wire or twisted pairs. What's more that coaxial wire or that twisted pair should idealy have an impedance close to that of the output impedance of the generator and the impedance of the antenna. In fact, the three impedances should be the same (don't bother too much, practicaly it works often very well with fairly different impedances). That's why when you buy TV wire it is written 75 on it. Other common impedances are 50 and 100. The impedance of a coaxial cable means that if you send a signal of any frequency trough a cable of infinite length it will behave for your generator like a resistance of that impedance. Symetricaly, if a signal comes trough a coaxial cable or twisted pair, it will be like if it came trough a resistance of that impedance. If one of the three impedances is not the same, then you will get ghosts and signals bouncing back partialy. Coaxial cables and twisted pairs have three main particularities : they do not distort the signal (it may weaken, but it will keep the same shape), they do not spill radio waves around (that would polute around and weaken the signal inside the cable) and they are insensible to external noise (even if your cable went trough a room with radio emitters, electric sparks or whatever, the signal stays clean). For example, you may transmit RS/232 signals or even VGA screen signals on hundreds of meters provided you do that trough such wires.


8.5 Increase of the received power

The electronics inside the receiver work on the basis of a signal received by the "hearing device" : a microphone, an antenna, a light detector or whatever else. Now, the stronger the power of the signal delivered by the "hearing device", the easier will be the work of the electronics. That's trivial.

The quality of the "hearing device" matters, but also it's surface, a bit like for the directivity. The bigger an antenna, the more powerfull will be the signal it delivers. (In the case of an omnidirectional antenna, noise and useful signal are both increased.)

The most serious reason why the received signal should be as strong as possible is to make it be stronger than the internal noise produced by the electronics of the receiver.

It is not necessary to try to make the received power as big as possible : you just have to make it be louder than the internal noise of the electronics.

In the case of a basic straight antenna, you increase the received power by making the antenna longer. You may consider that a thick metalic antenna with a length of one half the wavelength of the frequency received has an impedance of 75 (wavelength  =  300,000,000 / frequency). This is to say you may consider the signal is coming trough a resistance of 75. If you double the length of the antenna, you half the resistance and thus you get two times more power. (The electric tension of the signal will stay the same, but you will be able to rely on a stronger current.) Attention : once the antenna becomes longer than half the wave length you get a certain form of disturbing directivity.

A receiving antenna transforms radio waves into an electric signal just like a microphone transforms sound waves into an electric signal.



9. A practical software example

Following program simulates the functioning of both an emitter and a receiver. A signal is emitted, it arrives at the receiver weakened and with a lot of noise added, yet the receiver manages to show wether there was an emitted signal or not.

While the program is running, press the 0 or 1 key on your keyboard to switch the emitted signal on or off. Then look at the sum result that appears at the bottom of the screen (wait). If the signal was on, a sine wave period will be drawn. If it was off, just a weak noise will be drawn.

In order to run this program you need a PC running (or emulating) DOS or Windows. They contain a powerfull BASIC language interpreter capable of running this program. Just select the program with your mouse, copy it, paste it inside a simple text editor, then save it under the name you want (with the .BAS extension). Start the BASIC interpreter (QBASIC.EXE), load the program and run it.


SCREEN 1        'switch to 320 x 200 graphical output screen

LOCATE 1, 1: PRINT "Signal emitted (press 0 or 1) :"
LOCATE 8, 1: PRINT "Signal weakened, noise added :"
LOCATE 15, 1: PRINT "Result of last sum of 1000 periods :"

t = 0           'time
x = 0           'horizontal display position on screen
i = 0           'sweep inside receiver memory
p = 0           'number of periods received
s = 0           'signal to transmit

DIM r(16)       'receiver memory : 16 registers

DO

    i$ = INKEY$                                 'key pressed ?
    IF i$ = "0" THEN s = 0                      'signal to transmit
    IF i$ = "1" THEN s = 1

    m = s * SIN(t * 2 * 3.1415627# / 16)        'modulated signal
    LINE (x, 20)-(x, 40), 0                     'erase old pixel
    PSET (x, m * 10 + 30)                       'display modulated signal
    t = t + 1
   
    n = RND - RND                               'noise

    r = n * .9 + m * .1                         'received signal
    LINE (x, 80)-(x, 100), 0                    'erase old pixel
    PSET (x, r * 10 + 90)                       'display received signal

    x = x + 1: IF x = 320 THEN x = 0            'display sweep

    r(i) = r(i) + r                             'add to register
    i = i + 1: IF i = 17 THEN i = 1: p = p + 1  'registers sweep

    IF p = 1000 THEN                            '1000 periods
       FOR a = 1 TO 16
          LINE (a + 140, 135)-(a + 140, 165), 0   'erase old pixel
          PSET (a + 140, r(a) / 10 + 150)         'display register value
          r(a) = 0                                'reset register
       NEXT a
       BEEP                                     'beep sound
       p = 0                                    'start new 1000 periods
    END IF

LOOP


Following program is much simpler. It works the same way as algorithms I implement inside microcontrollers. You may compare it with the program above to understand clearly how it works. Note only two registers are used and only the sign of the signal is used.


CLS

LOCATE 1, 1: PRINT "Signal emitted (press 0 or 1) : no"
LOCATE 15, 1: PRINT "Result of last sum of 1000 periods : nothing"

t = 0           'time
i = 0           'sweep inside receiver memory
p = 0           'number of periods received
s = 0           'signal to transmit

DIM r(2)        'receiver memory : 2 registers

DO

    i$ = INKEY$                                 'key pressed ?
    IF i$ = "0" THEN                            'signal to transmit
       s = 0
       LOCATE 1, 1: PRINT "Signal emitted (press 0 or 1) : no "
    END IF
    IF i$ = "1" THEN
       s = 1
       LOCATE 1, 1: PRINT "Signal emitted (press 0 or 1) : yes"
    END IF

    m = s * SIN(t * 2 * 3.1415627# / 16)        'modulated signal
    t = t + 1
   
    n = RND - RND                               'noise

    r = n * .9 + m * .1                         'received signal

    IF i = 1 OR i = 2 OR i = 3 OR i = 4 THEN r(1) = r(1) + SGN(r)
    IF i = 5 OR i = 6 OR i = 7 OR i = 8 THEN r(2) = r(2) + SGN(r)
    IF i = 9 OR i = 10 OR i = 11 OR i = 12 THEN r(1) = r(1) - SGN(r)
    IF i = 13 OR i = 14 OR i = 15 OR i = 16 THEN r(2) = r(2) - SGN(r)

    i = i + 1
    IF i = 17 THEN
       i = 1
       p = p + 1
    END IF

    IF p = 1000 THEN                            '1000 periods
       result = r(1) * r(1) + r(2) * r(2)
       IF result > 100000 THEN
          LOCATE 15, 1: PRINT "Result of last sum of 1000 periods : signal !"
       ELSE
          LOCATE 15, 1: PRINT "Result of last sum of 1000 periods : nothing "
       END IF
       BEEP                                     'beep sound
       p = 0                                    'start new 1000 periods
       r(1) = 0
       r(2) = 0
    END IF

LOOP


Please note two things about this second program :