project:medlab:ekg
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
project:medlab:ekg [2015/11/11 00:12] – sachy | project:medlab:ekg [2015/11/11 00:13] (current) – sachy | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Tesla EKG ====== | ||
+ | Tesla EKG is legacy piece of medical hw made in Czechoslovakia. On one side is connected to the subject via DIN5 port, on the other side sits Arduino mini which is used to emulate classic RS232 over USB for easy data dumping. | ||
+ | |||
+ | Signal is tranmitted realtime as unsigned short integer. | ||
+ | |||
+ | === Arduino firmware === | ||
+ | |||
+ | <code c> | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | int sensorPin = A0; | ||
+ | int sensorValue = 0; | ||
+ | |||
+ | ISR(TIMER1_OVF_vect) | ||
+ | { | ||
+ | sensorValue = analogRead(sensorPin); | ||
+ | Serial.println(sensorValue, | ||
+ | |||
+ | TCNT1=65535-2500; | ||
+ | } | ||
+ | |||
+ | // the setup routine runs once when you press reset: | ||
+ | void setup() { | ||
+ | Serial.begin(38400); | ||
+ | | ||
+ | /* Normal timer operation.*/ | ||
+ | TCCR1A = 0x00; | ||
+ | | ||
+ | // timer counter | ||
+ | TCNT1=65000; | ||
+ | | ||
+ | // prescaler | ||
+ | TCCR1B = 0x03; | ||
+ | | ||
+ | /* Enable the timer overlow interrupt. */ | ||
+ | TIMSK1=0x01; | ||
+ | | ||
+ | power_spi_disable(); | ||
+ | power_twi_disable(); | ||
+ | } | ||
+ | |||
+ | // the loop routine runs over and over again forever: | ||
+ | void loop() { | ||
+ | | ||
+ | delay(1000); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | === Computer dumper === | ||
+ | |||
+ | == Python with fancy GUI == | ||
+ | |||
+ | <code python> | ||
+ | # | ||
+ | import pygame | ||
+ | import random | ||
+ | import time | ||
+ | import serial | ||
+ | import sys | ||
+ | |||
+ | SCREENSIZE = XSIZE, YSIZE = (1360, 514) | ||
+ | |||
+ | screen = pygame.display.set_mode(SCREENSIZE) | ||
+ | x = 4 | ||
+ | |||
+ | # background color | ||
+ | bg = (200, | ||
+ | |||
+ | # line color | ||
+ | fg = (0,0,0) | ||
+ | screen.fill(bg) | ||
+ | |||
+ | ser = serial.Serial(port="/ | ||
+ | |||
+ | yprev=0 | ||
+ | |||
+ | # grid color | ||
+ | gc = (150, 150, 150) | ||
+ | |||
+ | def grid(x): | ||
+ | ''' | ||
+ | for i in range(1, | ||
+ | pygame.draw.line(screen, | ||
+ | |||
+ | from datetime import datetime | ||
+ | from time import gmtime, strftime | ||
+ | |||
+ | wow=datetime.now().strftime(" | ||
+ | l=open(" | ||
+ | |||
+ | |||
+ | while True: | ||
+ | line = ser.readline() | ||
+ | s = line.decode(" | ||
+ | wow=datetime.now().strftime(" | ||
+ | s = wow + " " + s | ||
+ | sys.stdout.write(s) | ||
+ | | ||
+ | l.write(s) | ||
+ | x = (x+1)%(XSIZE-2) | ||
+ | try: | ||
+ | y = int(line)/2 | ||
+ | except: | ||
+ | y=0 | ||
+ | |||
+ | y = YSIZE-y | ||
+ | |||
+ | # remove previous data | ||
+ | pygame.draw.line(screen, | ||
+ | # draw red line | ||
+ | pygame.draw.line(screen, | ||
+ | # draw grid | ||
+ | grid(x) | ||
+ | # draw data | ||
+ | pygame.draw.line(screen, | ||
+ | yprev=y | ||
+ | pygame.display.update() | ||
+ | |||
+ | </ | ||
+ | |||
+ | == Command line dumper == | ||
+ | |||
+ | Use minicom to dump the stream for future use (gnuplot, statistics, etc). Use combo " | ||
+ | |||
+ | <code bash> | ||
+ | minicom -b 38400 -8 -d / | ||
+ | </ | ||
+ | |||
+ | ====== Helige EKG ====== | ||
+ | |||
+ | Modern (90's) EKG/ |