Editing Pulse Necklace 15Nov2009
Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 13: | Line 13: | ||
To look at the output signal from AD 620, we resorted to a virtual oscilloscope - link and code are in the next section. Unfortunately, we saw only noise from the oscilloscope. We tried switching the gain-control resistor from 98 ohms (two 47 ohm resistors) to 1 kohm. That only lowered the amplitude. We were using red dot electrodes, so the ECG signal was entering the chip reliably. More work to be done on this front. | To look at the output signal from AD 620, we resorted to a virtual oscilloscope - link and code are in the next section. Unfortunately, we saw only noise from the oscilloscope. We tried switching the gain-control resistor from 98 ohms (two 47 ohm resistors) to 1 kohm. That only lowered the amplitude. We were using red dot electrodes, so the ECG signal was entering the chip reliably. More work to be done on this front. | ||
== | ==Oscillascope Code== | ||
We got | We got amazing code for a virtual Arduino oscilloscope from [http://accrochages.drone.ws/en/node/90 Poorman's oscilloscope] and juse changed the serial port name to correspond to either Eric's or mine cable: | ||
<pre> | <pre> | ||
// Pulse Choker | |||
// Chung-Hay and Eric | |||
// Oct 1st, 2009 | |||
// | // Control 5 different lines of LEDs based on EKG | ||
// Center top line is 5V shared across all LEDs | |||
// EKG input pin = pin 2 | |||
int OuterTwosLeft = 13; // Left, right w/r/t to viewer, not wearer | |||
int MiddleLeft = 12; | |||
int CenterGrd = 11; | |||
int MiddleRight = 10; | |||
int OuterTwosRight = 9; | |||
int val = 0; | |||
int minval = 10000; | |||
int maxval = 0; | |||
float avg = 160; // common value, better than initing to zero | |||
float stdev = 40; | |||
int i; | |||
void setup() { | void setup() { | ||
Serial.begin( | pinMode(OuterTwosLeft, OUTPUT); | ||
pinMode(OuterTwosRight, OUTPUT); | |||
pinMode(MiddleLeft, OUTPUT); | |||
pinMode(MiddleRight, OUTPUT); | |||
pinMode(CenterGrd, OUTPUT); | |||
digitalWrite(OuterTwosLeft, 1); | |||
digitalWrite(OuterTwosRight, 1); | |||
digitalWrite(MiddleLeft, 1); | |||
digitalWrite(MiddleRight, 1); | |||
digitalWrite(CenterGrd, 1); | |||
Serial.begin(57600); // setup serial | |||
} | } | ||
void loop() { | void loop() { | ||
/* digitalWrite(OuterTwosLeft, 1); | |||
delay(500); | |||
digitalWrite(OuterTwosRight, 1); | |||
delay(500); | |||
digitalWrite(MiddleLeft, 1); | |||
delay(500); | |||
digitalWrite(MiddleRight, 1); | |||
delay(500); | |||
digitalWrite(CenterGrd, 1); | |||
delay(500); | |||
digitalWrite(OuterTwosLeft, 0); | |||
delay(500); | |||
digitalWrite(OuterTwosRight, 0); | |||
delay(500); | |||
digitalWrite(MiddleLeft, 0); | |||
delay(500); | |||
digitalWrite(MiddleRight, 0); | |||
delay(500); | |||
digitalWrite(CenterGrd, 0); | |||
delay(500); | |||
*/ | |||
< | val = 0; | ||
for (i=0; i < 8; i++) | |||
{ | |||
val += analogRead(2); // read the input pin | |||
} | |||
val = val/8; | |||
if (val > maxval) | |||
maxval = val; | |||
if (val < minval) | |||
minval = val; | |||
avg = avg*99.0/100.0 + (float)val/100.0; | |||
stdev = sqrt ((stdev*99.0/100.0)*(stdev*99.0/100.0) + ((float)val-avg)*((float)val-avg)/100); | |||
Serial.print(val); | |||
Serial.print(" "); | |||
Serial.print(minval); | |||
Serial.print(" "); | |||
Serial.print(maxval); // debug value | |||
Serial.print(" "); | |||
Serial.print(avg); | |||
Serial.print(" "); | |||
Serial.println(stdev); | |||
if (val < (avg-stdev)) | |||
{ | |||
// Serial.println(val); // debug value | |||
digitalWrite(OuterTwosLeft, 0); // 0 = lit // this LED not working, unless you push down at wire connection area | |||
digitalWrite(OuterTwosRight, 0); | |||
digitalWrite(CenterGrd, 0); // this LED not working | |||
digitalWrite(MiddleLeft, 0); | |||
Serial | digitalWrite(MiddleRight, 0); // this LED not working | ||
} | } | ||
else | |||
{ | |||
digitalWrite(OuterTwosLeft, 1); // 1 = off | |||
digitalWrite(OuterTwosRight, 1); | |||
digitalWrite(CenterGrd, 1); | |||
digitalWrite(MiddleLeft, 1); | |||
digitalWrite(MiddleRight, 1); | |||
} | } | ||
//Serial.println("test"); | |||
} | } | ||
</pre> | </pre> | ||
[[Category:Sensebridge]] | [[Category:Sensebridge]] |