Interfacing with an Analogue World PDF
Document Details
Uploaded by AccomplishedMoose509
Singapore Institute of Technology
2020
Ian McLoughlin
Tags
Summary
These lecture notes provide information about interfacing with an analogue world, focusing on the conversion between analogue and digital signals. Topics covered include the importance of analogue signals, representing analogue values in digital systems, pulse code modulation, transducers, and practical considerations for analog-to-digital and digital-to-analogue conversion. Presented in a slide format.
Full Transcript
h a n a nalo g ue world it Title: Interfacing w n e s s or I an M cL oughli Lecturer: Prof Date: 2020-07 SINGAPORE INSTITUTE OF TECHNOLOGY Interfacing with an...
h a n a nalo g ue world it Title: Interfacing w n e s s or I an M cL oughli Lecturer: Prof Date: 2020-07 SINGAPORE INSTITUTE OF TECHNOLOGY Interfacing with an analogue world – general principles Professor Ian McLoughlin ICT Cluster Singapore Institute of Technology SINGAPORE INSTITUTE OF TECHNOLOGY Contents The importance of analogue Representing analogue values in a digital system Pulse code modulation and sampling Transducers Analogue-to-digital conversion Digital-to-analogue conversion Some practicalities SINGAPORE INSTITUTE OF TECHNOLOGY The importance of analogue The world is analogue sound, temperature, speed, pressure, medical measurements etc... all have units and amounts, e.g. 23.6 dB, 36.8°, 41.5 km/h, 230.2 Pa Our computers are digital everything is represented in binary –> fixed or floating point When a computer interacts with the real world, we need to convert between the two domains, and we need to represent values internally SINGAPORE INSTITUTE OF TECHNOLOGY Representing analogue in a digital system For single values to store the quantity in a computer – we must choose the right number format based on maximum size and precision. Example 1: a temperature in between °C. Need to know range and precision. Let's say -99 - 999°C +/- 0.01°C. => probably use a floating point variable. Example 2: a speed 0 to 215km/h with precision 1km/h => probably an 8-bit integer. SINGAPORE INSTITUTE OF TECHNOLOGY For continuous values to measure something which is changing, we need to represent it with multiple values – and how often they are updated is important Glucose level Too high Actual blood The stored information Normal glucose level 9am to 6pm Too low Time Sampled every 2 hours – looks fne Sampled every 1 hour – we see two problems! SINGAPORE INSTITUTE OF TECHNOLOGY That was an example of sampling – defined by sample rate Examples of sample rate: Telephone speech: 8kHz CD-quality music: 44.1kHz Two hourly measurement: 1 / 2 x 60 x 60 = 0.00014 Hz Sample rate - must be frequent enough to capture the variations in the signal that we are interested in. But sampling too frequently wastes power, CPU cycles and memory space. So how fast is “fast enough”? SINGAPORE INSTITUTE OF TECHNOLOGY Nyquist theorem A continuous signal can be sampled and perfectly reconstructed from its samples if the waveform is sampled at least twice as fast as the highest frequency component in the signal. or When sampling a signal, if the highest frequency we are interested in is Fmax, then we need a sample rate of Fs ≥ 2Fmax SINGAPORE INSTITUTE OF TECHNOLOGY Working backwards, what does this tell us about the highest frequencies found in these original signals which are now represented digitally: Telephone speech Fs = 8kHz CD-quality audio Fs = 44.1kHz Earthquake sensor Fs = 0.25Hz Keyboard scan rate Fs = 100Hz SINGAPORE INSTITUTE OF TECHNOLOGY Pulse code modulation (PCM) This is the name given to continuous sampling of a signal at a rate Fs , with each sample stored as a signed two's complement integer. 0 0.25 0.5 0.75 1.0 1.25 1.5 1.75 2 Time, 8 ms Amplitude 7 6 5 4 3 2 1 0 -1 -2 -3 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Time, The analogue signal and index Its digital representation SINGAPORE INSTITUTE OF TECHNOLOGY Thanks to A/P Yar Kar Peo for these plots Quantisation The number of discrete levels used to represent the amplitude of a signal. More levels means better accuracy, but bigger numbers. SINGAPORE INSTITUTE OF TECHNOLOGY Quantisation defines how a value is stored in binary. e.g.: CD-quality audio: 16-bits Recorded speech: 8- or 12-bits Quantisation is necessary for single values too! Quantisation error – difference between what you actually store and the original value. SINGAPORE INSTITUTE OF TECHNOLOGY Most microprocessor applications start with analogue data, transform input Micro- ADC DAC output into the digital domain via an ADC, processor process internally, then output to a DAC to transform back into the Micro- analogue domain. input ADC processor However some systems lack either Micro- an input or output (but not both!) DAC output processor Analogue Digital Analogue SINGAPORE INSTITUTE OF TECHNOLOGY Transducers input Input Micro- Output ADC DAC output transducer processor transducer Transducers convert a signal from one form into another form, e.g. Sound CC BY-SA 3.0 Microphone, Loudspeaker, Buzzer https://commons.wikimedia.org/w/ index.php?curid=1148080 Ultrasonic transducer CC BY-SA 2.0 Wikimedia commons user Afrank99 Vision LED, LDR (light dependent resistor), photodiode Camera sensor Temperature, pressure, CO2, magnetometer SINGAPORE INSTITUTE OF TECHNOLOGY Analogue-to-digital conversion In an N-bit analogue-to-digital converter (ADC), the range of the input voltage is divided into 2N levels. The resolution of the ADC is the step between levels: R = VREF / 2N There are really two main things happening inside an ADC device: 1. Sample the input voltage (take a snapshot) 2. Quantise the sample into binary (and 3. Provide the digital sample to the CPU when asked) SINGAPORE INSTITUTE OF TECHNOLOGY This example is a 3-bit ADC, so 111 Digital output, NADC there are 23=8 levels. 110 101 R = VREF / 2N 100 The biggest quantization error 011 Any input voltage in this region would give will be half of one bit = +/- R/2 010 a binary output of 100 001 Dynamic range is; DR= 6.02N + 1.76 dB 000 0 Analogue voltage input, Vin VREF SINGAPORE INSTITUTE OF TECHNOLOGY Everything we have looked at so far assumes uniform quantisation. But the quantisation could be non-uniform. For example logarithmic; 111 111 110 110 101 101 100 100 Usually more 011 011 010 relevant to human 010 perception 001 001 000 000 There are some clever methods that allow you to trade sample rate for dynamic range. e.g. delta-sigma ADCs which sample very fast (e.g. 32x Nyquist) but with only 1 bit precision! SINGAPORE INSTITUTE OF TECHNOLOGY Digital-to-analogue conversion This is the reverse of the ADC The same factors apply – sample rate Fs, precision N bits, Nyquist, quantisation error, dynamic range SINGAPORE INSTITUTE OF TECHNOLOGY Practical use of the ADC and DAC In hardware, the circuit designer fixes the Clipping VREF voltage to the maximum that will VREF be needed. Some ADCs/DACs can also fix the lower voltage (i.e. not 0v) 0 If an ADC input signal goes above VREF Input Clipping Output or below 0v then it is clipped when sampled Sampling/quantisation isn't instantaneous, the CPU tells an ADC to start sampling. Instead of waiting for it to finish... we always use interrupts. i.e. the ADC interrupts the CPU when it has finished converting. SINGAPORE INSTITUTE OF TECHNOLOGY What we have covered in this segment The importance of analogue Representing analogue values in a digital system PCM Transducers ADC DAC Some practicalities