Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU,...

21
Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3

Transcript of Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU,...

Page 1: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

Analog and Digital SignalsAD/DA conversion

BME 1008 Introduction to Biomedical EngineeringFIU, Spring 2015

Feb 5Lesson 3

Page 2: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

http://commons.wikimedia.org/wiki/File:A-D-A_Flow.svg

Analog signal

Voltage changescontinuously withpressure.

Digital signal

Voltage has discrete values.

Analog signal

Page 3: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

Analog signalsSmooth and continuous.

Most physical and biological signals, e.g. sound, temperature, blood pressure, pH.

Many sensors produce an analog signal; temperature, pressure, pH, light intensity etc.

Used typically by some older electronic devices, e.g. radio, TV, tape recorders, vinyl records.

time

Page 4: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

Digital signalsDiscrete and discontinuous.

Used by digital computers, i.e. most modern computers, including PC and supercomupters.

Used by many modern electronic devices, e.g. satellite radio, digital TV, digital cameras, scientific instruments etc.

Advantages over analog signals: immune to noise, flexible hardware, easy computing, robust storing, transmission, compression.

0 1 0 1 0 1 0 1 0 1 0

time

amplitude

Page 5: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

Analog-to-digital conversion(ADC)Modern telecommunication technology.Music recording, CD recordings. Hearing aids with digital signal processing.Scientific instruments, medical devices, e.g. ECG, EEG, pH-meters etc.

Digital imaging systems commonly use analog-to-digital converters in digitizing pixels.

Digital ECG

Page 6: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

Analog or Digital?

• 100 billion (1011) neurons.• 100 trillion (1014) synapses.• peaks are the firing of the cells.• the analog looking signals at the bottom represent sub-threshold activity.

Page 7: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

McCulloch and Pitts & The Binary Neuron

• Neurons first studied in the 40’s• Only two states were known, firing and not firing.

Page 8: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

•Artificial neural networks can be trained to recognize complex input patterns, e.g. sounds, images, faces etc.

•Biological brain and its theoretical models work entirely different than the modern digital computers.

Page 9: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

Modern Digital Computer

"Von Neumann Architecture" http://commons.wikimedia.org/wiki/File:Von_Neumann_Architecture.svg#mediaviewer/File:Von_Neumann_Architecture.svg

Page 10: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

10110000 01100001.....

inc ecxjne .loop...

Machine Assembler C/C++ Matlab code

Abstraction from the details of the hardware

main() { printf("hello"); }

y = 1:10plot(y.^2)

low high

Page 11: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

Analog-to-digital Converter ADC

Page 12: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

Sampling rate of ADC

Page 13: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

Quiz 3 - Sampling%Write the script in Matlab editor:clearsamplingInterval=1; %secondstime=0:samplingInterval:4; %secondssignalPeriod = 0.27; %secondssignal = sin(2*pi*time/signalPeriod);figure; plot(time,signal,'.-')

1) Adjust 'samplingInterval' to obtain proper plot of sin(). 2) What is the maximum 'samplingInterval'

for which the shape of sin() is preserved?

0 1 2 3 4-1

-0.5

0

0.5

1

undersampled

Page 14: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

Quiz 3 Answer

samplingInterval= 0.1; 0.01; 0.001;% ok % good % oversampled

General rule: (sampling Interval) < (signal period)/2or (sampling frequency) > 2×(signal frequency),where (sampling frequency) = 1/(sampling Interval).

0 1 2 3 4-1

-0.5

0

0.5

1

0 1 2 3 4-1

-0.5

0

0.5

1

0 1 2 3 4-1

-0.5

0

0.5

1

Page 15: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

Audio in Matlab[Y,FS,NBITS]=wavread('fileName.wav');% reads a WAVE audio file and returnsY -sampled data, FS - sample rate in Hertz, NBITS the number of bits per sample.

wavplay(Y,FS);% plays the signal in vector Y with sample frequency of FS Hertz% alternatively try audioplayer()>> help audioplayer

Page 16: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

Matlab script to read and play a WAV file:

clearfileName = 'THE_MICROSOFT_SOUND.WAV';[Y,FS,NBITS] = wavread(fileName);plot(Y)wavplay(Y,FS)whosFSNBITS

Page 17: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

0 2 4 6 8 10 12 14

x 104

-0.8

-0.6

-0.4

-0.2

0

0.2

0.4

0.6

0.8

3.852 3.854 3.856 3.858 3.86 3.862 3.864 3.866 3.868 3.87

x 104

-0.4

-0.3

-0.2

-0.1

0

0.1

0.2

0.3

0.4

THE_MICROSOFT_SOUND.WAV

FS = 22050 %Hz

NBITS = 8

length(Y)ans = 135005

%number of elements

Page 18: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

Addition of sine signal to the original sound

time = (1:length(Y))/FS; % length(Y) - returns number of elements

sine = 0.2*sin(2*pi*FS/50*time)'; % ' - transpose to column vector

wavplay(sine,FS);pause(2)wavplay(Y+sine,FS);figure; plot(time,sine,'g-.',time,Y,'b--',... time,sine+Y,'r:')

% ... - line continuation

Page 19: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

Quiz 4- Sounds clearFS = 5000; %sample frequency of 5kHztime = [0:25000]/FS; y1 = 0.25*sin(2*pi*FS/5*time);wavplay(y1,FS)pause(2)y2 = 0.25*sin(2*pi*FS/25*time);wavplay(y2,FS)pause(2)wavplay(y1+y2,FS)plot(time,y1,time,y2,time,y1+y2)

Page 20: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

Quiz 5- WAV files Search Windows or Google for a '*.wav' file, and

copy the file to Matlab current folder. Import the file into Matlab with wavread() or

Menu/File/Import.Plot the samples. Play sound with wavplay() (or audioplayer() ).

Modify the sound to fade out.Hint: Multiply the audio samples by a decaying functionY2=Y.*exp(-(1:length(Y))/(length(Y)/5))';

Page 21: Analog and Digital Signals AD/DA conversion BME 1008 Introduction to Biomedical Engineering FIU, Spring 2015 Feb 5 Lesson 3.

Note:wavplay() and audioplayer() may be unavailable or not

working in some Matlab configurations, e.g. Matlab on Citrix, Mac OS.