58
Interfacing

Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Interfacing

Page 2: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Interfacing

What sits between the microcontroller and the outside world?

This segment includes a very compressed look at analog electronics

passive components op amps Some of it is review is if you’ve taken EE 205

a little bit of signal processing Modulation / demodulation Code division multiplexing

CSE 466 Interfacing 2

Page 3: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Lab Electric field sensing

A good example that allows you to get your hands dirty with some signal conditioning and embedded signal processing

2 part lab Week 1

Create a single channel electric field sensor, using software demodulation Software-defined UART to send bits from MSP430 to PC

Week 2 Multi-channel e-field sensing, using software-defined code division

multiplexing PC-side GUI to display sensor values

It’s a lot…the lecture material is structured to cover what you need in time for the lab We will discuss RS-232 now, and then do other serial protocols after

interfacing

CSE 466 Interfacing 3

Page 4: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

CSE 466 Interfacing 4

Electric Field Sensing

Use software to make sensitive measurements Case study: electric field sensing You will build an electric field sensor in lab

Non-contact hand measurement Software (de)-modulation for very sensitive measurements Same basic measurement technique used in accelerometers, etc Good intro to some principles of signal processing & radio We will get signal-to-noise gain by software operations

We will need some basic electronics some math some signal processing

Page 5: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

CSE 466 Interfacing 5

Electrosensory Fish

Weakly electric fish generate and sense electric fields Measure conductivity “images” Frequency range .1Hz – 10KHz

W. Heiligenberg. Studies of Brain Function, Vol. 1:Principles of Electrolocation and Jamming AvoidanceSpringer-Verlag, New York, 1977.

Black ghost knife fish(Apteronotus albifrons)Continuous wave, 1KHz

Tail curling for active scan

Page 6: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

CSE 466 Interfacing 6

Electric Field Sensing for input devices

Page 7: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

CSE 466 Interfacing 7

Cool stuff you can do with E-Field sensing

Page 8: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Interfacing 8

Lab preview

Microcontroller

-1

+1

Square waveout

ADC IN

RS-232 serialdata to PC

Sensed object

Signal processing

3 pieces:- Serial communication- Analog HW- Software signal processing

Page 9: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

CSE 466 Communication 9

Serial protocols

RS-232 (IEEE standard) serial protocol for point-to-point, low-cost, low-speed applications for PCs

I2C (Philips) TWI (Atmel) up to 400Kbits/sec, serial bus for connecting multiple components

Ethernet (popularized by Xerox) most popular local area network protocol with distributed arbitration

IrDA (Infrared Data Association) up to 115kbps wireless serial (Fast IrDA up to 4Mbs)

Firewire (Apple – now IEEE1394) 12.5-50Mbytes/sec, consumer electronics (video cameras, TVs, audio, etc.)

SPI (Motorola) 10Mbits/sec, commonly used for microcontroller to peripheral connections

USB (Intel – followed by USB-2) 12-480Mbits/sec, isochronous transfer, desktop devices

Bluetooth (Ericsson – cable replacement) 700Kbits/sec, multiple portable devices, special support for audio

Page 10: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

CSE 466 Communication 10

RS-232 (standard serial line) Point-to-point, full-duplex Synchronous or asynchronous Flow control Variable baud (bit) rates Cheap connections (low-quality and few wires) Variations: parity bit; 1.5 or 2 stop bits (not common)

start bit(always low)

8 databits

paritybit

stop bit(always high)

At 9600 baud, each bit (start, data, stop) lasts 1/9600s

Page 11: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

CSE 466 Communication 11

RS-232 HWConnector: DB-9 (old school)

Wires (Spec): TxD – transmit data TxC – transmit clock RTS – request to send CTS – clear to send

RxD – receive data RxC – receive clock DSR – data set ready DTR – data terminal ready

Ground

Wires (Typical) TxD, RxD, GND

all wires active low

Spec:

"0" = -3v to -15v

"1" = +3v to +15vReality: even more variability

PC serial port: +5 and –9

special driver chips (eg Max 232)

generate high /-ve voltages from 5v or 3v

Often you see “TTL level serial,” between

chips or boards,

+5v and 0v or

+3.3v and 0v

Often implemented as “virtual COMM” port

over USB, e.g. FTDI chip

Page 12: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

CSE 466 Communication 12

Transfer modes

Synchronous clock signal wire is used by both receiver and sender to sample data

Asynchronous no clock signal in common data must be oversampled (16x is typical) to find bit boundaries

Flow control handshaking signals to control rate of transfer

Page 13: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

CSE 466 Interfacing 13

Basic electronics

Page 14: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

CSE 466 Interfacing 14

Basic electronics

Voltage sources, current sources, and Ohm’s law AC signals Resistance, capacitance, inductance, impedance Op amps

Comparator Current (“transimpedance”) amplifier Inverting amplifier Differentiator Integrator Follower

Page 15: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

CSE 466 Interfacing 15

Voltage & Current sources

“Voltage source” Example: microcontroller output pin Provides defined voltage (e.g. 3.6V) Provides current too, but current depends on load (resistance) Imagine a control system that adjusts current to keep voltage fixed

“Current source” Example: some transducers Provides defined current Voltage depends on load

Ohm’s law (V=IR) relates voltage, current, and load (resistance)

Page 16: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

CSE 466 Interfacing 16

Ohm’s law and voltage divider

Need 3 physics facts: 1. Ohm’s law: V=IR (I=V/R)

Microcontroller output pin at 5V, 100K load I=5V/100K = 50A Microcontroller output pin at 5V, 200K load I=5V/200K = 25A Microcontroller output pin at 5V, 1K load I=5V/1K = 5mA

2. Resistors in series add 3. Current is conserved (“Kirchoff’s current law”)

Voltage divider Lump 2 series resistors together (200K) Find current through both: I=5V/200K=25A Now plug this I into Vd=IR for 2nd resistor Vd=25A * 100K = 25*10-6 * 105 = 2.5V General voltage divider formula: Vd=VR2/(R1+R2)

Vd=?

Page 17: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Capacitor

Apply a voltage Creates difference in charge between two plates Q = CV

If you change the voltage, the charge on the plates changes…apply an AC (continuously changing) voltage, get continuously changing charge == AC currentd dQ CVdt dtdQ dV dVC i Cdt dt dt

Page 18: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Time domain capacitor behavior

/

For 0 at 0,(1 )

i

t RCi

V VdVI Cdt R

V tV V e

“5RC rule”: a cap charges/decays to within 1% of itsfinal value within 5 RC timeconstants

Page 19: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Capacitor charge/discharge e-cap.html

Useful fact:For “parallel plate” capacitor,

ACd

Where- epsilon is a constant (that

depends on the material between the plates)

- A is plate area- d is plate separation

Page 20: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Applications of capacitors

Energy Supercaps ~1F electrolytics (polarized [+-] leads! don’t hook them up backward

or the smoke will escape!) ~10uF-100uF

Power supply filtering 10uF-100uF electrolytic

“AC coupling” between amp stages “Bypass”

0.1uF ceramic or polyester, one per chip, shunts noise to ground

Timing and waveform generation [“delay circuits”] Hi/low pass filtering Differentiation (AoE 1.14) / integration (AoE 1.15)

Page 21: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Operational amplifiers

Amplify voltages (increase voltage) Turn weak (“high impedance”) signal into robust (“low

impedance”) signal by adding current (and thus power) Perform mathematical operations on signals (in analog)

E.g. sum, difference, differentiation, integration, etc Originally analog computing building blocks!

Page 22: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Operational amplifier (as comparator) e-opamp.html

Page 23: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Op Amp Behavior

Op amp has two inputs, +ve & -ve. Rule 1: Inputs are “sense only”…no current goes into the

inputs It amplifies the difference between these inputs With a feedback network in place, it tries to ensure:

Rule 2: Voltage on inputs is equal ensuring this is what the op-amp does! as if inputs are shorted together…“virtual short” more common term is “virtual ground,” but this is less accurate

Using rules 1 and 2 we can understand what op amps do

Page 24: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Comparator

Used in earlier ADC examples No feedback (so Rule 2 won’t apply) Vout = T{g*(V+ - V-)} [g big, say 106]

T{ } means threshold s.t. Vout doesn’t exceed rails

In practice V+ > V- Vout = +15 V+ < V- Vout = -15

V-

V+

+15V

-15V

Vout

Page 25: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Op amp with feedbacke-opampfeedback.html

Page 26: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Follower

Because of direct connection, V- = Vout

Rule 2V- = V+, so Vout = Vin Vin

Vout

1. No current into inputs2. V- = V+

Page 27: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Follower e-amp-follower-outputimped.html

Page 28: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

CSE 466 Interfacing 28

Page 29: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Op Amp Behavior (again!)

Op amp has two inputs, +ve & -ve. Rule 1: Inputs are “sense only”…no current goes into the

inputs It amplifies the difference between these inputs With a feedback network in place, it tries to ensure:

Rule 2: Voltage on inputs is equal ensuring this is what the op-amp does! as if inputs are shorted together…“virtual short” more common term is “virtual ground,” but this is less accurate

Using rules 1 and 2 we can understand what op amps do

Page 30: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Transimpedance amp

Produces output voltage (inversely) proportional to input current

AGND = V+ = 0V By rule 2, V- = V+, so V- = 0V Suppose Iin = 1A By rule 1, no current enters “-” input All current must go through R1 Vout-V- = -1A * 106 Vout = -1V

Generally, Vout = - Iin * R1

IinVout

1. No current into inputs2. V- = V+

V-

V+

Page 31: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Transimpedance amp (current to voltage)e-itov.html

Page 32: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Inverting op amp e-amp-invert.html

Page 33: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Inverting op amp

1

11

22 1 2

1 1

2

1

The Golden Rules1. Hi inputs2. = = 0

Drop across is

... Now we have a current into a transimpedance amp!

Gain N

in in

in

inout in

out

in

ZV V

V VR V V V

VIR

V RV R I R VR R

V RV R

2 1

egative value of gain ==> "inverting"

Example: 100 , 10 , 0.1 1in outR K R K V V V V

Page 34: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Op Amp power supply

Dual rail: 2 pwr supplies, +ve & -ve Can handle negative voltages “old school”

Single supply op amps Signal must stay positive Use Vcc/2 as “analog ground” Becoming more common now, esp in

battery powered devices Sometimes good idea to buffer output of

voltage divider with a follower What you’re using in the lab

2.5V“analogground”

Ground0V

Dual rail op-amp

Single supply op-amp

Page 35: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

CSE 466 Interfacing 35

End of basic electronics

Page 36: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Signal processing Sensor measurements are often noisy, or contain extra information

we don’t want Signal processing is a body of techniques for filtering (and otherwise

improving) signals (sequences of sensor measurements)

Often useful to treat a signal as a mathematical vector Can ask questions like “how similar are these two vectors?” This computation is called a correlation For two vectors of the same length (same number of dimensions),

inner product (dot product) can be a good measure of correlation

Can also perform vector operations, such as subtracting one vector from another

Embedded systems often used for signal processing operationsCSE 466 Interfacing 36

Page 37: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Interfacing 37

Electric Field Sensing circuit

Microcontroller

-1

+1

Square waveout

ADC IN

For nsamps desired integration Assume square wave TX (+1, -1) After signal conditioning, signal goes direct to ADC Acc = sum_i T_i * R_i

When TX high, acc = acc + sample When TX low, acc = acc - sample

Page 38: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Interfacing 38

E-Field lab pseudo-code

// Set P1.0 as output// Set ADC as input; configure ADCNSAMPS = 200; // Try different values of NSAMPS //Look at SNR/update rate tradeoffacc = 0; // acc should be a 16 bit variableFor (i=0; i<NSAMPS; i++) {

SET P1.0 HIGHacc = acc + ADCVALUESET P1.0 LOWacc = acc - ADCVALUE

}Return acc

Page 39: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Interfacing 39

What is the code doing?

The code computes inner product of 2 signal vectors…Imagine unrolling the loop:

Write ADC1, ADC2, ADC3, … for the 1st, 2nd, 3rd, … ADCVALUE

acc = ADC1 – ADC2 + ADC3 – ADC4 + ADC5 – ADC6 +… acc = +1*ADC1 + -1*ADC2 + +1*ADC3 + -1*ADC4 +…acc = C1*ADC1 + C2*ADC2 + C3*ADC3 + C4*ADC4 + …

where Ci is the ith sample of the carrier (i.e. the TX signal)

acc = <C,ADC> Inner product of the carrier vector with the ADC sample vector

Vectors bold, blue

Page 40: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Example (1/2) Suppose original signal is+1 +1 -1 -1 +1 +1 -1 -1

Gain and sensor values cause it to be modulated by 20:+20 +20 -20 -20 +20 +20 -20 -20

It gets a DC offset of 5, yielding:+25 +25 -15 -15 +25 +25 -15 -15

And the following noise added +1 +0 +1 -1 +1 -1 -1 +1

Yielding +26 +25 -14 -16 +26 +24 -16 -14

CSE 466 Interfacing 40

Page 41: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Example (2/2) Take inner product of modulated signal+20 +20 -20 -20 +20 +20 -20 -20

with original (unmodulated) signal:+1 +1 -1 -1 +1 +1 -1 -1

we get20 +20 +20 +20 +20 +20 +20 +20 = 160

Take inner product of received signal (incl. noise & offset ):+26 +25 -14 -16 +26 +24 -16 -14

with original (unmodulated) signal:+1 +1 -1 -1 +1 +1 -1 -1

we get26 +25 +14 +16 +26 +24 +16 +14 = 161

CSE 466 Interfacing 41

Almost same value! Offset & noise barely affected result!

Page 42: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Linearity

Inner product is linear operator…that means it obeys superposition…so we can separately analyze effects on signal and (additive) noise:

<a+b,c> = <a,c> + <b,c>

CSE 466 Interfacing 42

Page 43: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Orthogonality

Two vectors are orthogonal if their inner product is zero: Suppose b is orthogonal to c:

<b,c> = 0 Very nice when combined with linearity: <a+b,c> = <a,c> + <b,c> = <a,c>

We were able to separate the effects of b because c is orthogonal to b

In our example, the carrier is orthogonal to both the DC offset, and (approximately) to the noise!

CSE 466 Interfacing 43

Page 44: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Orthogonality example (offset)

Inner product of original signal…+1 +1 -1 -1 +1 +1 -1 -1

…with offset+5 +5 +5 +5 +5 +5 +5 +5

is+5 +5 -5 -5 +5 +5 -5 -5 = 0

CSE 466 Interfacing 44

Page 45: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Orthogonality example (noise) Inner product of original signal…+1 +1 -1 -1 +1 +1 -1 -1

… with noise+1 +0 +1 -1 +1 -1 -1 +1

is+1 +0 -1 +1 +1 -1 +1 -1 = +1

CSE 466 Interfacing 45

Small, close to zero

Page 46: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Interfacing 46

v

Vectors! Think of a signal as a vector of samples Vector lives in a vector space, defined by bases A vector v can be projected onto various basis vectors to

find out “how much” of each basis vector is in v If v is orthogonal to a particular basis vector, the result

is 0

Vector v in some basis

<1,2>v

Vector v in another basis

<2.236,0>

Length:Sqrt(12+22)=2.236

Length:Sqrt(2.2362+02)=2.236

Page 47: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

What’s going on?

uC is generating a carrier (wave / signal / vector) Sensed quantity is amplitude modulating the carrier uC will demodulate to recover sensed value from carrier

Demodulation is projection of received signal onto original TX signal Any signal that is orthogonal to TX (e.g. offset, noise) will be

suppressed

Why do it this way? We are shifting the signal of interest [the sensed quantity] up to a

higher frequency (just like when a singer modulates in a song) There is less 1/f, 60Hz, fluorescent light-noise at high frequencies Also repeating the measurement many times, which improves SNR A single measurement would not have anywhere near usable SNR

CSE 466 Interfacing 47

Page 48: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

End of lecture

CSE 466 Interfacing 48

Page 49: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Digital filtering

Page 50: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Two types of digital filters

FIR (Finite Impulse Response) Output always settles to zero eventually after input stops No internal feedback…i.e.: current output depends only on past

inputs…current output does not depend on past output IIR (Infinite Impulse Response)

May “ring” forever (output never reaching zero) Has internal feedback: current output depends on previous

outputs, as well as previous inputs

FIR & IIR can each be used for low pass or high pass filtering

Page 51: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

FIR & IIR

CSE 466 Interfacing 51

FIRNo feedback…new outputdepends only on old input, noton old output

IIRHas feedback…new outputdepends on old outputs (current output is fed back to become an input again)

Outputfed backinto input

Page 52: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Example IIR filter derivation

Discretize ! and

in out

out

out

outin out

V V RidQQ CV idt

dVi Cdt

dVV V RCdt

1 2

1 2

1

1

1

( , ,..., )( , ,..., )

(sampling interval)

(1 )

where

1

0.5 time equal to sampling period

in n

out n

T

i ii i

T

Ti i i

T T

i i i

T

T

T

V x x xV y y ydt

y yx y RC

RCy x yRC RC

y x y

RC

RC

RC

0.5 time >> sampling periodRC

1 T T T

T T T T

RC RCRC RC RC RC

This circuit is an analog low pass filter

Page 53: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

FIR: Filtering in time domain via convolution Consider “impulse response” of filter

Impulse response is output when input is a delta function, i.e. an impulse

Convolve filter impulse response with input signal

Result is filter output

NB: In freq domain, this corresponds to multiplying filter frequency response (i.e. transfer function) by transform of input signal

Page 54: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Convolving tophat with various discrete low pass filters

0 5 10 15 20 25 30 35

0

0.2

0.4

0.6

0.8

1

1 tap2 tap3 tap4 tap9 tap10 tap11 tap15 tap

Page 55: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Matlab code% LPFth.m == LPF tophatc1=conv(tophat, [1]/1.0);c2=conv(tophat, [1 1]/2.0);c3=conv(tophat, [1 1 1]/3.0);c4=conv(tophat, [1 1 1 1]/4.0);c9=conv(tophat, [1 1 1 1 1 1 1 1 1 ]/9.0);c10=conv(tophat, [1 1 1 1 1 1 1 1 1 1]/10.0);c11=conv(tophat, [1 1 1 1 1 1 1 1 1 1 1]/11.0);c15=conv(tophat, [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]/15.0);

figure;plot(c1,'b');hold on;plot(c2,'r');plot(c3,'g');plot(c4,'c');plot(c9,'m');plot(c10,'y');plot(c11,'k');plot(c15,'b');axis([0 length(c10) -0.1 1.1])legend('1 tap', '2 tap', '3 tap', '4 tap', '9 tap', '10 tap','11 tap','15 tap')

Page 56: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Convolving tophat with discrete high pass filters

0 5 10 15 20 25 30 35

-1

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

1

c1c2c2bc3c3bc4c4b

Page 57: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

Matlab code% HPFth.m == HPF tophatc1=conv(tophat, [1]/1.0);c2=conv(tophat, [1 -1]/2.0);c2b=conv(tophat, [-1 1]/2.0);c3=conv(tophat, [1 0 -1]/2.0);c3b=conv(tophat, [-1 0 1]/2.0);c4=conv(tophat, [-1 -1 1 1]/4.0);c4b=conv(tophat, [1 1 -1 -1]/4.0);

figure;plot(c1,'b');hold on;plot(c2,'r');plot(c2b,'g');plot(c3,'c');plot(c3b,'m');plot(c4,'y');plot(c4b,'k');%plot(c15,'b');axis([0 length(c10) -1.1 1.1])legend('c1', 'c2', 'c2b', 'c3', 'c3b', 'c4','c4b')

Page 58: Interfacing · Interfacing What sits between the microcontroller and the outside world? This segment includes a very compressed look at analog electronics passive components op amps

A filtering technique

Given a signal x and a low-pass filtered version LPF(x), a high-pass filtered version of x is given by x – LPF(x)

CSE 466 - Winter 2008 Interfacing 58