OpenHolter project: D.I.Y. Electrocardiography using Arduino and Django

OpenHolter project: D.I.Y. Electrocardiography using Arduino and Django

943620c3bc4056a40ce132690f1d9ac1?s=128

Roberto Rosario

April 05, 2017
Tweet

Transcript

  1. The OpenHolter Project: D.I.Y. Cardiometry with Arduino and Django. Roberto

    Rosario robertorosario.com
  2. Who am I?

  3. Who am I? Hint: Not him.

  4. Who am I?

  5. Who am I?

  6. Who am I?

  7. DISCLAIMER I’m not a doctor or a medical practitioner. This

    talk is about my personal experiences and covers my basic understanding about some topics using Internet sources. I share this as an introduction of these topics only. This talk is not meant to be a scientifically accurate document, do not use it or reference it as such. There many things in this talk that can be and should have been made differently/better. The device shown in this talk is not meant or claims to diagnose or cure heart diseases or conditions. I’m not endorsing that you build this device. The material in this talk doesn’t substitute a visit to your doctor or the years of study they endure to become doctors or the years of experience they endure to become experts. If you decide use the information shown in this talk or build the device shown in this talk, you do so at your own risk and assume any and all consequences of such decision, relieving me of any and all liabilities.
  8. What is Cardiometry? Cardio = Heart Metry = Measurement

  9. What is Electro Cardiometry? Electro = Electricity Cardio = Heart

    Metry = Measurement
  10. What is an EKG (or ECG) Acronym: Electro Cardio Gram

    Electric Heart Diagram
  11. Sample EKG. Wikipedia, Public Domain

  12. Cardiac pacemaker. Wikipedia, CC BY-SA 2.5

  13. Cardiac pacemaker. Wikipedia, CC BY-SA 3.0

  14. ECG principle. Wikipedia, CC by 3.0

  15. Sinus Rhythm. Wikipedia, Public domain

  16. Sample EKG. Wikipedia, Public Domain

  17. EKG leads. Wikipedia, Public Domain

  18. Precordial leads. Wikipedia, Public Domain

  19. Limb leads. Wikipedia, Public Domain

  20. Limb leads. Wikipedia, Public Domain

  21. Limb leads. Wikipedia, Public Domain

  22. Sinus Rhythm. Wikipedia, Public domain

  23. Sample EKG. Wikipedia, Public Domain

  24. Vintage EKG machine. Wikipedia, Public Domain

  25. Modern EKG machine. Wikipedia, CC by 3.0

  26. What is a Holter? EKG + Time EKG Histogram

  27. Holter. Wikipedia GNU Free Documentation License

  28. Holter. Wikipedia GNU Free Documentation License

  29. Holter. Wikipedia GNU Free Documentation License

  30. Canine Holter. Wikipedia, Public Domain.

  31. Holter. Wikipedia GNU Free Documentation License

  32. Why I decided to do this?

  33. Queue flashback!

  34. None
  35. None
  36. None
  37. None
  38. None
  39. None
  40. None
  41. Problems • An EKG is just a snapshot of your

    heart at a specific moment. • A moment when you might not have symptoms. • Monitoring your heart requires a Holter. • You need an appointment and referral for a Holter study. • Holters fail. You have to start all over again. • Holters only work for 24 hours.
  42. Realisation • An EKG is ADC sampling. • Holter is

    an EKG with storage and battery. Or a data logger. • I had all the knowledge to build an Arduino based data logger. • I could work on it 1 hour a day during my recovery.
  43. None
  44. None
  45. None
  46. Challenges • Use off the shelves parts only. Orderwise known

    as “stuff-I-could-get-on-eBay” strategy. • Cheap. • Simple. • Use standard medical cables and electrodes. • Modular or breakout boards.
  47. Block diagram MCU Bio Interface RTC Storage Graphical User Interface

    Power Management
  48. None
  49. Block diagram MCU Bio Interface RTC Storage Graphical User Interface

    Power Management
  50. Block diagram MCU Bio Interface RTC Storage Graphical User Interface

    Power Management
  51. Bio Interface - Needs • No voltage but differential voltage

    reading • Signal amplification • Adaptive signal filtering • Analog to digital conversion
  52. Bio Interface - Analog Devices AD8232 • $10-$20 USD •

    Built-in voltage comparators • Built-in amplifier • Built-in filtering • Power management • Cons: No ADC
  53. Block diagram MCU Bio Interface RTC Storage Graphical User Interface

    Power Management
  54. Real Time Clock - Needs • Small • Battery or

    SuperCap backed up • Easy interface
  55. Real Time Clock - Dallas DS3231 • $1 USD •

    I2C Interface • Unlike DS1302 and DS1307, has temperature compensated crystal and crystal oscillator • Has battery input and powerless timekeeping
  56. Block diagram MCU Bio Interface RTC Storage Graphical User Interface

    Power Management
  57. Microcontroller unit - Needs • Low power • Analog to

    digital interface • Faster than bio interface sampling rate
  58. Microcontroller unit - Arduino Nano • Clones at $4 USD

    • Atmel Atmega 328 at 16 MHz • Analog and digital pins • 32 KB Flash (minus 2KB bootloader) • I2C & SPI communications • UART TTL to USB
  59. Block diagram MCU Bio Interface RTC Storage Graphical User Interface

    Power Management
  60. Power management - Needs • 5 volt output • High

    size and weight to power ratio • Low heat
  61. Power management - Custom • GTL 18650 5300mAh Lithium Ion

    ($2 USD) • Lithium Ion charger module w/ output pins ($0.35 USD) • 3.7v to 5v voltage inverter ($0.50 USD)
  62. Block diagram MCU Bio Interface RTC Storage Graphical User Interface

    Power Management
  63. Graphical User Interface - Needs • Small • Low power

    or low energy mode • Easy to interface
  64. Graphical User Interface - Solomon Systech SD1306 • $5 USD

    • Multiple communication modes including I2C • OLED • Visibility • Pixel based • 2 x Push buttons
  65. Block diagram MCU Bio Interface RTC Storage Graphical User Interface

    Power Management
  66. Storage - Needs • Fast • Detachable • Computer interface

    compatible
  67. Storage - SDCard & module • $3 USD (card) +

    $1 USD (reader) • Cons: Fast modes need license. • SPI bus mode. This bus type supports only a 3.3-volt interface. This is the only bus type that does not require a host license. • 5V to 3V converter • 5V to 3V level converter
  68. Communications SPI I2C or I2C

  69. What is SPI The Serial Peripheral Interface bus (SPI) is

    a synchronous serial communication interface specification used for short distance communication, primarily in embedded systems. The interface was developed by Motorola in the late eighties and has become a de facto standard. Typical applications include Secure Digital cards and liquid crystal displays.
  70. What is SPI SPI devices communicate in full duplex mode

    using a master-slave architecture with a single master.
  71. What is I2C Short for Inter-IC, a type of bus

    designed by Philips Semiconductors in the early 1980s. Is used to connect integrated circuits (ICs).
  72. What is I2C I2C is a multi-master bus, which means

    that multiple chips can be connected to the same bus and each one can act as a master by initiating a data transfer.
  73. Block diagram MCU Bio Interface RTC Storage Graphical User Interface

    Power Management
  74. Block diagram - Communications MCU Bio Interface RTC Storage Graphical

    User Interface Power Management Analog Digital I2C Digital I2C SPI
  75. Organic interface - Connectors • Many types and subtypes ◦

    Snap ◦ Banana ◦ Suction ◦ Clip ◦ Limb clips ◦ Alligator • Easiest to work and with the most pros: Snap
  76. Organic interface - Connectors

  77. Organic interface - Leads • Build your own ◦ Source

    connectors ◦ Good wire gauge • Included leads ◦ Poor in all regards • Lead + electrode ◦ Not feasible
  78. Organic interface - Leads • Professional ones ◦ Best connectors

    ◦ Best wire gauge ◦ Tangle resistant ◦ Labeled ◦ $20 USD ◦ Easy to interface
  79. Organic interface - Electrodes • BIO Protech T815 ◦ Cloth

    ◦ Extended wear (day) ◦ Sweat resistant ◦ Cons: Painful to remove • BIO Protech T716 ◦ Foam ◦ Cons: Not water resistant • $20 USD for bag of 50
  80. Organic interface - Electrodes • BIO Protech T815 ◦ Cloth

    ◦ Extended wear (day) ◦ Sweat resistant ◦ Cons: Painful to remove • BIO Protech T716 ◦ Foam ◦ Cons: Not water resistant
  81. Firmware • Modular • Object oriented • 3 modes of

    operation: ◦ Realtime display ◦ Recording ◦ Serial port output
  82. Libraries - Display: U8g2 • Large hardware support • Support

    fonts • Graphics drawing • Low memory display mode (tiled) • Custom icons • GUI widgets like menus and dialogs • Physical buttons interface and debouncing
  83. Libraries - Storage: Bill Greiman’ SDfatlib • Non monolithic •

    Multiple classes: SdFat, SdBaseFile, SdFile, File, StdioStream, ifstream, ofstream • Mature • Fast • Economic memory usage
  84. Libraries - RTC: Adafruit’s RTClib • Supports several Arduino MCUs

    • Provides access to the square wave pin • Cons: High memory consumption
  85. Challenges and Tricks • Sampling rate reliability • Sample jitter

    • Fast OLED display updates • Heartbeat detection • BPM calculation • Interference filtering • Memory footprint reduction
  86. Challenges and Tricks • Sampling rate reliability • Sample jitter

    • Fast OLED display updates • Heartbeat detection • BPM calculation • Interference filtering • Memory footprint reduction
  87. Sampling rate reliability • Arduino’s crystal is subject to drift

    • Interrupt driven • Improve periodicity of readings • Increase sample rate
  88. Sampling rate reliability - Solution Use the DS3231 square wave

    output pin to trigger Arduino’s hardware interrupt and do sampling in an ISR.
  89. Sampling rate reliability - Solution The enable_interrupt function turns on

    the square wave pin and enables the Arduino hardware interrupt pin to call a callback function on the falling edge of the wave.
  90. Sampling rate reliability - Solution By default, a 4 KHz

    square wave is used, triggering the ISR 4,000 times a second or once every 0.000244141 seconds. This, we’ll call RTC ticks.
  91. Sampling rate reliability - Solution To get 100 samples a

    seconds, how many ticks between each? 1 / 100 / 0.000244141 = every 40.959937086 ticks
  92. Sampling rate reliability - Solution

  93. Sampling rate reliability - Solution

  94. Sampling rate reliability - Solution

  95. Sampling rate reliability - Solution MCU Main loop MCU RTC

    driven ISR ad8232 ad8232_buffer ad8232 interrupt_data_ready RTC
  96. Sampling rate reliability - Solution Consumer Hardware timer Generator Buffer

    (FIFO Stack) Lock Realtime sampling and multithreading on the Arduino.
  97. Recordings format

  98. Recordings format FAT only allows 8.3 filenames.

  99. Recordings format Unique non sequential filenames?

  100. Recordings format Hexadecimal unixtime!

  101. Recordings format

  102. Recordings format Decimal to time_struct, to epoch, to datetime

  103. Recordings format

  104. Recordings format Unique up to a second of difference.

  105. Heartbeat detection A heartbeat is not a spike but a

    wave
  106. Heartbeat detection

  107. Heartbeat detection

  108. Heartbeat detection

  109. Heartbeat detection We are interested in #2

  110. Heartbeat detection

  111. Heartbeat detection

  112. Heartbeat detection

  113. Heartbeat detection

  114. Heartbeat detection

  115. Heartbeat detection

  116. Heartbeat detection

  117. Heartbeat detection

  118. Heartbeat detection

  119. The build

  120. First prototype

  121. First prototype

  122. First prototype

  123. First prototype

  124. First prototype

  125. It’s ALIVE!

  126. None
  127. It’s ALIVE!

  128. First prototype • 3 modes of operation • Pocket size

    • Total cost ~ $30 USD • 4 GB SD Card (vs. 128 MB commercial • 12 days battery life (vs. 1 day commercial) • Rechargeable via USB • Upgradeable via USB
  129. First prototype • Total flash usage: 29KB • Total RAM

    usage: 500 bytes
  130. The App

  131. Creating an EKG journal A chart is good. A journal

    is better.
  132. Creating an EKG journal Recording downloader Packaged program Historic recordings

    Metadata Graphical Tags Share
  133. None
  134. Not just a DMS, but also a platform

  135. Features of interest Mayan Apps Generic templates Metadata Graphical previews

    Tags Email sharing Access Control
  136. App - Requirements • Upload recordings • Preview/render recordings •

    Selection and trim • Conversion to archival version • Metadata, tagging, etc. • Search • Sharing
  137. App

  138. App - Registration

  139. App - Registration

  140. App - Registration

  141. App - Models

  142. App - Models

  143. App - Models

  144. App - Model views

  145. App - Model views

  146. App - Model views

  147. App - Model views

  148. App - Model views

  149. App - Model views

  150. App - Widget, dygraphs

  151. App - Widget, dygraphs

  152. App - API views

  153. App - Capture form

  154. App - Capture form

  155. App - Capture form

  156. App - Capture form

  157. App - Capture form

  158. App - Capture form

  159. App - Capture form

  160. App - Recording slices list

  161. App - Recording slices previews

  162. App - Recording slices comments

  163. App - Recording slices categorization

  164. App - Recording slices categorization

  165. App - Recording slices categorization

  166. App - Recording slices searching

  167. App - Recording slices searching

  168. App - Recording slices searching

  169. Demo

  170. What’s next? Future enhancements, ideas, wishes.

  171. Improvements, wishlist • Smaller • Single board • More leads

    • Panic button • Remove RTC -> Interrupt • Wireless • Battery level & low battery indicator • Audible “beeps” • Power save mode, smart power on & off
  172. Improvements, wishlist

  173. Improvements, wishlist Mayan Box (Mayan on a battery powered, wireless,

    single board computer) + OpenHolter = ??
  174. Improvements, wishlist Solar powered, last mile, electrophysiologist office.

  175. Improvements, wishlist Solar powered, on-the-field, emergency electrophysiologist station.

  176. Improvements, wishlist • Mayan Box combo • SBC and Mayan

    inside
  177. Next prototype

  178. Questions? Critiques Comments Suggestions

  179. Thank you!

  180. The OpenHolter Project: D.I.Y. Cardiometry with Arduino and Django. Roberto

    Rosario robertorosario.com