digital stethoscope - ece 4760

Upload: shubher

Post on 02-Apr-2018

244 views

Category:

Documents


3 download

TRANSCRIPT

  • 7/27/2019 Digital Stethoscope - ECE 4760

    1/14

    8/12/13 Digital Stethoscope - ECE 4760

    people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/ 1/14

    "A digital stethoscope

    that can amplify, play,

    and record heart signals

    in real-time."

    Project Soundbyte

    The purpose of this project was to design and implement a digital stethoscope

    to serve as a platform for potential computer aided diagnosis (CAD)

    applications for the detection of cardiac murmurs. The system uses a custom-

    built sensor to capture heart sounds at 8 kHz and converts them to electrical

    signals to be processed by an ATmega644 microcontroller. The captured

    signals are outputted via pulse-width modulation to a standard 3.5 mm audio

    socket for real-time auscultation. In addition, the stethoscope uses a 1MB

    external Flash memory chip to record and playback audio waveforms. For the

    user interface, the system includes a 4-line 20-character wide LCD display and a 16-button keypad. Real-time and

    recorded data can also be visualized using a MATLAB interface that runs on a separate PC and connects to the

    stethoscope system via the USART interface on the microcontroller. The MATLAB interface also uses the transmitted

    data to calculate and display the patients average heart rate in beats per minute.

    This project is meant to provide a framework for developing useful embedded CAD tools for cardiac murmur

    detection. Heart murmurs may go unnoticed during routine check-ups since detection relies on the training ophysicians, the quality of the equipment used, and the severity of the condition. A digital stethoscope can be used to

    assist physicians in analyzing cardiac signals in real time during auscultation to reduce the risks of not detecting

    certain conditions.

    CE 4760: Final Projects

    Digital StethoscopeA portable, electronic auscultation device

    Michael Wu ([email protected])

    Garen Der-Khachadourian ([email protected])

    SEARCH: go

    Pages People more options

    High Level Design Software Hardware Results Conclusions Appendices

    http://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/index.html#appendiceshttp://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/index.html#conclusionshttp://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/index.html#resultshttp://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/index.html#hardwarehttp://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/index.html#softwarehttp://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/index.html#designhttp://www.cornell.edu/search/mailto:[email protected]:[email protected]://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/http://people.ece.cornell.edu/land/courses/ece4760/http://www.ece.cornell.edu/
  • 7/27/2019 Digital Stethoscope - ECE 4760

    2/14

    8/12/13 Digital Stethoscope - ECE 4760

    people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/ 2/14

    High Level Design top

    Overview

    The overall architecture of the system is centered on the ATmega644 microcontroller. The acoustic sensor and

    keypad are inputs to the MCU, while the LCD, headphones, and MATLAB visualization tool are outputs.

    Communication with the Flash memory is bi-directional. Figure 2 shows an overview of the system high level design.

    Figure 2. System High Level Design

    Figure 1. Digital Stethoscope System

    http://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/index.html#top
  • 7/27/2019 Digital Stethoscope - ECE 4760

    3/14

    8/12/13 Digital Stethoscope - ECE 4760

    people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/ 3/14

    Hardware Design & Implementation top

    Stethoscope Acoustic Sensor

    The stethoscope acoustic sensor was an integral hardware component of the system. The quality of the sensor

    directly impacts the quality of the real-time audio output as well as all analyses performed on the measured

    waveforms. Because of this, a custom sensor was designed and developed to capture heart signals. The sensor

    includes a standard stethoscope chest piece to amplify acoustic signals and an electret condenser microphone to

    convert the amplified signals to electrical waveforms. A microphone with a 20 Hz 20 kHz frequency range wasselected in order to capture all of the low frequencies characteristic of internal body sounds. The microphone was

    placed within a rubber tubing as close as possible to the base of the chest piece. In order to reduce noise and

    improve convenience, a 3.5 mm shielded cable was soldered to the leads of the microphone and pulled through the

    rubber tubing to interface with the MCU. Figure 3 shows an image of the constructed stethoscope sensor.

    Figure 3. Stethoscope Acoustic Sensor

    The sensor construction was tested by using a multimeter to detect shorts and to verify that proper connections

    were made. The actual sensing capability of the component was tes ted us ing the bias/amplifier circuit described in

    the next section.

    Microphone Bias and Amplifier Circuit

    The microphone in the acoustic sensor needed to be biased in order for proper operation. In addition, the output o

    the microphone is on the order of millivolts, which is relatively small in magnitude compared to the precision of the

    ADC sampling the sensor (the ADC has a precision of approximately 20 mV when taking 8-bit samples). This makes it

    challenging for the microcontroller to detect changes in sensor output. In order to address bo th these issues, a bias

    and amplifier circuit was designed and implemented to interface the raw sensor output with the MCU. The goal of the

    The MCU runs several software interfaces to support the various features of the digital stethoscope. The signal

    capturing interface uses the analog-to-digital converter to sample the acoustic sensor at 8 kHz. The real-time audio

    processing module modifies the measured signal based on user settings and outputs it to the 3.5 mm audio socket

    via pulse-width modulation. The user interface supports the detection and de-bouncing of keypad button presses as

    we ll as controls the LCD display to reflect the current state of the system. In addition, the use r interface also outputs

    real-time or recorded data at 100 Hz to a MATLAB utility running on a separate PC for signal visualization and

    average heart rate calculations. The Flash interface includes a software library for SPI communication to read from

    and w rite data to the external Flash memory chip.

    http://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/index.html#top
  • 7/27/2019 Digital Stethoscope - ECE 4760

    4/14

    8/12/13 Digital Stethoscope - ECE 4760

    people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/ 4/14

    circuit was to properly bias the microphone and amplify the sensor output to detect voltage swings caused by

    sounds. The figure be low shows a schematic of the completed circuit.

    Figure 4. Microphone Bias and Amplifier Circuit

    The typical operating range for the microphone was 2 V, with a maximum rating of 10 V. The MCU provided a voltage

    of 5 V, so a s imple voltage divider circuit with identical 1k resistors was used to reduce the voltage to 2.5 V to bias

    the microphone. The output of the microphone was passed through a capacitor to remove the DC offset. The

    capacitor used was large enough to make sure that the desired low frequencies were not filtered out. With two 1k

    resistors in parallel with the output of the microphone, the equivalent output impedance of the sensor is roughly 400

    ohms. Using a 10 uF capacitor, a simple high pass filter w ith a cutoff frequency around 40 Hz was designed, which is

    below most of the low frequencies of interest.

    The AC-coupled signal was connected to the positive input (Vin+) of an operational amplifier to boost the signal

    amplitude. Because the microcontroller ADC measures voltages between 0 and 5 V, the Vin+ line of the op-amp was

    biased to 2.5 V in order to capture the largest magnitude of positive and negative swings from the microphoneoutput. This biasing was implemented with another voltage divider circuit using identical 20k resistors. The values o

    these res istors were chosen to be larger than the resistors in the previous voltage divider in order to avoid affecting

    the equivalent output impedance of the previous stage.

    For signal amplification, a non-inverting op-amp configuration was used. The gain of the circuit is defined by the

    following equation:

    The resistors were selected to achieve an ideal gain of 150 for frequencies between the range of 20 Hz and 2 kHz.

    The gain was selected based on the 300 kHz gain-bandwidth product constraint of the op-amp. *Note: the resistor

    R6 was implemented in hardware as a variable resistor (10k trimpot) in order to allow for more convenient

    prototyping and testing. A capacitor was added in series with resistor R6 in the op-amp feedback loop to create a

    system with unity gain for DC voltage inputs. The unity gain at DC is important to prevent amplification of the 2.5 V

    bias at the Vin+ node. Without this additional capacitor, the output of the amplifier would sa turate to 5 V when the

    microphone did not detect any sounds. A 10 uF capacitor was selected for C1 in order to achieve a high pass filter

    cutoff of approximately 2 Hz, which is close to DC in order to pass all non-DC s ignals. On the other hand, a 500 pF

    capacitor was selected for C5 in parallel w ith a 1M resistor in order to create a low-pass filter with a cutoff frequency

    of approximately 300 Hz. With all of these basic hardware filter realizations, the effective frequency range of the

    filtered output signal is between 40 300 Hz.

    For stability, 0.1 uF decoupling capacitors were added in parallel to the Vcc and Gnd nodes of the op-amp. And to

    protect the ADC pin on the MCU, protective diodes and a 10k series resistor were added to the circuit.

    The amplifier circuitry was thoroughly tested after it was built on the breadboard. A function generator was

  • 7/27/2019 Digital Stethoscope - ECE 4760

    5/14

    8/12/13 Digital Stethoscope - ECE 4760

    people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/ 5/14

    connected to the input of the circuit and frequencies were manually swept to test and verify the circuits frequency

    response. The following table and plot shows the measured frequency response of the microphone circuit:

    Microphone Circuit Frequency Response Results

    Input Frequency (Hz)Input Peak-to-Peak(mV)

    Output Peak-to-Peak(mV)

    Gain (abs) Gain (dB)

    20 2.08 272 130.77 42.33

    50 2.08 272 130.77 42.33

    100 2.08 264 126.92 42.07150 2.08 248 119.23 41.53

    200 2.08 232 111.54 40.95

    250 2.08 216 103.85 40.32

    300 2.08 200 96.15 39.66

    500 2.08 152 73.08 37.28

    1000 2.08 88 42.31 32.53

    Figure 5. Microphone Circuit Frequency Response

    The measured data shows that there is approximately a 3dB drop in gain at the 300 Hz cutoff frequency. This shows

    that the implementation of the low pass filter properly attenuates high frequency signals. After verifying that the

    frequency response of the circuit was as expected, the acoustic sensor was tested by connecting it to the input o

    the bias/amplifier circuit.

    Digital-to-Analog Converter

    In order to output the real-time or recorded audio waveform to a headphone/speaker, a simple digital-to-analog

    converter was implemented in the form of an RC low-pass filter. This circuit averages a pulse-width modulated input

    signal in addition to attenuating high frequency content. Figure 6 shows a schematic of the DAC circuit.

    Figure 6. Digital-to-Analog Circuit for Audio Output

  • 7/27/2019 Digital Stethoscope - ECE 4760

    6/14

    8/12/13 Digital Stethoscope - ECE 4760

    people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/ 6/14

    The RC time constant of the filter was designed to attenuate frequencies higher than approximately 210 Hz. This

    cutoff frequency is below the frequency range of the input signal to the MCU. The circuit was designed this way in

    order to reduce higher frequency noise introduced to the s ignal at the PWM output. A relatively small resistor value

    was chosen for the circuit in order to interface with low input impedance headphones.

    The circuit was tested and validated using the stethoscope sensor and amplifier circuit after the software to capture

    the stethoscope output and generate the PWM signal was developed. The figure be low shows the PWM signal and

    corresponding analog signal captured on an oscilloscope.

    Flash Memory

    A 1MB Flash memory chip was acquired to provide the capacity to store up to 10 cardiac waveforms for future

    playback and analysis. Since the chip requires a supply voltage between 2.7 V and 3.6 V, a power regulator was

    used to convert the 5 V supply powering the rest of the circuit to a stable 3.3 V supply for the memory. The

    microcontroller communicated with the Flash chip through a serial peripheral interface (SPI), with the MCU as the

    master and the Flash chip as the slave device. The SPI bus specifies four logic lines: serial clock (SCLK), master

    output (MOSI), master input (MISO), and slave select (SS). The SCLK, MOSI, and SS lines are outputted by the MCU

    and therefore require level shifting from 5 V to approximately 3.3 V. The MISO line is outputted by the Flash memory

    and does not require any voltage translation to interface with the MCU. This is because the 3.3 V output of the

    memory is within the lower bound to detect an input high voltage on the I/O pin. Figure 7 shows a schematic of the

    flash memory circuit.

    Figure 7. Flash Memory and Voltage Regulator Circuits

    Voltage translation was implemented using simple resistive dividers. The values of the resistors were selected to be

    small in order to reduce the RC time constant of the translation. This was necessary in order to cleanly level shift the

    high frequency clock signal without distortion.

    To test the read functionality of the Flash memory, a short segment of code was written to send a command from the

    microcontroller to read the memory chip manufacturers ID. To test the erase and write functionalities, a sector erase

    followed by a page write command were sent to the chip to store data. A data read command was then issued to

    verify that the contents of the memory were correct.

    Keypad and LCD

    A 16-button keypad and 4-line 20-character wide LCD display were used for the primary user interface of the system.

    The two components were directly connected to I/O pins on the microcontroller and did not require any extra

    hardware circuitry for operation.

  • 7/27/2019 Digital Stethoscope - ECE 4760

    7/14

    8/12/13 Digital Stethoscope - ECE 4760

    people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/ 7/14

    Software Design & Implementation top

    The overall software for the project consisted of embedded code running on the Atmega644 microcontroller and a

    MATLAB visualization tool on a PC.

    Tmega644 Microcontroller

    The microcontroller served as the central system component. The software running on the microcontroller was

    responsible for sampling the stethoscope sensor output, generating a PWM signal for audio playback, adjusting the

    volume of the audio output, storing the acquired data in Flash memory for later playback, and transmitting data to

    the MATLAB visualization tool. Figure 8 shows an overview of the software system architecture.

    Figure 8. System Software High Level Overview

    Signal Acquisition

    The ADC module was used to convert the analog electrical signal from the output of the sensor circuit into a digital

    signal that the microcontroller can process. The voltage reference for the ADC module was set to 5 V. The system

    clock running at 16 MHz was divided by 32 to drive the ADC at a frequency of 500 kHz. The Timer 1 Capture ISR was

    used to sample the ADC at 8 kHz with 8-bit precision. Although the frequency content of most internal body sounds

    are relatively low (< 300 Hz), a higher sampling rate was used to improve the audio quality of the acquired s ignal.

    *Note: the minimum sampling rate needed to reconstruct a 300 Hz signal without aliasing is 600 Hz based on the

    Nyquist sampling theorem. Within the ISR, the sampled data is then scaled based on the current volume settings

    and w ritten to a flash buffer in the MCU if the system is in capture mode.

    PWM Waveform Generation and Serial Data Transfer

    Cardiac waveforms were played in real time and from previous recordings by generating a PWM signal using the

    sampled data from the ADC. A 62.5 kHz PWM output was produced using Timer 2. The magnitude of the output is

    updated within the Timer 1 Capture ISR at the same 8 kHz sampling rate based on the sampled or recorded data. In

    addition to outputting the audio data to headphones/speakers, the data is also transmitted to a MATLAB

    visualization tool via the USART module at 100 Hz. Since the serial transfer task is non-critical, the data is onlywritten to a serial transfer buffer within the Timer 1 ISR. The actual transmission of the data using the USART is

    performed w ithin the main loop based on system and task times updated using the Timer 0 Compare ISR.

    Flash Operations

    http://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/index.html#top
  • 7/27/2019 Digital Stethoscope - ECE 4760

    8/14

    8/12/13 Digital Stethoscope - ECE 4760

    people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/ 8/14

    The software interface with the Flash memory chip utilized the SPI hardware module in the microcontroller. To send a

    command via SPI, the slave select line was first enabled. The desired transmit data was then written to the SPI data

    register, which outputs the clock signal on the SCLK line and shifts the data bits (MSB first) out onto the MOSI line.

    After sending all data bytes, the s lave se lect line was disabled to execute the command in the memory. *Note: SPI

    communication is full-duplex. As each bit is shifted out onto the MOSI line, a new bit is shifted in from the MISO line.

    Because of this, dummy data can be sent from the master in order to receive data from the s lave. The table below

    lists the major Flash commands used to read, erase, and write data to the chip.

    Command Instruction Code Description

    Page Program 0x02 Program up to 256 bytes of data at erased locations

    Read Data 0x03 Read 1 or more bytes of data sequentially

    Read Status Register-1 0x05 Reads the 8-bit status register-1

    Write Enable 0x06 Must be executed before writing or erasing data

    Sector Erase 0x20 Erases a 4KB sector of memory

    Read Manufacturer ID 0x90 Reads the manufacturer ID of the chip

    Chip Erase 0xC7 Erases the entire Flash memory

    Block Erase (64 KB) 0xD8 Erases a 64 KB block of memory

    Flash Commands

    Writing Acquired Data

    In order to minimize SPI communication overhead, captured signal data is first written to a Flash write buffer in the

    Timer 1 ISR. An SPI page program command is only sent after 256 bytes of data have been collected in the buffer.

    Each audio recording is a llocated 64KB of memory, which corresponds to approximately 8 seconds of recording data

    when sampling at 8 kHz. This size was chosen in order to fit all of the data within a s ingle block.

    eading Recorded Data

    In order to playback recorded data, it is necessary to read data from the Flash memory. This is done one page at a

    time using two Flash read buffers in the MCU. The playback data is first initialized by reading two pages of data and

    storing it in the read buffers. The data in the buffers are then output at 8 kHz using the PWM. After a full page o

    data has been output to the headphones, the second buffer is used to continue the operation. When the bufferswitches, a Flash read command is issued to re-populate the original buffer. This process continues until all 64KB o

    data has been read from memory and outputted to the headphones.

    anaging Recording Data

    The digital stethoscope system supports saving up to 10 different waveform recordings. Each recording is ass igned

    an ID between 0 and 9. Each recording is also allocated a separate 64KB block of Flash memory. A special 16-bit

    location in Flash memory is interpreted as a recording status register, which indicates which recordings are valid and

    stored in memory. This is done through a simple one-hot encoding scheme where the recording ID corresponds to

    the bit position in the register. For instance, if bit 3 in the recording register is set to 1, then that means that

    recording 3 is stored in the Flash memory at its specific block address. If the bit value is set to 0, then the recording

    is not stored in memory.

    When initializing the system on power-up, the MCU reads a special signature memory address to identify whether

    the project signature has been written to the chip. The signature indicates that the Flash memory has been properly

    formatted and the data in the recording status register is valid. If the signature is not found, the chip is erased and

    the recording status register is programmed to have a value of 0x0000, which indicates that no recording data is

    stored on the chip.

    Keypad and LCD Operation

    The primary user interface for controlling the microcontroller consisted of the keypad and the LCD display. The

    keypad was used to toggle between several modes of operation to record cardiac waveforms, play them back, and

    adjust the volume settings. The LCD was used to display instructions and visually see that the system was setting

    parameters and switching between operating modes as expected. The microcontroller software was thus

    responsible for the operation of these two hardware components, periodically checking the state of the keypad, de-

    bouncing button presses, and updating the messages displayed on the LCD.

  • 7/27/2019 Digital Stethoscope - ECE 4760

    9/14

    8/12/13 Digital Stethoscope - ECE 4760

    people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/ 9/14

    When a button on the keypad is pressed, two of the eight pins get shorted. A piece of code that collected the values

    of each of the pins in a single number and mapped the result to a number between 1 and 16 was provided. This

    value corresponded to index of the button in the 4x4 array of buttons. For example, button A was mapped to a

    numerical value of 4. This value (butnum) was used in the de-bounce state machine for the system (see Figure 3). I

    the value was anything other than zero, the system would jump from the default RELEASED_STATE to the

    MAYBE_PUSH_STATE. If the same button is still pressed (and the value of butnum is not zero), the system jumps to

    the PUSHED_STATE. If the same button is released, the system goes to the MAYBE_REL_STATE before jumping to the

    RELEASED_STATE and setting a tag to indicate that a button was pressed and released. The button verication and

    de-bounce code is executed every 30 ms. The value of butnum was mapped to the actual numerical values 0-9 if one

    of those buttons was pressed. The buttons corresponding to the asterisk (*), pound symbol (#), and the letters

    were mapped to 11-15 in that respective order. These mappings were stored in the global variable keynumber and

    were used to evaluate button actions. Figure 9 below demonstrates the state machine used to de-bounce a button

    press.

    Figure 9. Keypad De-bounce State Machine

    The system used several states to differentiate between when a user could specify a setting and when an input

    wouldn't be registered. In the default state, the system sampled the stethoscope sensor output, outputted the PWM

    audio signal, and transmitted the data to the PC in real time. Numbers were used to enter various modes o

    operation. The asterisk and pound keys served the purpose of clearing or entering previously pressed characters.

    When a user selected 1 and pressed the pound symbol, the system would enter a recording mode. The user would

    enter A to start a recording and B to end it. After a recording is stopped, the user was given the option to play

    the recording, delete it, or store the sample to Flash memory for later playback. A confirmation message is then

    displayed based the user input and the system will return to the default state when D is entered. The user could

    play a previously recorded sample by entering 2 to enter playback mode when the system was in the default state.

    The user could then press the number corresponding to one of the saved waveforms to play the previously recorded

    sample. The volume could be adjusted by entering 3 in the default state to enter a volume selection mode and

    entering a number in the range between 0 and 4. The lowest setting disables the audio output entirely while the

    highest one double the amplitude of the voltage sw ings from their default values to produce a sound that is twice as

    loud as the default one. The current volume setting and the number of waveforms stored could be displayed on the

    LCD screen by se lecting 4 in the default mode. The table below conveys the button functions in each mode.

    Mode Button Function

    Default 1 Enter Pre-Recording Mode

    2 Enter Pre-Playback Mode

    3 Enter Volume Select Mode

    4 Enter Settings

    5 Enter Flash Utility Mode

  • 7/27/2019 Digital Stethoscope - ECE 4760

    10/14

    8/12/13 Digital Stethoscope - ECE 4760

    people.ece.cornel l.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/ 10/14

    Results top

    Overall, the digital stethoscope system performed we ll in terms of audio quality, heart rate detection accuracy, and

    meeting real-time deadlines. The system successfully captured the heartbeat of various volunteers. The sound of the

    heartbeat was easily heard using standard headphones, indicating that the PWM audio output of the captured

    waveform was not significantly distorted by ambient noise. However, the audio became much noisier when a

    waveform was being recorded to the Flash memory and being subsequently played back.

    The MATLAB user interface also met expectations, displaying cardiac waveforms in real time and when a stored

    waveform was played back as illustrated in the figure below. Several people were tested using the stethoscope to

    determine the accuracy of the BPM measurement algorithm. After obtaining a measurement using the digital

    stethoscope, the volunteers also determined their heart rate by holding two fingers to their necks and recording the

    number of seconds required for 10 heart beats. The results are included in the table below. The largest error

    between the two measurement techniques for the samples taken was around 6%, suggesting that the BPM

    measurements displayed on the plot were fairly accurate. It should be noted that there is a degree of uncertainty in

    measuring heart rate using the method w ith two fingers.

    Pre-Recording A Start Recording

    D Return to Default Mode

    Post-Recording A Delete Saved Waveform

    B Play Saved Waveform

    Delete Any Return to Default Mode

    Pre-Playback 0-9 Play Saved Waveform

    Post-Playback A Delete Saved Waveform

    B Play Saved Waveform

    D Return to Default Mode

    Volume Select 0-9 Set Volume Level

    Settings D Return to Default Mode

    Flash Utility A Erase Flash Memory

    D Return to Default Mode

    Keypad Button Functions

    MATLAB User Interface

    A MATLAB program was developed to read data from the microcontroller through a serial connection with a baud rate

    of 9600 bits per second. The connection port was periodically queried and read. The received data was then

    processed and displayed on a MATLAB plot in real time. The program was also designed to calculate the beats-per-

    minute (BPM) of a cardiac waveform in real time as well. An average of a cardiac waveform was taken to filter out

    ambient noise and detect when voltage spikes from heartbeats in a clean fashion. The average calculation was non-

    linear, intended to increase drastically at the start of a heartbeat and gradually decay until the next one. The first

    and second derivatives of the average were taken to determine where those steep spikes occur and thus, record

    the start time for each heartbeat. By calculating the difference between consecutive start times, it was possible to

    measure the time for a single heartbeat and to calculate BPM.

    http://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/index.html#top
  • 7/27/2019 Digital Stethoscope - ECE 4760

    11/14

  • 7/27/2019 Digital Stethoscope - ECE 4760

    12/14

  • 7/27/2019 Digital Stethoscope - ECE 4760

    13/14

    8/12/13 Digital Stethoscope - ECE 4760

    people.ece.cornel l.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/ 13/14

    Datasheets

    ATmega644

    Winbound 8M-Bit SPIFlash

    Microchip Operational Amplifier (MCP6231)

    Microphone (Panasonic ABA5000CE6)

    Voltage Regulators (Texas Instruments

    References

    Digital Stethoscope

    TI Digital Stethoscope Implementation

    UCSB ECE 2C Lab #1 Microphone Circuit

    Electret Condenser Microphone Basics

    Bruce Land's MATLAB User Interface Code

    References top

    This section provides links to datasheets, vendor sites, and external references used for the project.

    Header files

    lab5_stethoscope.h (6KB) contains global variables, definitions, and function prototypes

    flash.h (2KB) contains Flash function prototypes

    uart.h (1KB) contains UART function prototypes

    lcd_lib.h (5KB) contains LCD display prototypes

    Download all files: software.zip (20KB)

    B. Bill of Materials

    Component Part # Quantity Vendor Cost

    3.5mm Cable CP-2206-ND 1 Digikey $3.09

    Condenser Microphone P9955-ND 1 Digikey $2.22

    Flash Memory (1 MB) W25Q80BVDAIG-ND 1 Digikey $1.39

    Operational Amplifier MCP6231-E/P-ND 1 Digikey $0.38

    Stethoscope AH-DST0201 1 Allheart.com $6.98

    Plastic Box (Clear Blue) N/A 1 Michael's $3.00

    Max233CPP N/A 1 ECE 4760 Lab $7.00

    ATmega644 N/A 1 ECE 4760 Lab $6.00Keypad N/A 1 ECE 4760 Lab $6.00

    Custom PC Board N/A 1 ECE 4760 Lab $4.00

    Solder board (6 inch) N/A 1 ECE 4760 Lab $2.50

    Small solder board (2 inch) N/A 1 ECE 4760 Lab $1.00

    Voltage Regulator (3.3V) N/A 1 ECE 4760 Lab $0.00

    Resistors N/A Many ECE 4760 Lab $0.00

    Capacitors N/A Many ECE 4760 Lab $0.00

    Diodes N/A 2 ECE 4760 Lab $0.00

    LCD Display N/A 1 Previously Owned $0.00

    Switch N/A 1 Previously Owned $0.00

    Voltage Regulator (5V) N/A 1 Previously Owned $0.00

    9V Battery N/A 1 Previously Owned $0.00

    Total: $43.56

    C. Tasks

    Michael Wu Garen Der-Khachadourian

    Hardware wiring MATLAB user interface

    Stethoscope capture, record, playback code Keypad/LCD Display code

    Flash memory programming Webpage formatting

    The other aspects of the project were completed as a group. These tasks include: building the protoboard,integrating the hardware into the box, and testing the hardware and software components.

    http://www.ti.com/lit/ds/symlink/lp2950-n.pdfhttp://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/software/software.ziphttp://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/software/lcd_lib.hhttp://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/software/uart.hhttp://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/software/flash.hhttp://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/software/lab5_stethoscope.hhttp://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/index.html#tophttps://courses.cit.cornell.edu/bionb330/matlab_sims/hebb2.mhttp://www.schusterusa.com/pdfs/announcepdfs/puiaudio/whitepapers/pui_electretcondensermicbasics.pdfhttp://www.ece.ucsb.edu/yuegroup/Teaching/ECE2C/Lab/Lab3b_new.pdfhttp://www.ti.com/lit/an/sprab38a/sprab38a.pdfhttp://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2004/bcr5/index.htmhttp://www.ti.com/lit/ds/symlink/lp2950-n.pdfhttp://industrial.panasonic.com/www-data/pdf/ABA5000/ABA5000CE6.pdfhttp://ww1.microchip.com/downloads/en/DeviceDoc/21881e.pdfhttp://www.winbond.com/NR/rdonlyres/4D2BF674-7427-4FC8-AEF0-1A534DF74F16/0/W25Q80BV.pdfhttp://www.atmel.com/Images/doc2593.pdf
  • 7/27/2019 Digital Stethoscope - ECE 4760

    14/14

    8/12/13 Digital Stethoscope - ECE 4760

    LP2950,LP2951)

    3.5 mm Audio Cable (Tensility CA-2206)

    endor Sites

    Digikey

    Allheart

    Plotting the Serial Port Data with MATLAB

    Acknowledgements top

    This project would not have been possible without the help of several key individuals. Thanks go to Bruce Land, who

    was an indispens ible resource that provided valuable advice and feedback. Another thanks goes out to the teaching

    assistants of ECE 4760, especiall Joe Montanino and Pavel Vasilev, for their constant support. Several volunteers

    facilitated the testing process and their help was appreciated. These volunteers include: Stephanie Stoughton,

    Stephen Wu, Chris Piccoli, and Suryansh Agarwal.

    2012 Michael Wu & Garen De r-Khachadou rianStyle adapted from A. Papamarcos

    Layout 2010 C ornell University

    http://people.ece.cornell.edu/land/courses/ece4760/FinalProjects/s2012/myw9_gdd9/myw9_gdd9/index.html#tophttp://mycola.info/2011/04/02/plotting-the-serial-port-data-with-matlabhttp://www.allheart.com/http://www.digikey.com/http://www.tensility.com/pdffiles/CA-2206.pdfhttp://www.ti.com/lit/ds/symlink/lp2950-n.pdf