Upgrade to Pro — share decks privately, control downloads, hide ads and more …

OpenHolter project: D.I.Y. Electrocardiography ...

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

Roberto Rosario

April 05, 2017
Tweet

More Decks by Roberto Rosario

Other Decks in How-to & DIY

Transcript

  1. 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. 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.
  3. 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.
  4. 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.
  5. Bio Interface - Needs • No voltage but differential voltage

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

    Built-in voltage comparators • Built-in amplifier • Built-in filtering • Power management • Cons: No ADC
  7. Real Time Clock - Needs • Small • Battery or

    SuperCap backed up • Easy interface
  8. 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
  9. Microcontroller unit - Needs • Low power • Analog to

    digital interface • Faster than bio interface sampling rate
  10. 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
  11. Power management - Needs • 5 volt output • High

    size and weight to power ratio • Low heat
  12. 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)
  13. Graphical User Interface - Needs • Small • Low power

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

    • Multiple communication modes including I2C • OLED • Visibility • Pixel based • 2 x Push buttons
  15. 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
  16. 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.
  17. What is SPI SPI devices communicate in full duplex mode

    using a master-slave architecture with a single master.
  18. 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).
  19. 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.
  20. Block diagram - Communications MCU Bio Interface RTC Storage Graphical

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

    Snap ◦ Banana ◦ Suction ◦ Clip ◦ Limb clips ◦ Alligator • Easiest to work and with the most pros: Snap
  22. Organic interface - Leads • Build your own ◦ Source

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

    ◦ Best wire gauge ◦ Tangle resistant ◦ Labeled ◦ $20 USD ◦ Easy to interface
  24. 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
  25. Organic interface - Electrodes • BIO Protech T815 ◦ Cloth

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

    operation: ◦ Realtime display ◦ Recording ◦ Serial port output
  27. 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
  28. Libraries - Storage: Bill Greiman’ SDfatlib • Non monolithic •

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

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

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

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

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

    output pin to trigger Arduino’s hardware interrupt and do sampling in an ISR.
  34. 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.
  35. 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.
  36. Sampling rate reliability - Solution To get 100 samples a

    seconds, how many ticks between each? 1 / 100 / 0.000244141 = every 40.959937086 ticks
  37. Sampling rate reliability - Solution MCU Main loop MCU RTC

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

    (FIFO Stack) Lock Realtime sampling and multithreading on the Arduino.
  39. 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
  40. App - Requirements • Upload recordings • Preview/render recordings •

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

  42. 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