====== 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 ===
#include
#include
int sensorPin = A0;
int sensorValue = 0;
ISR(TIMER1_OVF_vect)
{
sensorValue = analogRead(sensorPin);
Serial.println(sensorValue,DEC);
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); // wait for a second
}
=== Computer dumper ===
== Python with fancy GUI ==
#!/usr/bin/python3
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,200,200)
# line color
fg = (0,0,0)
screen.fill(bg)
ser = serial.Serial(port="/dev/ttyUSB0", baudrate=38400, timeout=1)
yprev=0
# grid color
gc = (150, 150, 150)
def grid(x):
''' Draw horizontal grid '''
for i in range(1,500,50):
pygame.draw.line(screen, gc, (x, i), (x,i))
from datetime import datetime
from time import gmtime, strftime
wow=datetime.now().strftime("%Y-%m-%d-%H%M%S")
l=open("./gsr-%s.txt"%(wow), "a")
while True:
line = ser.readline()
s = line.decode("utf-8", 'ignore')
wow=datetime.now().strftime("%Y-%m-%d-%H:%M:%S")
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, bg, (x, 0), (x,YSIZE))
# draw red line
pygame.draw.line(screen, (255,0,0), (x+1, 0), (x+1,YSIZE))
# draw grid
grid(x)
# draw data
pygame.draw.line(screen, fg, (x, y), (x,yprev))
yprev=y
pygame.display.update()
== Command line dumper ==
Use minicom to dump the stream for future use (gnuplot, statistics, etc). Use combo "CTRL+A ... q ... ENTER" to end dumping.
minicom -b 38400 -8 -d /dev/ttyUSBx --capturefile=/dumped/file
====== Helige EKG ======
Modern (90's) EKG/respiration/whatever box with more precise measurements and nicer GUI but without documentation (there is RS232 with some proprietary crippled protocol), thus we lack the possibility to dump and analyze the data.