Shop OBEX P1 Docs P2 Docs Learn Events
Prop EKG (Preview) — Parallax Forums

Prop EKG (Preview)

RaymanRayman Posts: 14,591
edited 2008-09-24 14:47 in Propeller 1
I've been working on this (EKG) for a while!· I've kinda got it working now...· Enough to show a screenshot.
Circuit is relatively simple, just two 8-pin DIPs...

Update:· Added a new screenshot with calibrated grid (major grid is 200 ms by 0.5 mV) and hardware RC lowpass filter

Post Edited (Rayman) : 9/23/2008 7:31:40 PM GMT
1152 x 864 - 586K
1152 x 864 - 601K
«1

Comments

  • HarleyHarley Posts: 997
    edited 2008-09-19 19:24
    Rayman, Looks good.

    Curious, is there a reason to display the waveform vertically? Seems a bit strange.

    Recently was in emergency with a relative; the waveforms were horizontal. Seems more normal orientation. Guess you're trying for a strip-chart type display.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
  • PraxisPraxis Posts: 333
    edited 2008-09-19 19:30
    Turn the monitor on it's side, all fixed....Just kidding[noparse]:)[/noparse]
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2008-09-19 19:41
    Rayman,
    ·
    Excellent! ... How does your sensor cope with other myo-electric signals (i.e. voluntary muscle contractions)·other than from your heart.
    ·
    Also, are you using any kind of filtering on your inputs?· i.e. 60Hz notch or simply a high-pass for anything above 400Hz
    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • RaymanRayman Posts: 14,591
    edited 2008-09-19 19:43
    Harley said...
    Curious, is there a reason to display the waveform vertically? Seems a bit strange.
    Unfortunately, there isn't enough RAM to show·two 768x256 bitmaps...· So, I have to do the graphing dynamically, inside a cog.

    The Prop just isn't fast enough to dynamically generate a horizontal line with info from all 768 bytes of data displayed per graph.

    But, it is just fast enough to dynamically generate a horizontal line based on one or two data points...


    Praxis:· Many monitors do rotate 90 degrees and I have it in my mind to copy and rotate the ROM font so that I can rotate everything...
  • RaymanRayman Posts: 14,591
    edited 2008-09-19 19:46
    Beau: My filtering needs work! Right now, I'm using a simple digital bandpass filter...
  • LeonLeon Posts: 7,620
    edited 2008-09-19 19:46
    Are your inputs electrically isolated? Your system could be lethal if they aren't! When I designed a heart rate monitoring system many years ago I used medically-approved isolation amplifiers, they were very expensive.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • RaymanRayman Posts: 14,591
    edited 2008-09-19 19:55
    If you power everything from a battery, it is completely isolated...

    But, if you suddenly don't hear from me for a long while, you'll know why! [noparse]:)[/noparse]
  • RaymanRayman Posts: 14,591
    edited 2008-09-19 20:05
    More seriously though, I have 100k resistors between the body leads and the amplifier. The only real danger I see with wall power is a lightning strike while you're hooked up...
  • LeonLeon Posts: 7,620
    edited 2008-09-19 20:16
    It's connected to the computer, though. Suppose that developed an electrical fault. It really ought to be isolated.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • RaymanRayman Posts: 14,591
    edited 2008-09-19 20:21
    It takes 10mA to cause pain, 100mA death.· With 100k input resistors (and assuming zero body resistance), it would take a 1,000 V pulse to cause pain, 10,000 V to cause death.

    I could just add an 10V MOV between inputs and GND.· That would elimate most concerns.

    Also, it need not be connected to a PC...· I plan on allowing recording to SD or EEPROM·for later review on PC...
  • KeithEKeithE Posts: 957
    edited 2008-09-19 20:44
    Interesting - I was thinking about using one of the Polar Heart Rate Modules (RMCM01 $15) from Sparkfun to create something like the stresseraser.com - just for entertainment value.
  • KeithEKeithE Posts: 957
    edited 2008-09-20 01:04
    This is interesting - someone posted about a certain alternative platform in the protoboard pricing thread and here is is with an ECG application?

    www.stm32circle.com/projects/project.php?id=31
  • RaymanRayman Posts: 14,591
    edited 2008-09-20 01:24
    Yes, I must admit that was my inspiration... It won 1st price, you know [noparse]:)[/noparse]
  • VIRANDVIRAND Posts: 656
    edited 2008-09-20 06:10
    Harley said...
    Harley said...
    Curious, is there a reason to display the waveform vertically? Seems a bit strange.
    rayman said...

    Unfortunately, there isn't enough RAM to show two 768x256 bitmaps... So, I have to do the graphing dynamically, inside a cog.

    The Prop just isn't fast enough to dynamically generate a horizontal line with info from all 768 bytes of data displayed per graph.

    Are you sure about that?
    What would you say if I find my old 8-bit homebrew horizontal trace AUDIO scope that drives any VGA monitor
    to at least 640x128 effective trace resolution in my junk pile in working condition and then put it on youtube?

    Surely the Propeller must have enough MIPS to translate 768x2 samples of Ultra Low Frequency EKG
    into run-length-encoding or something for dynamic video generation. And horizontal scrolling too.
  • RaymanRayman Posts: 14,591
    edited 2008-09-20 11:31
    Virand:

    I've seen some Parallax code that creates a bitmap within a cog.· 640x128 by 1-bit I could believe.· But, two of them would use up over 20kB.·

    The way I'm doing it uses no HUB RAM for data or display.· The data is only held within one cog and that cog generates and displays the graph...

    But, I probably would like to display on TV and VGA too, so I'd definitely be interested in what you've done...
  • HarleyHarley Posts: 997
    edited 2008-09-20 16:38
    Rayman said...
    It takes 10mA to cause pain, 100mA death. With 100k input resistors (and assuming zero body resistance), it would take a 1,000 V pulse to cause pain, 10,000 V to cause death.

    I could just add an 10V MOV between inputs and GND. That would elimate most concerns.

    Also, it need not be connected to a PC... I plan on allowing recording to SD or EEPROM for later review on PC...

    Apologies for this late comment. One detail that must be noted here is that there is a voltage limit on resistor breakdown.

    Back some decades ago, I had a circuit that had to stand 1000v transient across it's input, which originally consisted of one 600 Ohm resistor. On testing, it was found every resistor would breakdown, altering its value. Until it was finally noted that at breakdown there was a minute 'flash' on its body, if the breakdown point was aimed towards the observer. It was found that there was a tiny crater blasted out of the resistor body. That was when closer examination of the data sheet revealed that the resistor was good for only 350v; these were metal-film resistors, which had a spiral cut/detail along the length of the resistive metal on the insulator core, and this was where the breakdown was occurring. The arc would blast away some resistive material making for a overall higher resistance. So the fix was to use 4x 150 Ohm resistors to handle the breakdown. That took care of the breakdown problem. And possibly SMD resistors would have a lower breakdown limit.

    So, one 100K resistor would provide a higher than anticipated current, possibly changing from 'pain' to 'death' with much lower than 1000v. Us humans make for a very poor 'fuse'.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Harley Shanko
  • LeonLeon Posts: 7,620
    edited 2008-09-20 18:41
    Resistors used like that don't make the system suitable for connection to anyone, they won't satisfy the requirements for medical equipment. Isolation using approved devices is the only way to be safe.

    Leon

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Amateur radio callsign: G1HSM
    Suzuki SV1000S motorcycle
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2008-09-20 18:48
    Rayman,

    Great minds think alike! Except I'm planning to try this with the "Frequency to Light" IC from Parallax.
    There's a suggestion for a project like this in the documentation on that page using an LED.
    (Placing your pinky on the IC, then using an LED as the light source above your fingernail.)

    Haven't had a chance to try it yet, (perhaps today) so I'll report back if it looks like graphicable data.

    OBC

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    New to the Propeller?

    Getting started with a Propeller Protoboard?
    Check out: Introduction to the Proboard & Propeller Cookbook 1.4
    Updates to the Cookbook are now posted to: Propeller.warrantyvoid.us
    Got an SD card connected? - PropDOS
  • RaymanRayman Posts: 14,591
    edited 2008-09-20 22:40
    OBC:· Do you mean like a pulse OX sensor?· That would be neat!

    Leon:· I'm not making a medical device, just an educational tool...· There are plenty·kits and circuits out there without any special isolation.· That being said, I wouldn't recommend using this in a thunder storm.
  • RaymanRayman Posts: 14,591
    edited 2008-09-21 00:40
    Harley: You are quite correct. However, I would only anticipate such high voltages as a result of lightning strike... Anyway, the body is essentially grounded by one of the leads. And as you say, the physical components really won't allow very high voltages between leads... So, as I see it, the only real danger is if you are connected to another ground somehow that generates a large inductive potential difference due to a large current, like from lightning... The only difference between this and any other circuit is that the EKG pads are specifically designed to reduce the skin resistance and this is what usually protects us from shocks...

    All of this concern can be avoided by running the proto board off a 9V battery when taking measurements...
  • VIRANDVIRAND Posts: 656
    edited 2008-09-21 01:14
    Rayman said...
    Virand:

    I've seen some Parallax code that creates a bitmap within a cog. 640x128 by 1-bit I could believe. But, two of them would use up over 20kB.

    The way I'm doing it uses no HUB RAM for data or display. The data is only held within one cog and that cog generates and displays the graph...

    But, I probably would like to display on TV and VGA too, so I'd definitely be interested in what you've done...

    There's no need for a bitmap in an oscillograph, since the input is the complete graph data.
    Aren't you using the vertical graph just because the samples can be directly translated into a video of the graph?
    It's only a little bit harder to graph horizontally, and that's because the number of data points on each line varies.
    Either way, you're just feeding the video generator the pixels that represent the data points on the graph.
  • rjo_rjo_ Posts: 1,825
    edited 2008-09-21 13:24
    Rayman,

    Excellent... can't wait for more. I found an article summary that talks about removing the EKG from myoelectric signals used to drive a
    prosthetic arm... the same problem you have but in reverse[noparse]:)[/noparse]

    http://ieeexplore.ieee.org/Xplore/login.jsp?url=/iel5/10755/33900/01615670.pdf?temp=x

    "The performance of various ECG artifact removal methods including high pass filtering, spike clipping, template subtracting, wavelet thresholding and adaptive filtering was presented. In particular, considering the clinical requirements and memory limitation of commercial prosthesis controllers, we further explored suitable means of ECG artifact removal for clinical application..."

    --You seem to be using non-standard scaling for your EKG... should be 0.5 millivolts per graph line. There should be 5 divisions per second.

    (http://books.google.com/books?id=oPS75f1BJ8AC&pg=PA50&lpg=PA50&dq=qrst+ecg&source=web&ots=RuvkIi47d9&sig=uJvHXSNwV7fpOrJ0pkFqgt9Dud8&hl=en&sa=X&oi=book_result&resnum=6&ct=result#PPA79,M1)

    Why make it a hobby thing?... here is the state of the art in mobile units with 3D Mapping... would require 12 Cogs[noparse]:)[/noparse]

    http://www.measurement.sk/2007/S2/Rosik.pdf


    About the safety thing... can't you design that into the power supply?

    Rich
  • Beau SchwabeBeau Schwabe Posts: 6,566
    edited 2008-09-21 13:47
    rjo_,
    This is exactly what I was getting at...
    "...I found an article summary that talks about removing the EKG from myoelectric signals used to drive a
    prosthetic arm..." ... "...The performance of various ECG artifact removal methods including high pass filtering..."

    If a reliable myo-electric system can easily be developed, then there are many $$$·that people would be willing to spend.· Without name dropping, there are a few companies that I know of that charge upwards of $600 per myo-electric sensor... in most cases you need at least two of them for complementary prosthetic action.· i.e. open/close, up/down, rotate CW/CCW, etc.
    There are many benefits, not only to the prosthetic community, but also·in·other robotic applications.
    ·
    High pass filtering above 100Hz to 400Hz is what I have seen in the past to effectively filter out 50/60Hz, which is the largest problem.· This also eliminates most if not all of the spikes from a heartbeat.· I forget what the exact frequency range is, but what you are looking for is the "noise" or signature produced in the muscle from the Sodium·/ Potassium chemical reaction that causes your muscle to contract in the first place.· The·harder the contraction, the more "noise".· The softer the contraction, the less "noise".· However there is a frequency component that can be detected from the Sodium·/ Potassium·chemical reaction that the brain is sending to the muscle causing it to fire.





    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Beau Schwabe

    IC Layout Engineer
    Parallax, Inc.
  • rjo_rjo_ Posts: 1,825
    edited 2008-09-21 14:35
    Beau,

    I love my Propeller[noparse]:)[/noparse]


    Rich
  • PaulPaul Posts: 263
    edited 2008-09-21 22:45
    How about an optoisolator for isolation? Some are rated up to 5KV. We use PC817 and they come in 5 'flavors' of Current Transfer Ratios.(CTR) 25% to 300%

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki Rocks! - propeller.wikispaces.com
  • RaymanRayman Posts: 14,591
    edited 2008-09-21 23:51
    That's tough because the signal is analog all the way to the Prop and out to the VGA. Optoisolators are usually digital and slow...

    If someone really has a concern, they should just power the proto board with a battery and disconnect the VGA while acquiring data.

    The Proto board has a spare 32kB of I2C EEPROM that can hold over a minute of two-channel data (or almost 3-minutes of single channel) (assuming the current 200 sample/second rate [noparse][[/noparse]likely to change]). If a 2-GB SD card is present, it could record for 1000 hours...

    One could use LEDs and pushbuttons to show and set aquisition status while on battery power...·

    Or, there's always the uOled-Prop-96...· I'm not sure that ADC will work with that, but might be worth a try...

    Still, I personally think the risk of electrocution is so low, that it's not worth the trouble. But, there's always somebody that will connect one electrode to line voltage, isn't there?
  • PaulPaul Posts: 263
    edited 2008-09-22 00:10
    What's the old saying? If you make something idiot proof, they just find smarter idiots.

    My last attempt at keeping you from massive lawsuits: analog = transformer = galvanic isolation = no dc path anyway.

    This is great idea by the way. Good luck with it!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Propeller Wiki Rocks! - propeller.wikispaces.com
  • RaymanRayman Posts: 14,591
    edited 2008-09-23 19:30
    rjo_: I've fixed the scaling... First post now has a screenshot with calibrated grid.
  • RinksCustomsRinksCustoms Posts: 531
    edited 2008-09-24 02:19
    Speaking of EMG... check this page out (look at the "screenshot" at the bottom). That should give enough data to make some prop based EMG stuff... like maybe a electronic human hand, anybody check out the nano muscle over at sparkfun? I had an idea to use a net of EMG sensors around the forearm to pick up a "signature" of the underlying muscles and use that "signature" to move the hand/wrist/fingers accordingly, and with good precision too. Originally thought of trying to capture the individual muscle movements but realized the potential of crosstalk having that many sensors in proximity. It's likely that obtaining isolated muscle contractions isn't all that feasable through EMG sensors. Embeded sensors (similar to an RFID tag) could be implanted below the skin to obtain the individual muscle contractions and assosiated strength or amplitude of these contractions WITH an RFID tag so each finger muscle would have a unique ID and you could read the Intensity if any and run it through an algorithm to control a neumatic piston·"muscle" regulated from a standard CO2 cartridge through a precise valving system. Or an alternative system with even thiner "muscles" hydraulically opperated through similar precision valving utilizing either a small hydraulic pump to charge an acuumulator with hydraulic pressure or via CO2 cartridge that would instantly charge the acuumulator.
    There's one "bump" in this thinking... To exactly mimic the human hand with ALL points of articulation, you also need to sense pinch, those muscles reside on the hand along with a few others, for amputee's this would pose a larger problem that EMG or ultrasound wouldn't be able to process.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    E3 = Thought

    http://folding.stanford.edu/·- Donating some CPU/GPU downtime just might lead to a cure for cancer! My team stats.

    Post Edited (RinksCustoms) : 9/24/2008 3:13:52 AM GMT
  • rjo_rjo_ Posts: 1,825
    edited 2008-09-24 02:50
    PVC looks the same... so the second picture shows the same data with filtering?

    Looks sooooooooooooo good[noparse]:)[/noparse]

    I had an EMG once... didn't hurt too much. Go ahead and try it. Remember... you have to get the needle all the way into the muscle[noparse]:)[/noparse]

    Rich
Sign In or Register to comment.