175 ADVAL analogue to digital converter value Purpose An analogue signal is one which can have almost any value – including fractional parts. It is contrasted with a digital signal which is expressed in exact numbers. The height of the water in a harbour is an analogue quantity whereas the number of boats it contains is a digital quantity. Watches always used to have analogue dials – ‘The time is about four fifteen’. Electronic things usually work with whole numbers; for example 16h : 15m : 23s There are four ‘analogue to digital’ converters in the BBC Microcomputer.
Each analogue to digital converter in the computer accepts a voltage and gives out a whole number indicating how large the voltage is. This voltage might be controlled by, for example, the position of a ‘games paddle’ or ‘joystick’ control which is connected to the computer. Alternatively the computer might be connected to a speed sensor on a piece of machinery or it might measure the temperature of a room. The input voltage range is 0 volt to 1.8 volt. When the input is 0 V the converter produces the number zero. With 1.8 V input the converter produces the number 65520. Why 65520? The circuit in the computer which does the conversion was designed to give out numbers in the range 0 to 4095.
However it may well be that future converters can give out numbers over a larger range – enabling the computer to measure things more accurately. In order to ensure that the BBC Microcomputer can be used in this situation we have specified a large range. Instead of producing numbers in the 0 to 4095 range it produces a number in the range 0 to 65520. Therefore instead of numeric results going up in the sequence 0, 1, 2, 3 etc they will go 0, 16, 32, 48, 64 etc. If you prefer the range 0 to 4095 then just divide the value by 16.
There are four analogue input channels provided in the BBC Microcomputer and the number in parentheses after the keyword ADVAL refers to the channel whose value you wish to find. The channels are numbered 1, 2, 3, 4. ADVAL(0) performs a special function in that it can be used to test to see which of the ‘fire’ buttons is pressed on the games paddles. The value returned also indicates which ADC channel was the last one to be updated. The following can be used to extract these two pieces of information from the value returned by ADVAL(0) .