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. 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.
  2. 34.
  3. 35.
  4. 36.
  5. 37.
  6. 38.
  7. 39.
  8. 40.
  9. 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.
  10. 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.
  11. 43.
  12. 44.
  13. 45.
  14. 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.
  15. 48.
  16. 51.

    Bio Interface - Needs • No voltage but differential voltage

    reading • Signal amplification • Adaptive signal filtering • Analog to digital conversion
  17. 52.

    Bio Interface - Analog Devices AD8232 • $10-$20 USD •

    Built-in voltage comparators • Built-in amplifier • Built-in filtering • Power management • Cons: No ADC
  18. 54.

    Real Time Clock - Needs • Small • Battery or

    SuperCap backed up • Easy interface
  19. 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
  20. 57.

    Microcontroller unit - Needs • Low power • Analog to

    digital interface • Faster than bio interface sampling rate
  21. 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
  22. 60.

    Power management - Needs • 5 volt output • High

    size and weight to power ratio • Low heat
  23. 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)
  24. 63.

    Graphical User Interface - Needs • Small • Low power

    or low energy mode • Easy to interface
  25. 64.

    Graphical User Interface - Solomon Systech SD1306 • $5 USD

    • Multiple communication modes including I2C • OLED • Visibility • Pixel based • 2 x Push buttons
  26. 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
  27. 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.
  28. 70.

    What is SPI SPI devices communicate in full duplex mode

    using a master-slave architecture with a single master.
  29. 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).
  30. 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.
  31. 74.

    Block diagram - Communications MCU Bio Interface RTC Storage Graphical

    User Interface Power Management Analog Digital I2C Digital I2C SPI
  32. 75.

    Organic interface - Connectors • Many types and subtypes ◦

    Snap ◦ Banana ◦ Suction ◦ Clip ◦ Limb clips ◦ Alligator • Easiest to work and with the most pros: Snap
  33. 77.

    Organic interface - Leads • Build your own ◦ Source

    connectors ◦ Good wire gauge • Included leads ◦ Poor in all regards • Lead + electrode ◦ Not feasible
  34. 78.

    Organic interface - Leads • Professional ones ◦ Best connectors

    ◦ Best wire gauge ◦ Tangle resistant ◦ Labeled ◦ $20 USD ◦ Easy to interface
  35. 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
  36. 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
  37. 81.

    Firmware • Modular • Object oriented • 3 modes of

    operation: ◦ Realtime display ◦ Recording ◦ Serial port output
  38. 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
  39. 83.

    Libraries - Storage: Bill Greiman’ SDfatlib • Non monolithic •

    Multiple classes: SdFat, SdBaseFile, SdFile, File, StdioStream, ifstream, ofstream • Mature • Fast • Economic memory usage
  40. 84.

    Libraries - RTC: Adafruit’s RTClib • Supports several Arduino MCUs

    • Provides access to the square wave pin • Cons: High memory consumption
  41. 85.

    Challenges and Tricks • Sampling rate reliability • Sample jitter

    • Fast OLED display updates • Heartbeat detection • BPM calculation • Interference filtering • Memory footprint reduction
  42. 86.

    Challenges and Tricks • Sampling rate reliability • Sample jitter

    • Fast OLED display updates • Heartbeat detection • BPM calculation • Interference filtering • Memory footprint reduction
  43. 87.

    Sampling rate reliability • Arduino’s crystal is subject to drift

    • Interrupt driven • Improve periodicity of readings • Increase sample rate
  44. 88.

    Sampling rate reliability - Solution Use the DS3231 square wave

    output pin to trigger Arduino’s hardware interrupt and do sampling in an ISR.
  45. 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.
  46. 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.
  47. 91.

    Sampling rate reliability - Solution To get 100 samples a

    seconds, how many ticks between each? 1 / 100 / 0.000244141 = every 40.959937086 ticks
  48. 95.

    Sampling rate reliability - Solution MCU Main loop MCU RTC

    driven ISR ad8232 ad8232_buffer ad8232 interrupt_data_ready RTC
  49. 96.

    Sampling rate reliability - Solution Consumer Hardware timer Generator Buffer

    (FIFO Stack) Lock Realtime sampling and multithreading on the Arduino.
  50. 119.
  51. 126.
  52. 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
  53. 130.
  54. 133.
  55. 136.

    App - Requirements • Upload recordings • Preview/render recordings •

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

    App

  57. 169.
  58. 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
  59. 173.
  60. 179.