Overview
Introduction/motivation Sampling basics A/D conversion Nyquist frequency Binary numbers and quanti ation !achine representation Bitwise operations in " Summary
Operational amplifiers
Analog filters
,lectronic systems
In the -old days. people constructed all electronic systems using purely analog devices 0pper vertical
deflection plate
"athode
,lectronic systems
,lectronic systems are very often used together with non1 electronic devices2 motors( loudspea3ers( antennas( *,D displays( etc$ etc$
!otor current
D"1motor
5egulator
%oltage proportional to speed
4achometer
5oughly since the 6789's( analog systems have gradually been replaced with digital designs( because2
4hey are cheaper 4hey are easier to design 4hey are (re-)programmable
Actuator
;ower supply :eadphones Antenna 5udder( engine( propeller
Analog/Continuous
Computer
System/reality
Sensor
"ontinuous signals
4he signals and physical phenomena we observe around us are normally continuous:
"urrents and voltages in the power grid >ater flow in a district heating system 5otation speed of an engine ,tc$ etc$$$
,lectrocardiogram
,lectromyogram
"omponent/ subsystem
"omponent/ subsystem
Signal
"omponent/ subsystem
Signal
"omputers only -understand. -numbers. :ence( continuous signals must be discretized in order for computers to be able to process them 4his is 3nown as sampling
Amplitude
"ontinuous time
Sampling
# ? s @ is called sampling time %s A 6/4 ? : @ is called the sampling %re$uency &sometimes also given in ?rad/s@+
Sampling 1 schematics
D/A converter
Actuator
Algorithm
4imer
A/D converter
Sensor
Sampled signal
Say we want to sample the following sinusoidal signalC how do we choose an appropriate sampling frequencyD
Sampling with E9 :
Sampling with F9 :
Nyquist frequency
4he Nyquist1Shannon sampling theorem2 '% a %unction x(t) contains no %re$uencies higher than ( hertz! it is completely determined by gi&ing its ordinates at a series o% points spaced ) / &*(+ seconds apart+
"onversely( it is impossible to reconstruct a continuous1time sinusoidal signal containing frequencies higher than half the sampling frequencyH 4his frequency is called the ,y$uist %re$uency In practice( it is difficult to detect frequencies of more than about I of the sampling frequency
=ast enough C1+ But fast sampling comes at a price( both in terms of more eJpensive A/D converters and faster processing equipment( e$g$( microcontrollers$ Also( if one samples too fast( the information in the signal may be lost in noise etc$ 5ule of thumb2 G %b K %s K E9 %b where %b is the -bandwidth. of the system
Loseph =ourier discovered that any repetiti&e signal may be written as a &potenitially infinite+ sum o% sines/cosines(and.idth refers to the frequencies where the amplitude of the sine/cosine components have non1 negligible amplitude$
=requency spectrum
A frequency spectrum is a graph that shows how much 'power' each sinusoidal component contributes with
A 6$7 sin&9$N t+ 9$7 sin&N$< t+ 9$E sin&E$< t+ 9 9$N : E$< : N$< : %
Aliasing
In old movies you could sometimes see wagon wheels rotating -bac3wards. 1 this is an optical illusion caused by a limited sampling frequency in the film cameras used$
Aliasing
O<99
O6G9
Image <
Image E
Direction of motion
Image 6
>hen a frequency in a continuous1time signal eJceeds the Nyquist1frequency( but is still below the actual sampling frequency( we see a -reflection. of that frequency in the sampled signalC this is 3nown as aliasing
4he frequency of the aliased signal( %a ( is found via the eJpression %a&,+ A P % B , %s P
=or eJample$$$
=ind %a if %s is 6EG : and % is 699 : 4est different values of , in the eJpression %a&,+ A P% B , %s P , A 6 2 f = 125 100 = 25 N = 2 : f = |125 200| = 75 N = 3 : f = |125 300| = 175 We can thus expect to see an aliased signal component at 25 H !
*owpass1filter
A/D "onverter
Digital signal
Sampled signal
Binary numbers
Binary numbers with n digits can represent different values ,$g$ for n A <:
Some common resolutions: EN A EGM( E6E A F97M( E6M A MGG<M( EEF A 6M888E6M( $$$
Ruanti ation
Numbers represented by binary digits are countable B this means that not all real numbers can be represented on a computer But we can get arbitrarily close by increasing the number of digits
,ach bit corresponds to a voltage interval :ence( quanti ation leads to a $uantization error q of at most the same si e as this interval &+ Best1case &5ounding off+2 q " #
Summary
A/D conversion is a way of representing continuous signals as discrete values )eywords2 discretization and $uantization Sampled &alues are represented in a computer using binary digits
Amplitude Amplitude
4ime
4ime
Summary
It is not possible to reconstruct sinusoidal signals containing frequencies higher than half the sampling frequency B the ,y$uist %re$uency Normally( a sensible choice of sampling frequency is G to E9 times the highest frequency -of interest. to the application( called the band.idth >hen sampling signals with lots of frequencies( you need to be aware of aliasing On the slides after this( you will find some reference material that you might find of relevance later
A continuous voltage signal is compared with different reference voltages and are converted into either %O or 9 % 4hese values are associated with logic values B either 9 or 6
PA OR and assignment T XOR 6 if ON, of the bits is 6 and the other is 9 TA XOR and assignment U one's complement =lips all bits KK Shift Left Shifts all bits to the left( inserting 9's KKA Shift Left and assignment VV Shift Right Shifts all bits to the right VVA Shift Right and assignment
{x }
, " " =9
that we wish to process in some way 4ypically( the x'es are used as input to some digital filter The general formula for a digital filter is where the a's og b's are filter coefficientes and the y's are the output of the filter at the indicated sample numbers
na
nb
na and nb are usually small integersC furthermore( it it is common to scale such that a9 A 6$ b9 is often &but not always+ 9$ =or eJample( a so1called second order filter2
0nit gain
y "= x"
Simple gain
y " = 0x "
Signal offset
y " = x " c
4ime delay
y " = x " 6
Averaging filters
5ecursive filters
4he output of recursive filters depend on -old. output values B for eJample2
Integrator
Implementation
Implementation
On ;" /* save to file data.dat */ /* load and plot in e.g. Matlab: load -ascii data.dat plot((2:N),data,'r-') */