Difference between revisions of "Projects:2013S2-U1 Wireless Electrocardiography System"

From Projects
Jump to: navigation, search
(Outline of Individual Work)
(Stage 3:Synchronisation and Visualisation)
 
(36 intermediate revisions by 3 users not shown)
Line 6: Line 6:
  
 
'''System Overview'''
 
'''System Overview'''
 +
 +
[[File:Overview.png]]
 +
  
 
The prototype we delivered need be able to perform several tasks: (1) Sensing and Data Acquisition: acquire the voltage signal generated by the test subject from textile electrodes, filter out the unwanted noise, amplify the signal to a manageable level, convert this analog signal to digital signal and connect to Bluetooth device for data transferring ; (2) Communication: package the data which is acquired from Analog Front End and transmit it to Android device wirelessly via Bluetooth; (3) Synchronisation and Visualisation: extract the received data package, create patient file and received data in database, plot real-time ECG waveform and review the patient history in log-file.
 
The prototype we delivered need be able to perform several tasks: (1) Sensing and Data Acquisition: acquire the voltage signal generated by the test subject from textile electrodes, filter out the unwanted noise, amplify the signal to a manageable level, convert this analog signal to digital signal and connect to Bluetooth device for data transferring ; (2) Communication: package the data which is acquired from Analog Front End and transmit it to Android device wirelessly via Bluetooth; (3) Synchronisation and Visualisation: extract the received data package, create patient file and received data in database, plot real-time ECG waveform and review the patient history in log-file.
  
 
=='''Outline of Individual Work'''==
 
=='''Outline of Individual Work'''==
'''Sensing and Data Acquisition'''
+
==== '''Stage1:Sensing and Data Acquisition''' ====
 +
*'''Textile Electrode'''
 +
A textile electrode is produced to minimise any motion inconvenience for the patients that might have caused during the sensing procedure. Research on the materials of the textile electrodes has been carried out, in order to achieve a comfortable, flexible and compatible to small to medium sized patients.We have agreed to use the non-conductive elastic clothing as the material of the textile electrodes, due to its elastic flexibility provided, and the compatibility to cut through hole to the clothing without destroying the whole clothing.
  
acquire the voltage signal generated by the test subject from textile electrodes, filter out the unwanted noise, amplify the signal to a manageable level, convert this analog signal to digital signal and connect to Bluetooth device for data transferring
+
*'''Analogue Front End Microcontroller'''
 +
The chosen microcontroller is the ADS1293. ADS1293 features its own Evaluation Module, ADS1293EVM which will be used in this project. ADS1293EVM evaluation module helps designers evaluate the operation and performance of the ADS1293 Analogue Front End for ECG Monitoring.
  
'''Communication'''
+
*'''Serial Peripheral Interface'''
 +
ADS1293EVM will be operated in the slave mode, and will be set up by the master device. Microcontroller used as the master device is the Arduino Xadow Main board, and Xadow Breakout board. Serial Peripheral Interface is a synchronous serial data link, which is used for short distance, single master communication.
  
 +
===='''Stage 2: Communication''' ====
 
In this stage the data which is acquired from Analog Front End will be packaged and transmitted to Android device wirelessly via Bluetooth
 
In this stage the data which is acquired from Analog Front End will be packaged and transmitted to Android device wirelessly via Bluetooth
  
'''Hardware'''
+
*'''Hardware'''
  
 
The communication part consists two parts: the micro-controller and the Bluetooth device. The hardware for the communication part is Xadow, which is an Arduino compatible board.The most signification feature of the Xadow boards is that it can be connected to different modules so
 
The communication part consists two parts: the micro-controller and the Bluetooth device. The hardware for the communication part is Xadow, which is an Arduino compatible board.The most signification feature of the Xadow boards is that it can be connected to different modules so
 
that it has multiple functions such as the BLE slave and the breakout board, which make the synchronization become more convenient. The breakout board works like a bridge between the analogue front-end and the microcontroller because it enables the microcontroller to grab digital data from the ADC board. The cable used to connect the Xadow boards is supple and bendable so the connection is simple and not easy to be damaged. The memory size of the mainboard is: 32K flash to store the program, 2.5K SRAM to store the data processed during running time such as register and stack, and 1K EEPROM to store the setting values. As an Arduino compatible boards, it has its specific develop tool – Arduino. This software can be programmed by using C or C++ languages so it is easy for developers to use.
 
that it has multiple functions such as the BLE slave and the breakout board, which make the synchronization become more convenient. The breakout board works like a bridge between the analogue front-end and the microcontroller because it enables the microcontroller to grab digital data from the ADC board. The cable used to connect the Xadow boards is supple and bendable so the connection is simple and not easy to be damaged. The memory size of the mainboard is: 32K flash to store the program, 2.5K SRAM to store the data processed during running time such as register and stack, and 1K EEPROM to store the setting values. As an Arduino compatible boards, it has its specific develop tool – Arduino. This software can be programmed by using C or C++ languages so it is easy for developers to use.
  
'''Programming structure'''
+
*'''Programming Structure'''
  
 
The first thing is to set up all the devices and this will be written in the setup() (so does the code for analogue front end controlling). After finishing the synchronization with ADC board, an empty array with fixed length will be constructed to store the ECG data temporarily. At the endof the array, a time stamp will be inserted for synchronization with the tablet. The array will be added in to a multiple buffer and wait for transmitting and the array in the end of the buffer will be transmitted. Considering the limit of the memory size, the array in the end will be cleared after sending and the temporary array will start loading new ECG data again.
 
The first thing is to set up all the devices and this will be written in the setup() (so does the code for analogue front end controlling). After finishing the synchronization with ADC board, an empty array with fixed length will be constructed to store the ECG data temporarily. At the endof the array, a time stamp will be inserted for synchronization with the tablet. The array will be added in to a multiple buffer and wait for transmitting and the array in the end of the buffer will be transmitted. Considering the limit of the memory size, the array in the end will be cleared after sending and the temporary array will start loading new ECG data again.
  
'''structure of array'''
+
*'''Structure of Array'''
  
 
Each ECG point will bethree bytes long and there are three channels totally, so there would be 9 bytes for each set of samples. 4 sets are packaged into an array in the coding and the final length of the array will be 40 bytes long after inserting the 4 bytes long time stamp. The time stamp is obtained by the millis() and the return value will be an unsigned long data ,which is 4 bytes long, but the Bluetooth can only send single byte each time, so the time stamp needs to be divided in to 4 single bytes before inserted.
 
Each ECG point will bethree bytes long and there are three channels totally, so there would be 9 bytes for each set of samples. 4 sets are packaged into an array in the coding and the final length of the array will be 40 bytes long after inserting the 4 bytes long time stamp. The time stamp is obtained by the millis() and the return value will be an unsigned long data ,which is 4 bytes long, but the Bluetooth can only send single byte each time, so the time stamp needs to be divided in to 4 single bytes before inserted.
  
'''Queue Buffer'''
+
*'''Queue Buffer'''
  
 
The multiple-buffer used here is a linked list (or queue). The queue is composed of several nodes and the nodes will be used to store the array. There are two pointers for the queue: *head and *tail. Head is the node for storing the next array while Tail will points to the array to be transmitted next. The Nodes have two pointers as well: *array refers to the array and *next links to next node. The buffer follows the First In First Out (FIFO) rule, and the board will free the node after sent to get enough memory space for new data. The number of the nodes is determined by the available SRAM size.
 
The multiple-buffer used here is a linked list (or queue). The queue is composed of several nodes and the nodes will be used to store the array. There are two pointers for the queue: *head and *tail. Head is the node for storing the next array while Tail will points to the array to be transmitted next. The Nodes have two pointers as well: *array refers to the array and *next links to next node. The buffer follows the First In First Out (FIFO) rule, and the board will free the node after sent to get enough memory space for new data. The number of the nodes is determined by the available SRAM size.
 +
===='''Stage 3:Synchronisation and Visualisation''' ====
 +
*'''Hardware'''
 +
The tablet Nexus 7 from previous team is used in this project, which is based on Android system Version 4.4.2. It contains 16GB internal storage,1GB RAM and 4.325Ah for the battery capacity(up to 10 hours). Large data storage and battery capacity can perform long time patient monitoring and data storing.
 +
*'''Software'''
 +
The development environment used for this application design is Eclipse (Version 4.3) + ADT (Android Developer Tools) plug in, written in Java language and the layout and for- mat designed by XML (Extensible Markup Language). Eclipse is an integrated development environment (IDE). It contains a base workspace and an extensible plug-in system for customising the environment. In additional, a serial port monitoring tool, namely AccessPort, is used to simulate a Bluetooth serial port profile (SPP) communication, in order to test data- storing and functions of the application.
  
 +
*'''Application Structure'''
 +
**'''Bluetooth Communication'''
 +
[[File:Blue.png]]
  
'''Synchronisation and Visualisation'''
+
The Android platform includes support for the Bluetooth network stack, which allows a device to wirelessly exchange data with other Bluetooth devices. The package android. bluetooth provides all the necessary APIs that make application wirelessly connect to the other Bluetooth device, enabling point-to-point wireless feature.
 +
When the user open the Bluetooth, using the BluetoothAdapter, the start discovery method will be called. Device discovery is a scanning procedure that searches the local area for Bluetooth available de- vices. With the help of BroadcastReveiver, the discovery finished and available device found methods will be returned. When the specific available device is selected, it will create an RFCOMM BluetoothSocket ready to start a secure outgoing connection to this remote device.
  
The tablet Nexus 7 from previous team is used in this project, which is based on Android system Version 4.4.2. It contains 16GB internal storage,1GB RAM and 4.325Ah for the battery capacity(up to 10 hours). Large data storage and battery capacity can perform long time patient monitoring and data storing.
+
*'''User File'''
 +
[[File:Patient.png]]
 +
 
 +
The figure shows the frame of the user file activity, which is used to create patient file includes name, birthday and gender and store the information into the table named as profiles in the SQLite Database. With the support of android.database.sqlite package in this application, the SQLiteOpenHelper class helps user create database, and the SQLiteDatabase class is the base class for accessing database[8]. By clicking the start button, the patient file will be created and new test will be processed in the real-time plotting activity. This activity was designed by previous team, for testing and verifying data structure purpose, age-calculating was be added inside. By calculating the difference between current time and the input birthday from user, it will auto display the age in the third line. This activity also has been modified that enable to detect the same patient detail that stored in profiles and displays the alert dialog if wants to start a new test.
 +
 
 +
*'''Real-time Plotting'''
 +
This activity is the major component of this ECG application. After the new test option is selected, this activity will perform three key tasks: Bluetooth data extraction, data storing and visualisation.
 +
**'''Bluetooth data extraction'''
 +
When the incoming data stream is detected by Bluetooth socket, a buffer, size of 60 bytes, will start to receive the data package into the array as ”unpacking”. After the buffer is loaded, before the data package be extracted into three separate dynamic ArrayList that represent three channels of ECG waveform, each three bytes per datum will be converted into one integer named as result and then put into each channel respectively. The code below illustrates the method that accomplish these two procedures, the parameter tmp refers the buffer with size of 60 bytes and len refers to the length of the data from Bluetooth module.
 +
**'''Data storing'''
 +
While the data is continuously extracted in the buffer, function named write(LinkedList<Integer> values) will store the data into dat file, belongs to the file with format of name.birthday.gender.fileindex. dat. After the data is converted into int result, all data stream will be stored in the linkedlist, named values for future review.
 +
**'''Visualisation'''
 +
In this activity, a Timer is set to send the extracted data of three channels to DrawtoView function every 50ms to plot and update the heart beat in the text view widget. The code above shows the plotting procedure of one channel for every 50ms: (1)Create an integer dynamic ArrayList (2) Copy the extracted data of one channel (3)Pass the data that contains max and min value into DrawtoView function in SurfaceView (4) Clear the ArrayList and update the status for the next repetitive action.
 +
 
 +
The packages of android.view and android.graphics provide programmer render 2D drawing graphic onto a Canvas. A SurfaceView is a special implementation of View that creates its own dedicated Surface for the application to directly draw into it. The relationship between SurfaceView and Canvas is that the window is tied to a SurfaceView and asks the canvas to draw onto. When the SurfaceView is initialised, SurfaceHolder can be created by calling getHolder() method once and Canvas can be retrieved with lockCanvas()[13]. After the ini- tialisation, the ECG data contained in three dynamic ArrayLists will be plotted upon the Canvas. As a result of 24 bits resolution and the type of each point that be plotted is integer, the normalisation of value need to be executed before plotting. During the process of Bluetooth data extraction mentioned above, the program will keep track the minimum and maximum values of three channels in the dynamic ArrayLists every 50ms. The data value is actual value subtract the minimum one and value range is maximum subtract the minimum.
 +
**'''Result'''
 +
 
 +
[[File:Plot.png]]
 +
 
 +
=='''Testing'''==
 +
=== Analog Front-End ===
 +
 
 +
=== Android ===
 +
 
 +
===System Testing ===
 +
 
 +
== Team ==
 +
=== Group members ===
 +
* Tze Chan
 +
* Yi Chen
 +
* Zhenyu Tang
 +
 
 +
=== Supervisors ===
 +
* Dr Thomas Kaufmann
 +
* Assoc Prof. Mathias Baumert
 +
* Dr. Said AI-Sarawi

Latest revision as of 02:05, 6 June 2014

Electrocardiography (ECG) is a standard diagnostic tool to investigate the conduction properties of the heart via sensors that are mounted on the body surface. The Wireless Electrocardiogram (ECG) is a medical telemetry instrument used to monitor a patient’s ECG signal while allow the user to remain fully mobile and comfortable. ECG measures small electrical signals from the patient’s chest caused by the heart beating. By using these signals stored in a single device, medical staff can monitor the patients’ well being and predict future heart problems. Using current ECG equipment can be a time-consuming task and changing wires also would introduce bacteria to the patient, further increasing the risk of infection. By using a wireless ECG, the patients will be more comfortable since they are free from unnecessary wires. The device is portable and does not require user interaction. Meanwhile, the visualisation in the Android application provides possible analysis for the hospital staff and the data is automatically synchronised and stored for future review.This project is motivated by the current state of wireless communication technology.

Project Information

This project aims to design and build a low cost electrocardiogram device which involves capturing heart signals via electrodes attached to the chest, amplifying,filtering and digitising them appropriately, and sending the data collected to a synchronised tablet for plotting and analysing. The project is a continuation of 2012 mid-year Final Year Project, where the initial prototype was designed. It consists of the hardware and software for a portable wireless electrocardiogram device, construction of textile electrodes, and a corresponding Android application which, together, displays and records the users heart signal. The aim of the thesis is to introduce the android platform and develop a android ECG application that works with the ECG monitoring device. The application will be used for the realisation that ECG data signals can be sent from the analog front end device via bluetooth communication.

System Overview

Overview.png


The prototype we delivered need be able to perform several tasks: (1) Sensing and Data Acquisition: acquire the voltage signal generated by the test subject from textile electrodes, filter out the unwanted noise, amplify the signal to a manageable level, convert this analog signal to digital signal and connect to Bluetooth device for data transferring ; (2) Communication: package the data which is acquired from Analog Front End and transmit it to Android device wirelessly via Bluetooth; (3) Synchronisation and Visualisation: extract the received data package, create patient file and received data in database, plot real-time ECG waveform and review the patient history in log-file.

Outline of Individual Work

Stage1:Sensing and Data Acquisition

  • Textile Electrode

A textile electrode is produced to minimise any motion inconvenience for the patients that might have caused during the sensing procedure. Research on the materials of the textile electrodes has been carried out, in order to achieve a comfortable, flexible and compatible to small to medium sized patients.We have agreed to use the non-conductive elastic clothing as the material of the textile electrodes, due to its elastic flexibility provided, and the compatibility to cut through hole to the clothing without destroying the whole clothing.

  • Analogue Front End Microcontroller

The chosen microcontroller is the ADS1293. ADS1293 features its own Evaluation Module, ADS1293EVM which will be used in this project. ADS1293EVM evaluation module helps designers evaluate the operation and performance of the ADS1293 Analogue Front End for ECG Monitoring.

  • Serial Peripheral Interface

ADS1293EVM will be operated in the slave mode, and will be set up by the master device. Microcontroller used as the master device is the Arduino Xadow Main board, and Xadow Breakout board. Serial Peripheral Interface is a synchronous serial data link, which is used for short distance, single master communication.

Stage 2: Communication

In this stage the data which is acquired from Analog Front End will be packaged and transmitted to Android device wirelessly via Bluetooth

  • Hardware

The communication part consists two parts: the micro-controller and the Bluetooth device. The hardware for the communication part is Xadow, which is an Arduino compatible board.The most signification feature of the Xadow boards is that it can be connected to different modules so that it has multiple functions such as the BLE slave and the breakout board, which make the synchronization become more convenient. The breakout board works like a bridge between the analogue front-end and the microcontroller because it enables the microcontroller to grab digital data from the ADC board. The cable used to connect the Xadow boards is supple and bendable so the connection is simple and not easy to be damaged. The memory size of the mainboard is: 32K flash to store the program, 2.5K SRAM to store the data processed during running time such as register and stack, and 1K EEPROM to store the setting values. As an Arduino compatible boards, it has its specific develop tool – Arduino. This software can be programmed by using C or C++ languages so it is easy for developers to use.

  • Programming Structure

The first thing is to set up all the devices and this will be written in the setup() (so does the code for analogue front end controlling). After finishing the synchronization with ADC board, an empty array with fixed length will be constructed to store the ECG data temporarily. At the endof the array, a time stamp will be inserted for synchronization with the tablet. The array will be added in to a multiple buffer and wait for transmitting and the array in the end of the buffer will be transmitted. Considering the limit of the memory size, the array in the end will be cleared after sending and the temporary array will start loading new ECG data again.

  • Structure of Array

Each ECG point will bethree bytes long and there are three channels totally, so there would be 9 bytes for each set of samples. 4 sets are packaged into an array in the coding and the final length of the array will be 40 bytes long after inserting the 4 bytes long time stamp. The time stamp is obtained by the millis() and the return value will be an unsigned long data ,which is 4 bytes long, but the Bluetooth can only send single byte each time, so the time stamp needs to be divided in to 4 single bytes before inserted.

  • Queue Buffer

The multiple-buffer used here is a linked list (or queue). The queue is composed of several nodes and the nodes will be used to store the array. There are two pointers for the queue: *head and *tail. Head is the node for storing the next array while Tail will points to the array to be transmitted next. The Nodes have two pointers as well: *array refers to the array and *next links to next node. The buffer follows the First In First Out (FIFO) rule, and the board will free the node after sent to get enough memory space for new data. The number of the nodes is determined by the available SRAM size.

Stage 3:Synchronisation and Visualisation

  • Hardware

The tablet Nexus 7 from previous team is used in this project, which is based on Android system Version 4.4.2. It contains 16GB internal storage,1GB RAM and 4.325Ah for the battery capacity(up to 10 hours). Large data storage and battery capacity can perform long time patient monitoring and data storing.

  • Software

The development environment used for this application design is Eclipse (Version 4.3) + ADT (Android Developer Tools) plug in, written in Java language and the layout and for- mat designed by XML (Extensible Markup Language). Eclipse is an integrated development environment (IDE). It contains a base workspace and an extensible plug-in system for customising the environment. In additional, a serial port monitoring tool, namely AccessPort, is used to simulate a Bluetooth serial port profile (SPP) communication, in order to test data- storing and functions of the application.

  • Application Structure
    • Bluetooth Communication

Blue.png

The Android platform includes support for the Bluetooth network stack, which allows a device to wirelessly exchange data with other Bluetooth devices. The package android. bluetooth provides all the necessary APIs that make application wirelessly connect to the other Bluetooth device, enabling point-to-point wireless feature. When the user open the Bluetooth, using the BluetoothAdapter, the start discovery method will be called. Device discovery is a scanning procedure that searches the local area for Bluetooth available de- vices. With the help of BroadcastReveiver, the discovery finished and available device found methods will be returned. When the specific available device is selected, it will create an RFCOMM BluetoothSocket ready to start a secure outgoing connection to this remote device.

  • User File

Patient.png

The figure shows the frame of the user file activity, which is used to create patient file includes name, birthday and gender and store the information into the table named as profiles in the SQLite Database. With the support of android.database.sqlite package in this application, the SQLiteOpenHelper class helps user create database, and the SQLiteDatabase class is the base class for accessing database[8]. By clicking the start button, the patient file will be created and new test will be processed in the real-time plotting activity. This activity was designed by previous team, for testing and verifying data structure purpose, age-calculating was be added inside. By calculating the difference between current time and the input birthday from user, it will auto display the age in the third line. This activity also has been modified that enable to detect the same patient detail that stored in profiles and displays the alert dialog if wants to start a new test.

  • Real-time Plotting

This activity is the major component of this ECG application. After the new test option is selected, this activity will perform three key tasks: Bluetooth data extraction, data storing and visualisation.

    • Bluetooth data extraction

When the incoming data stream is detected by Bluetooth socket, a buffer, size of 60 bytes, will start to receive the data package into the array as ”unpacking”. After the buffer is loaded, before the data package be extracted into three separate dynamic ArrayList that represent three channels of ECG waveform, each three bytes per datum will be converted into one integer named as result and then put into each channel respectively. The code below illustrates the method that accomplish these two procedures, the parameter tmp refers the buffer with size of 60 bytes and len refers to the length of the data from Bluetooth module.

    • Data storing

While the data is continuously extracted in the buffer, function named write(LinkedList<Integer> values) will store the data into dat file, belongs to the file with format of name.birthday.gender.fileindex. dat. After the data is converted into int result, all data stream will be stored in the linkedlist, named values for future review.

    • Visualisation

In this activity, a Timer is set to send the extracted data of three channels to DrawtoView function every 50ms to plot and update the heart beat in the text view widget. The code above shows the plotting procedure of one channel for every 50ms: (1)Create an integer dynamic ArrayList (2) Copy the extracted data of one channel (3)Pass the data that contains max and min value into DrawtoView function in SurfaceView (4) Clear the ArrayList and update the status for the next repetitive action.

The packages of android.view and android.graphics provide programmer render 2D drawing graphic onto a Canvas. A SurfaceView is a special implementation of View that creates its own dedicated Surface for the application to directly draw into it. The relationship between SurfaceView and Canvas is that the window is tied to a SurfaceView and asks the canvas to draw onto. When the SurfaceView is initialised, SurfaceHolder can be created by calling getHolder() method once and Canvas can be retrieved with lockCanvas()[13]. After the ini- tialisation, the ECG data contained in three dynamic ArrayLists will be plotted upon the Canvas. As a result of 24 bits resolution and the type of each point that be plotted is integer, the normalisation of value need to be executed before plotting. During the process of Bluetooth data extraction mentioned above, the program will keep track the minimum and maximum values of three channels in the dynamic ArrayLists every 50ms. The data value is actual value subtract the minimum one and value range is maximum subtract the minimum.

    • Result

Plot.png

Testing

Analog Front-End

Android

System Testing

Team

Group members

  • Tze Chan
  • Yi Chen
  • Zhenyu Tang

Supervisors

  • Dr Thomas Kaufmann
  • Assoc Prof. Mathias Baumert
  • Dr. Said AI-Sarawi