3:37:56 am on 7/30/10
Menu
» Home
» About Scott
» QRSS VD
» Old Stuff
» Archive
» Contact

Categories
» C/C++
» Circuitry
» Dentistry
» DIY ECG
» General
» Linux
» Microcontrollers
» Molecular Biology
» My Website
» PHP
» Prime Numbers
» Python
» Radio
» UCF Lab
» Everything
Writings
» MD Labels
» Streamrip
» AIM Thoughts
» WindowsXP?
» Partitioning
» CD/DVD Repair
» Monitor Info
» CRT Deflection
» Venomcrack
» Flash Thing
» Heart/Brain
» Diabetes
» Triops
» Biomed

Friends
» Fred
» Kyle W
» Nick
» Louis
» Tom
» Kyle H




Archives
» July 2010
» June 2010
» May 2010
» April 2010
» March 2010
» February 2010
» January 2010
» December 2009
» September 2009
» August 2009
» July 2009
» June 2009
» May 2009
» April 2009
» March 2009
» February 2009
» January 2009
» December 2008
» November 2008
» October 2008
» September 2008
» September 2007
» December 2006
» August 2006
» January 2006
» August 2005
» July 2005
» June 2005
» May 2005
» April 2005
» March 2005
» February 2005
» January 2005
» December 2004
» November 2004
» October 2004
» September 2004
» August 2004
» July 2004
» June 2004
» May 2004
» April 2004
» March 2004
» February 2004
» January 2004
» December 2003
» November 2003
» October 2003
» September 2003
» August 2003
» July 2003
» June 2003
» May 2003
» April 2003
» March 2003
» February 2003
» January 2003
» December 2002
» November 2002
» October 2002
» September 2002
» June 2001

You are currently browsing the archives for the Circuitry category.

Archive for the 'Circuitry' Category

« Previous Entries


High Altitude Balloon Transmitter
Posted by
Scott July 14th, 2010 | 5,253 words | 10 Comments »


Scott was 24.80 years old when he wrote this!

SUMMARY: A small group of high school students taking an AP class for college credit launched a high-altitude weather balloon with a small payload. In addition to a video transmitter and GPS transmitter, they decided to include a simple transmitter built from scratch. This is the story of the project, with emphasis on the simple transmitter’s design, construction, implementation, and reception (which surprised me, being detected ~200 miles away and lasting the entire duration of the flight!) [sample.ogg]

6/16/2010 – TRACKING

I’m completely amazed at how well the transmitter/receiver worked! For only a few milliwatts, I was able to track that thing all the way from takeoff to landing in Gainesville, FL a few hundred miles away. Here is the data assembled in a special, annotated way!

CLICK HERE to view the signal tracked from Gainesville, FL
balloon_track

ANALYSIS: the text on the image describes most if it, but one of the most interesting features is the “multipathing” during the final moments of the descent, where the single carrier signal splits into two. I believe this is due to two Doppler shifts: (1) as the distance between the falling transmitter and the receiver is decreasing, producing a slight in increase in frequency, and (2) a signal reflected off of a layer of the atmosphere above the craft (the ionosphere?) before it gets to the receiver, the distance of which is increasing as the craft falls, producing a decrease in frequency. I’ll bet I can mathematically work backwards and determine how high the craft was, how fast it was falling, and/or how high the layer of the reflecting material is – but that’s more work than this dental student is prepared to do before his morning coffee!

HERE IS SOME AUDIO of some of the strongest signals I received. Pretty good for a few milliwatts a hundred miles away! [beeps.ogg]

6/16/2010 – THE FLIGHT

The launch:

This is the design team:
DSC_7127

Walking the balloon to its launch destination at NASA with an awesome rocket (Saturn 1B – identified by Lee, KU4OS) in the background.
DSC_7210

The team again, getting ready for launch. I’ve been informed that the reason their hands are up is to prevent the balloon from tilting over too much. I’d imagine that a brush with a grass blade could be bad news for the project!
DSC_7232

Last minute checks – you can see the transmitter and battery holders for it taped to the Styrofoam.
DSC_7248

The transmitter in its final position. Note the coil of yellow wire. That serves as a rudimentary “ground” for the antenna’s signal to push off of. I wasn’t very clear on my instructions on how to make it. I meant that it should be a huge coil wrapped around the entire payload (as large as it can be), which would have probably produced a better signal, but since I was able to capture the signal during the whole flight it turned out to be a non-issue.
DSC_7250

The antenna can be seen dropping down as a yellow wire beneath the payload. (arrow)
DSC_7253

Awesome photo.
DSC_7279

Launch! Look how fast that balloon is rising!
DSC_7294

It’s out of our hands now. When I got the text message that it launched, I held my breath. I was skeptical that the transmitter would even work!
DSC_7297

One of the students listening to my transmitter with QRSS VD software (score!)
DSC_7365

Video capture from an on-board camera was also attempted (900MHz), but from what I hear it didn’t function well for very long.
DSC_7334

6/15/2010 – IMPROVED BUILD

Here you can see me (center arrow) showing the students how to receive the Morse code signal sent from the small transmitter (left arrow) using a laptop running QRSS VD (my software) analyzing audio from and an Icom706 mkII radio receiver attached to a dipole (right arrow).DSC_7082

I amped-up the output of the oscillator using an octal buffer chip (74HC240) with some decent results. I’m pleased! It’s not perfect (it’s noisy as heck) but it should be functional for a 2 hour flight.
72hc240_qrp_amplifier

Closeup of the transmitter showing the oscillator at 29.4912 MHz, the Atmel ATTiny44a AVR microcontroller (left chip), octal buffer 74HC240 (right chip), and some status lights which blink as the code is executed.01_closeup

This is my desk where I work from home. Note the styrofoam box in the background – that’s where my low-power transmitter lives (the one that’s spotted around the world). All I needed to build this device was a soldering iron. 02_workstation

Although I had a radio, it is not capable of receiving 29MHz so I was unable to test the transmitter from home. I had to take it to the university to assess its transmitting capabilities.03_room

At UF I used an oscilloscope to measure the waveform of the transmitter. 04_measure

I connected the leads to the output of the transmitter, shorted by a 39ohm resistor. By measuring the peak-to-peak voltage of the signal going into a resistor, we can measure its power.04_measure2

Here’s the test setup. The transmitter is on the blue pad on the right, and the waveform can be seen on the oscilloscope on the upper left.05_lab

Here’s a closer view.
06_scope

With the amplifier off, the output power is just that of the oscillator. Although the wave should look like a sine wave, it’s noisy, and simply does not. While this is unacceptable if our goal is a clean radio signal with maximum efficiency, this is good enough to be heard at our target frequency. The PPV (peak-to-peak voltage) as seen on the screen is about 100mV. Since I’m using a x10 probe, this value should be multiplied by 10 = 1V. 1V PPV into 39 ohms is about 3 milliwatts! ((1/(2*2^.5))^2/39*1000=3.2). For the math, see this post07_no_amp

With the amplifier, the output is much more powerful. At 600mV peak-to-peak with a 10x probe (actually 6V peak-to-peak, expected because that’s the voltage of the 4xAAA battery supply we’re using) into 39 ohms we get 115 millivolts! (6/(2*2^.5))^2/39*1000=115.38. 08_amp

Notes about power: First of all, the actual power output isn’t 115mW. The reason is that the math equations I used work only for pure sine waves. Since our transmitter has multiple waves in it, less than that power is going to produce our primary signal. It’s possible that only 50mW are going to our 29MHz signal, so the power output assessment is somewhat qualitative. Something significant however is the difference between the measured power with and without the amplifier. The 6x increase in peak-to-peak voltage results in a 36x (6^2) increase in power, which is very beneficial. I’m glad I added this amplifier! A 36 times increase in power will certainly help.

The final schematic is here:
balloon_transmitter_final

6/14/2010 – THE BUILD

Last week I spoke with a student in the UF aerospace engineering department who told me he was working with a group of high school students to add a payload to a high-altitude balloon being launched at (and tracked by) NASA. We tossed around a few ideas about what to put on it, and we decided it was worth a try to add a transmitter. I’ll slowly add to this post as the project unfolds, but with only 2 days to prepare (wow!) I picked a simplistic design which should be extremely easy to understand by everyone. Here’s the schematic:

balloon_transmitter

The code is as simple as it gets. It sends some Morse code (”go gators”), then a long tone (about 15 seconds) which I hope can be measured QRSS style. I commented virtually every line so it should be easy to understand how the program works.

#include <avr /io.h>
#include <util /delay.h>

char call[]={2,2,1,0,2,2,2,0,0,2,2,1,0,1,2,0,2,0,2,2,2,0,1,2,1,0,1,1,1,0,0};
// 0 for space, 1 for dit, 2 for dah

void sleep(){
  _delay_ms(100); // sleep for a while
  PORTA^=(1<<PA1); // "flip" the state of the TICK light
}

void ON(){
 PORTB=255; // turn on transmitter
 PORTA|=(1<<PA3); // turn on the ON light
 PORTA&=~(1<<PA2); // turn off the ON light
}

void OFF(){
 PORTB=0; // turn off transmitter
 PORTA|=(1<<PA2); // turn on the OFF light
 PORTA&=~(1<<PA3); // turn off the OFF light
}

void ID(){
        for (char i=0;i<sizeof(call);i++){
                if (call[i]==0){OFF();} // space
                if (call[i]==1){ON();} // dot
                if (call[i]==2){ON();sleep();sleep();} // dash
    sleep();OFF();sleep();sleep(); // between letters
        }
}

void tone(){
 ON(); // turn on the transmitter
 for (char i=0;i<200;i++){ // do this a lot of times
  sleep();
 }
 OFF();sleep();sleep();sleep(); // a little pause
}

int main(void) // PROGRAM STARTS HERE
{
    DDRB = 255; // set all of port B to output
 DDRA = 255; // set all of port A to output
 PORTA = 1; // turn on POWER light

 while (1){ // loop forever
  ID(); // send morse code ID
  tone(); // send a long beep
 }
}

I’m now wondering if I should further amplify this signal’s output power. Perhaps a 74HC240 can handle 9V? … or maybe it would be better to use 4 AAA batteries in series to give me about 6V. [ponders] this is the schematic I’m thinking of building.

UPDATE

This story was featured on Hack-A-Day! Way to go everyone!
hackaday_swharden



QRSS Receiver Works… Barely
Posted by
Scott June 10th, 2010 | 5,253 words | No Comments »


Scott was 24.71 years old when he wrote this!

I completed work on my first RF receiver, and for what it is it seems to work decently. It should be self-explanatory from the photos. It’s based around an SA602. As with everything, I don’t plan on posting schematics until the project is complete because I don’t want people re-creating junky circuits! It’s stationed at the University of Florida’s club station W4DFU and its spectrograph can be viewed in real time from the QRSS VD – Web Grabber – W4DFU page. Back to work!IMG_3475IMG_3482IMG_34792dc_qrsscapture

And some music to complete the day!



Minimalist Radio Receiver
Posted by
Scott June 9th, 2010 | 5,253 words | No Comments »


Scott was 24.71 years old when he wrote this!

Now that my minimalist QRSS transmitter is mostly functional, I’m shifting gears toward building a minimalist receiver. These are some early tests, but I’m amazed I managed to hack something together that actually works! Once it’s finished I’ll post schematics. For now, here are some photos. This receiver is based upon an SA602 and although there *IS* an op-amp on the board, I actually bypassed it completely! The SA602 seems to put out enough juice to make my PC microphone jack happy, and those cheap op-amps are noisy anyway, so awesome! Go minimalism!

Here it’s pictured with its power supply:DSCN0833

Here’s a close-up. Remember, the op-amp is there but NOT used!DSCN0832

Here’s the output from 7.040 MHz. Conditions are pretty bad right now, and I’m at my apartment using my crazy indoor antenna [pic1] [pic2]recvbig



PWM Junk in CKOUT?
Posted by
Scott May 29th, 2010 | 5,253 words | No Comments »


Scott was 24.68 years old when he wrote this!

I’m fighting with this! No matter what I do, I can’t seem to get a clear CKOUT signal as long as PWM is activated.



Measuring QRP Radio Output Power with an Oscilliscope
Posted by
Scott May 28th, 2010 | 5,253 words | No Comments »


Scott was 24.67 years old when he wrote this!

PIMP MY OSCILLOSCOPE! Yeah, see that backlight? I made it. My o-scope’s backlight hasn’t worked since I got it (for $10), so I soldered-up a row of 9 orange LEDs (I had them in a big bag) and hooked them directly up to a 3v wall wart. In retrospect I wish I had a bunch of blue LEDs… but for now I can’t get over how well this worked! Compare it to the images a few posts back – you can really see the grid lines now!oscilliscope_leds

I know this is super-basic stuff for a lot of you all, but I haven’t found a place online which CLEARLY documents this process, so I figured I’d toss-up a no-nonsense post which documents how I calculate the power output (in watts) of my QRP devices (i.e., QRSS MEPT) using an oscilloscope.qrss_qrp_circuit_scope

This is the circuit I’m trying to measure.

supply

I think I have increased power output because I’m now powering my 74HC240 from this power supply (5v, 200A) rather than USB power (which still powers the microcontroller). Let’s see!

qrss_qrp_signal

There’s the signal, and I haven’t calibrated the grid squares (this thing shifts wildly) so I have to measure PPV (peak-to-peak voltage) in “squares”. The PPV of this is about 5.3 squares.

10vSquare

I now use a function generator to create square waves at a convenient height. Using the same oscilloscope settings, I noticed that 10v square waves are about 7 squares high. My function generator isn’t extremely accurate as you can see (very fuzzy) but this is a good approximation. I now know that my signal is 5.3/7*10 volts. The rest of the math is pictured here:

powerCalcs

140mW – cool! It’s not huge… but it’s pretty good for what it is (a 2-chip transmitter). I’d like to take it up to a full watt… we’ll see how it goes. My 74HC240 is totally mutilated. I accidentally broke off one of the legs, couldn’t solder to it anymore, and thought I destroyed the chip. After getting distraught about a $0.51 component, I ripped ALL the legs off. Later I realized I was running out of these chips, and decided to try to revive it. I used a dremel with an extremely small bit (similar to a quarter-round burr in dentistry) and drilled into the black casing of the microchip just above the metal contacts, allowing me enough surface area for solder to adhere to. I’m amazed it works! Now, to get more milliwatts and perhaps even watts…

testcircuit



Drop-In Lowpass Filters?
Posted by
Scott May 27th, 2010 | 5,253 words | No Comments »


Scott was 24.67 years old when he wrote this!

So I’m sitting in class bored as ever and I’m sketching circuit diagrams and I wondered if I could design a primary simplest-case QRSS transmitter board with drop-in capabilities to change lowpass filters. In other words, I designed a circuit which you can drop in any crystal into and it magically transmits at that frequency, so it would make sense to have a drop-in LPF to match. This is what I came up with… I wonder how realistic this is? It would also give the ability to add different filters (3 pole, 5 pole, or more) without having to re-PCB anything.

drop_in_LPF



Measuring Coil Inductance with an MFJ Antenna Analyzer
Posted by
Scott May 26th, 2010 | 5,253 words | No Comments »


Scott was 24.67 years old when he wrote this!

With my limited resources I’m attempting to design, test, and build a minimalist QRSS transmitter. While working on the output filter, I’ve done a lot of reading and thinking and have determined that a pi filter (a 3 pole Chebyshev filter) will give me the low-pass characteristics I’m looking for to eliminate harmonics of the QRPP output.

aade_filter

This is the filter (with values and AADE-generated gain plot) I’m shooting for. It has about a 12dB reduction by the time it gets to 14m. My major goal is suppressing harmonics, but I thought I’d be polite to the 20m crew. The filter uses standard 1nF capacitors and an inductor of ~.44uH which according to this chart I can get by 12 turns around a small yellow T37-6 toroid. Although I’d like to use an air coil because of the cost savings, I’ll admit that I understand why toroids are used. That’s the filter, as modeled by AADE, software gracefully recommended to me today by David (VK2/VK6DI).

David also suggested that I not rely on standardized values, but rather measure inductance myself. While an inductance meter is out of my budget (of about $10), I was able to check-out W4DFU’s MFJ antenna analyzer, which can measure inductance. However, my readings were not as expected. In fact, with a total short (center connector directly to ground) it read a very high inductance measurement. Knowing that series inductance can be added to get total inductance, I suspected that this could still be useful. I used a T37-6 toroid I had on hand and wound it from 0-25 times, checking the inductance reading after every turn. After plotting and curve fitting, I corrected each value by subtracting the y-intercept and compared these points with those discussed in this chart and, whew! They’re a good match. To measure inductance with this meter, I have to measure inductance with the straight wire, then subtract this value from the final measurement.

how_to_measure_inductance

All right, back to work. Dental school homework is due tomorrow [rolls eyes]

update: this is the antenna analyzer I used:

analyzer

UPDATE 2 I built the proposed filter with wire randomly coiled around an unknown toroid (oh the challenge!), added a 50 ohm (51 ohm, close enough!) resistor as a dummy load, and hooked it up to the SWR analyzer. I noticed a swr minimum around 8mhz… As I unwound loop by loop, I got higher and higher… 9.15, 9.64, and finally BOOM! 10.215mhz swr 1.0. 10.140mhz swr was 1.1. I assume that a low SWR means that the filter passes maximum signal of that frequency into the dummy load, so by “tuning” this filter into a dummy load to minimize SWR by adjusting the coil at a fixed frequency, I maximized gain at that desired frequency. Here’s a photo of the completed circuit. The capacitors are “102″, 0.001uF and the toroid is unknown, but 9 turns seems best.

tuning_toroids



Pushing and Pulling
Posted by
Scott May 26th, 2010 | 5,253 words | No Comments »


Scott was 24.84 years old when he wrote this!

I found a way to quadruple the output power of my QRSS transmitter without changing its input parameters. Thanks to a bunch of people (most of whom are on the Knights QRSS mailing list) I decided to go with a push-pull configuration using 2 pairs of 4 gates (8 total) of a 74HC240. I’ll post circuit diagrams when I perfect it, but for now check out these waveforms!

qrss_amplified

First of all, this is the waveform before and after amplification with the 74HC240. I artificially weakened the input signal (top) with a resistor and fed it to the 74HC240. For the rest of the images, the input is 5v p-p and the output is similar, so amplification won’t be observed. The wave I’m starting with is the output of a microcontroller which is non-sinusoidal, but this can be fixed later with lowpass filtering.

qrss_74hc240

Here you can see the test circuit I’m using. It should be self-explanatory.

qrss_inPhase

Here’s the output of the microcontroller compared to the in-phase output of the 74HC240

qrss_out_of_phase

Here are the two outputs of the 74HC240. 4 of the gates are used to create output in-phase with the input, and the other four are used to create out-of-phase wave. Here are the two side by side. The top is 0 to 5v, the bottom is 0 to -5v, so we have a push-pull thing going on… woo hoo!

qrss_out_of_phase_overlap

The waves, when overlapped, look similar (which I guess is a good thing) with a slight (and I mean VERY slight) offset of the out-of-phase signal. I wonder if this is caused by the delay in the time it takes to trigger the 74HC240 to make the out-of-phase signal? The signal I’m working with is 1MHz.

Okay, that’s it for now. I’m just documenting my progress. 73



Solar Powered QRSS Beacon
Posted by
Scott May 24th, 2010 | 5,253 words | No Comments »


Scott was 24.66 years old when he wrote this!

Haray! I’m making awesome progress with my QRSS transmitter design. Because my current transmitter (previous few posts) was randomly freezing-up (likely due to the oscillator stopping its oscillating due to being overloaded) so I moved the oscillator from in-chip to an external oscillator. It’s been made small enough to fit in an altoids tin, and I already tested it with the solar panel and it works! Awesome! Here are some photos. Again, when I perfect the design I’ll post final schematics.

DSCN0537

DSCN0533

DSCN0539

Sticking out are wires for power and an antenna on each side. The goal is to hang the device between two trees by its own antenna.

DSCN0535

That’s my new chip development board. I made it with what I needed on it. It’s so convenient! It uses 5v of power from the USB port too!

DSCN0532

Alltogether I’ve tested the device and confirmed it transmits radio when the solar panel is illuminated. I’m thinking of making it more effective by adding more panels… but that’s it for now!



First QRSS Spot!
Posted by
Scott May 22nd, 2010 | 5,253 words | No Comments »


Scott was 24.66 years old when he wrote this!

I’m so excited! This little transmitter I made and programmed to transmit my call sign (AJ4VD) and a picture of a gator got its first spotting tonight! I’m so excited. It was reported by W4HBK in Pensacola, FL. It’s only 300 miles away, but it’s a start! I’m keeping my fingers crossed and maybe someday soon I’ll hear from Europe. Note that I *JUST* got this thing working this afternoon. I’m so excited!

spotNice

And again, here’s the transmitter in its glorious simplicity:

simple_qrss_transmitter-1



Debut of the AJ4VD QRSS Gator
Posted by
Scott May 22nd, 2010 | 5,253 words | No Comments »


Scott was 24.84 years old when he wrote this!

I re-wrote the code from the previous entry to do several things. Once of which was to make a gator rather than a fish. It’s more appropriate since I’m planning on housing the transmitter at the University of Florida. To do it, I drew a gator in paint and wrote a python script to convert the image into a series of points. I’ll post it later. One thing to note was that size was a SERIOUS issue. I only have two thousand bytes of code, and every point of that gator was a byte, so it was a memory hog. I helped it dramatically by using repeating segments wherever possible, and some creative math to help out the best I could (i.e., the spines on the back) Here’s what it looks like, and the code below it…

aj4vd_gator

#include <avr/io.h>
#include <util/delay.h>

// front top LED - PA0
// inside top LED - PA1
// inside bot LED - PA2
// front bot LED - PA3

unsigned long int t_unit; // units of time
const int tDit = 100; //units for a dit
const int tDah = 255; //units for a dah
char fsk; // degree of frequency shift to use for CW
char fsk2; // degree of frequency shift to use for HELL

char light = 0; // which lights are on/off

void delay(){
        _delay_loop_2(t_unit);
        }

void blink(){
	return;
	if (light==0){
    	PORTA|=(1<<PA0); //on
    	PORTA|=(1<<PA1); //on
		PORTA&=~(1<<PA2); //off
		PORTA&=~(1<<PA3); //off
		light=1;
	} else {
    	PORTA|=(1<<PA2); //on
    	PORTA|=(1<<PA3); //on
		PORTA&=~(1<<PA0); //off
		PORTA&=~(1<<PA1); //off
		light=0;

	}
}

void tick(unsigned long ticks){
        while (ticks>0){
                delay();
                delay();
                ticks--;
        }
}

void pwm_init() {
    //Output on PA6, OC1A pin (ATTiny44a)
    OCR1A = 0x00; //enter the pulse width. We will use 0x00 for now, which is 0 power.
    TCCR1A = 0x81; //8-bit, non inverted PWM
    TCCR1B = 1; //start PWM
}

void set(int freq, int dly){
        OCR1A = freq;
        tick(dly);
}

void fish(){
	char mult = 3;

	char f2[]={2, 3, 4, 5, 6, 7, 4, 3, 7, 4, 7, 7, 6, 5, 4, 3, 2, 2, 2, 3, 3, 3, 2, 2, 2, 3, 3, 3, 2, 2, 2, 3, 4, 5, 6, 7, 8, 4, 9, 5, 9, 6, 9, 6, 9, 6, 9, 8, 8, 7, 7, 6, 5, 4, 3, 3, 3, 4, 5, 5};

	for (int i=0;i<sizeof(f2);i++) {
		OCR1A = f2[i]*mult;
		blink();
		tick(20);
		OCR1A = 1*mult;
		blink();
		tick(20);
		}

	char f3[]={1,2,3,4,3,2};

	char offset=0;
	while (offset<9){
		for (char j=0;j<3;j++){
			for (char i=0;i<sizeof(f3);i++){
				char val = (f3[i]+5-offset)*mult;
				if (val<mult || val > 10*mult){val=mult;}
				OCR1A = val;
				blink();
				tick(20);
				OCR1A = 1*mult;
				blink();
				tick(20);
				}
			}
		offset++;
	}

}

void id(){
        char f[]={0,0,1,2,0,1,2,2,2,0,1,1,1,1,2,0,1,1,1,2,0,2,1,1,0,0};
        char i=0;
        while (i<sizeof(f)) {
                blink();
                if (f[i]==0){OCR1A = 0;tick(tDah);}
                if (f[i]==1){OCR1A = fsk;tick(tDit);}
                if (f[i]==2){OCR1A = fsk;tick(tDah);}
                blink();
                OCR1A=0;
				tick(tDit);
                i++;
                }
}

void slope(){
        char i=0;
        while (i<25){
                OCR1A = 255-i;
                i++;
        }
        while (i>0){
                i--;
                OCR1A = 255-i;
        }
}

int main(void)
{
        DDRA = 255;
		blink();
        pwm_init();
        t_unit=1000;fsk=10;id(); // set to fast and ID once
        //fsk=50;//t_unit = 65536; // set to slow for QRSS
		t_unit=60000;

        while(1){;
                fish();
                id();
        }

        return 1;
}


Debut of the AJ4VD QRSS Fish
Posted by
Scott May 19th, 2010 | 5,253 words | 1 Comment »


Scott was 24.65 years old when he wrote this!

Finally! After a few years tumbling around in my head, a few months of reading-up on the subject, a few weeks of coding, a few days of bread-boarding, a few hours of building, a few minutes of soldering, and a few seconds of testing I’ve finally done it – I’ve created my first QRSS transmitter! I’ll describe it in more detail once I finalize the design, but for now an awesome working model. It’s ~100% digital, consisting of 2 ICs (an ATTiny44a for the PWM-controlled frequency modulation, and an octal buffer for the preamplifier) followed by a simple pi low-pass filter. I don’t want to waste time typing – let’s show some pics!

qrss desk

My desk is a little messy. I’m hard at work! Actually, I’m thinking of building another desk. I love the glass because I don’t have to worry (as much) about fires. Scary, I know…

qrss transmitter

This is the transmitter. The box is mostly empty space, but it consists of the circuit, an antenna connection, a variable capacitor for center frequency tuning, and a potentiometer for setting the degree of frequency shift modulation.

qrss fish

AMAZING! Yeah, that’s a fishy. Specifically a goldfish (the cracker). It’s made with a single tone, shifting rapidly (0.5 sec) between tones. So cool. Anyway, I’m outta here for now – getting back to the code! I think I’ll try to make a gator…

As it is, here’s the code. It sends my ID quickly, some fish, then my ID in QRSS speed using PWM. You can figure out the pinout… I’ll document it with circuit diagrams soon!

#include <avr/io.h>
#include <util/delay.h>

const int tDit = 270/3;
const int tDah = 270;

char fsk;
unsigned long int t_unit;

void delay(){
	_delay_loop_2(t_unit);
	}

void blink(){
  	PORTA^=(1<<0);
  	PORTA^=(1<<1);
  	PORTA^=(1<<2);
  	PORTA^=(1<<3);
}

void tick(unsigned long ticks){
	while (ticks>0){
		delay();
		delay();
		ticks--;
	}
}

void pwm_init() {
    //Output on PA6, OC1A pin (ATTiny44a)
    OCR1A = 0x00; //enter the pulse width. We will use 0x00 for now, which is 0 power.
    TCCR1A = 0x81; //8-bit, non inverted PWM
    TCCR1B = 1; //start PWM
}

void set(int freq, int dly){
	OCR1A = freq;
	tick(dly);
}

void fish(){
	char f[]={0,0,0,4,5,3,6,2,7,1,5,6,8,1,8,1,8,1,8,1,8,2,7,3,6,2,7,1,8,1,8,4,5,2,3,6,7,0,0,0};
	char i=0;
	while (i<sizeof(f)) {
		i++;
		OCR1A = 255-f[i]*15;
		blink();
		tick(20);
		}
}

void id(){
	char f[]={0,0,1,2,0,1,2,2,2,0,1,1,1,1,2,0,1,1,1,2,0,2,1,1,0,0};
	char i=0;
	while (i<sizeof(f)) {
		blink();
		if (f[i]==0){OCR1A = 255;tick(tDah);}
		if (f[i]==1){OCR1A = 255-fsk;tick(tDit);}
		if (f[i]==2){OCR1A = 255-fsk;tick(tDah);}
		blink();
		OCR1A = 255;tick(tDit);
		i++;
		}
}

void slope(){
	char i=0;
	while (i<25){
		OCR1A = 255-i;
		i++;
	}
	while (i>0){
		i--;
		OCR1A = 255-i;
	}
}

int main(void)
{
	DDRA = 255;
  	PORTA^=(1<<0);
  	PORTA^=(1<<1);
	pwm_init();

	t_unit=2300;fsk=50;id(); // set to fast and ID once

	fsk=50;t_unit = 65536; // set to slow for QRSS

	while(1){
		id();
		for (char i=0;i<3;i++){
			fish();
			}
	}

	return 1;
}


Microcontroller Clocking a Transmitter?
Posted by
Scott April 3rd, 2010 | 5,253 words | 2 Comments »


Scott was 24.52 years old when he wrote this!

UPDATE I shouldn’t claim this idea as novel. After googling around, I found another guy who’s doing the same thing, and now that I read his page I remember reading his page before, which is likely where I got the idea in the first place. Anyhow, I want to give him credit ASAP and hope that my project can turn out successfully like his! His project page is at http://clayton.isnotcrazy.com/mept_v1.

Random idea: I only have a moment to write but I have to get this on paper. The core of any transmitter is usually an oscillator circuit, and in simple transmitters (i.e., QRSS devices), it’s often a crystal. Frequency adjustment is accomplished by adjusting capacitance to ground on one of the crystal legs. Simple oscillators such as the Colpitts design (based on an NPN transistor) are often used. (pictured)
NPN_Colpitts_oscillator_collector_coil However in my quest to design a minimal-case long-distance transmitter, I’m trying to think outside the box. Although it’s relatively simple, that’s still several parts just to make an oscillating sine wave from a crystal. The result still has to be preamplified before sending the signal to an antenna. I’m starting to wonder about the oscillator circuitry inside a microcontroller which has the ability to be clocked by an external crystal. For example, take the pinout diagram from an Atmel ATTiny2313 AVR: :attiny-2313

See how pins 4 and 5 allow for a crystal, and pin 6 has a “CKOUT” feature?” I’m still not sure exactly what the waveform of its output looks like. The datasheet is almost intentionally cryptic. About the only thing I’ve been able to discover from the Internet is that it’s sufficient to clock another microcontroller. However, if it’s an amplified sine wave output, how cool is it that it might be able to produce RF at the same frequency at which it’s clocked?

Taking it a step further, I wonder if I could write code for the microcontroller to allow it to adjust its own clock speed / frequency output by adjusting capacitance on one of the legs of the crystal. A reverse-biased LED with variable voltage pressed against it from an output pin of the microcontroller might accomplish this. How cool would this be – a single chip transmitter and frequency-shifting keyer all in one? Just drop in a crystal of your choice and BAM, ready to go. Believe it or not I’ve tested this mildly and it’s producing enough RF to be able to be picked up easily by a receiver in the same room, but I’m still unsure of the power output or the waveform. If the waveform is an amplified sine wave I’m going to pass out. More likely it’s a weak sine wave needing a preamplifier still, or perhaps even amplified square waves in need of lowpass filtering…

My wife snapped a photo of me working! It’s a funny pic – I’m in my own little world somtimes…IMG_3206

Here’s the power supply I’m using:IMG_3250

Here’s my transmitter breadboarded-out:IMG_3245

Alltogether:IMG_3257

And close to the oscilliscope…IMG_3241

Anyway, it’s just my thoughts tonight. I had to get it out. 73!



Lubnaan Shaikhto’s Project
Posted by
Scott March 15th, 2010 | 5,253 words | No Comments »


Scott was 24.47 years old when he wrote this!

I’ve been exchanging emails with Lubnaan Shaikhto for a little while regarding a project involving a realtime spectrograph controlled by a microcontroller (ATTiny2313). He had a few questions, I had a few recommendations, and several weeks went by and I heard nothing… until today when I saw this awesome youtube video of his incredible success! The guy built his own USB AVR programmer just for this project too. Double score! Way to go Lubnaan!

LedDisp_schematics
100_3478 copy
100_3479 copy



Rainy Mornings and Boring Bicuspids
Posted by
Scott January 30th, 2010 | 5,253 words | No Comments »


Scott was 24.35 years old when he wrote this!

Alas, another fleeting patch of free time has been bestowed upon me. Just like last semester, this semester (my second in a 4 year dental school) started off tough from day one. After Christmas break it was hard to walk into class at 8am and hit the ground running, but I managed to get the hang of it after a few days. I’ve heard medical school being described as “trying to drink from a fire hydrant”, but I think a more appropriate analogy would involve a treadmill set too fast. You have to work as hard as you can as soon as your feet touch the ground, and you might be able to keep up for now but you don’t know how much longer you can go before you tumble. I never really tumble, but I always feel like I’m about to. Overall, I can’t complain. I’ve managed to compartmentalize dental school into a chunk of my schedule (albeit a massive chunk), leaving time to spend with my family (wife) and when she’s at work, time to spend playing with electronics (which seems to be radio at this stage of my life).

Rather than bore the internet with descriptions of what I’ve been up to in dental school, I’ll focus on the interesting aspects of my most recent endeavors. A few weeks ago I took the final (third-level, extra class) amateur radio license exam. It’s a bunch of technical questions about radio circuitry, antenna theory, and other random stuff. You can see what I mean by taking an online practice test! I passed [whew!] and applied for a new call sign (extra class operators can have shorter call signs). The FCC gave me a VD. AJ4VD that is! Yes, my old call sign KJ4LDF has gone out the window as I am now AJ4VD! In morse code, that’s [.- .--- ....- ...- -..]. Speaking of code, I made my first contact in Morse code from my apartment! Let me set the scene for you…
Ten_Tec_Century_21
This is the radio I’m using. It’s a Ten-Tec Century 21 HF CW transceiver which puts out ~30W.
antennaBig
I’m using a super-cheap but surprisingly functional homebrew base-loaded vertical antenna! The main vertical element is quarter-inch copper pipe from Home Depot (a couple bucks) cut with 1” to spare from my 10ft ceiling. Therefore, it’s a less-than quarter-wave vertical element, requiring a tuning coil (variable inductor at the base)…
antennaBigger
Here you can start to see the tuning coils. Briefly, I scraped a deep gash in the copper pipe such that a big glob of solder would adhere to it, and stuck a wire (yellow, coated) into that solder so it’s a good connection to the pipe. I then started wrapping the wire around a few toilet paper rolls [it's all I could find at the time!] adding tap points (regions of exposed wire) every other turn. This functioned somewhat, but didn’t allow for fine-tuning (pun intended). I therefore scrapped the bottom half of the cardboard cylinder/coil and constructed a slightly more elegant solution…
antennaCoil
That’s an Olvaltine container. Yeah, I know, “More chocolaty Olvaltine please!” I used a rotary tool to scrape some measured/templated gashes on each side to give the wire (picture frame hanging wire from Target, 50′ for $1.99) something to rest in. It turned out not to be enough, so I hot-glued the wire into the holes. This gives me a lot of exposed wire space to allow me to “tap” the coil wherever I want. By modifying where I clip onto the coil, I modify the length of wire in the coil that’s used, therefore modifying the inductance of the coil, allowing for some tuning capabilities. Although it has a narrow tuning range, using the current setup I’m able to get my SWR down to 1:1 on 40m (nice!).

I made a couple of contacts since I got the rig last night. First was K4KOR in central TN, who was calling CQ. I replied (slowly), and he came back to me (blazing fast Morse code). I was unable to copy ANYTHING he said (I’m not that good of an auditory decoder yet!) I’m sure he’s incredibly nice and it wasn’t intentional, but I had to give up the QSO. I know he copied my call, and I copied his, but I didn’t copy ANYTHING else he said. Does that count as my first contact? This morning I fired up the rig at 9:15 and heard W4HAY calling CQ from Northeast TN. I replied, stating that I’m new to CW so go slowly, and he was AMAZINGLY nice at sending me code at a snails pace. I was able to copy 90% of what he said, and will consider him my first solid contact! How cool is that?

And, as a closing note, Misia performing “Everything” (my favorite song) in Seoul, Korea:



CEJ, QRSS, and Life Recontemplation
Posted by
Scott January 1st, 2010 | 5,253 words | 2 Comments »


Scott was 24.27 years old when he wrote this!

Yes, I did it. I’m probably the first (and let’s hope the last) human to ever write CEJ (the abbreviation for the cemento-enamel junction, a dentistry term) immediately before the letters QRSS (extremely slow speed Morse code transmissions, a radio frequency term). Anyhow, thanks in part to the temporary cessation of the tortuously monotonous dental school I’m enrolled in, I have had some time to put into random obscure hobbies. For example, I’ve become somewhat obsessed with QRSS, an obscure sub-niche of amateur radio (ham radio).

I only have a couple of minutes to write, so I’ll be concise. In brief, QRSS uses extremely simple radio transmitters at extremely low power to send an extremely slow Morse code message over an extremely large distance to extremely sensitive receivers which are extremely dependent on computers to decode. While you might be able to send a voice message across the ocean with ~100 watts of power, there are guys sending messages with 100 milliwatts (one tenth of a watt! you can get more than that from a couple AA batteries!). The theory is that if you send the signals slow enough, and average the audio data (fast Fourier transformation) over a long enough time, weak signals below the noise threshold will stand out enough to be copied visually.
qrss_kj4ldf

Without going into more detail than that, this is the kind of stuff I’ve been copying the last couple days. The image is a slow time-averaged waterfall-type FFT display of 10.140mhz from a Mosley-pro 67 yagi mounted ~180 ft in the air connected to a Kenwood TS-940S transceiver sending data to a PC through a SignaLink USB sound card. Red ticks represent 10 seconds. Therefore the frame above is ~10 minutes of audio. The trace on the image is from two different transmitters. The upper trace is from VA3STL’s QRSS quarter-watt transmitter from Canada described here and pictured below. The lower trace is from WA5DJJ’s QRSS quarter-watt transmitter in New Hampshire, described and pictured here. Notice my call sign (KJ4LDF) at the bottom of the page!
qrss_transmitter

^^^ That’s the ACTUAL transmitter I’m hearing from Canada!!!

I don’t know why I’m drawn to QRSS. Perhaps it’s the fact that it’s a hobby which only a handful of people have ever participated in. It uses computers and software, but unlike SDRs (software-defined radios) they don’t require complicated equipment, and a QRSS transmitter or receiver can be built from a few bucks’ worth of parts.

HELPFUL FOR ANYONE WHO USES ARGO!!! 10_01_01_00009There’s a popular QRSS “grabber” software for Windows called Argo. It dumps out screenshots of itself every few minutes, but doesn’t assemble them together!!!!! It’s so annoying. I therefore took it upon myself to write a script to assemble several (or thousands) of Argo screen dumps together as a single image. It’s a script for ImageJ. To use it, first install MBF’s ImageJ. Open ImageJ, drag and drop a DIRECTORY of screenshots / captures into the program to open them as a stack, make a new macro, copy/paste the following code into it, and hit CTRL+R to run it, and poof! The output is a gorgeous panoramic shot like below.long

And here’s the script to automate the process…

makeRectangle(13, 94, 560, 320);
run("Crop");
rename("source");
frames = nSlices();
newImage("long", "RGB White", (frames-1)*560, 320, 1);
for (i=0; i<frames; i++) {
	selectWindow("source");
	setSlice(i+1);
	run("Select All");
	run("Cut");
	selectWindow("long");
	run("Paste");
	makeRectangle(i*560, 0, 560, 320);
}
//run("8-bit");
//run("Enhance Contrast", "saturated=0.5");
selectWindow("source");
close();

As far as life recontemplation goes, I’m discovering that it’s not the attainment of a goal that gives me pleasure; it’s the pursuit of the goal. Perhaps that’s why I peruse hobbies (goals?) which are notoriously difficult, and further challenge myself by doing things in weird, quirky ways. For example, I’d love to get into radio, BUT I HAVE NO MONEY!. Yeah, an all-band 100-watt HF/VHF/UHF rig would be nice, but I don’t have hundreds of dollars to fork over. Worse yet, in the technical sense, I do, I’m just trying to be responsible and saving it for emergencies / tuition and waiting until I’m a dentist (a.k.a. have a job) before I spend money on things that make me happy. Anyway, without complaining I built a non-elegant but surprisingly functional base-loaded vertical HF antenna for my apartment balcony (don’t worry neighbors, it’s taken inside after every use). It’s mainly for receive, but I don’t see any reason why it couldn’t be used for QRP transmitting! Here it is on my balcony…
ant_1

As you can see, it’s ghetto. Yes, that’s an antenna made from copper pipe, wire, and toilet paper rolls. I’ve wound the wire around the base and created various tap points so it serves as a variable inductor depending on where I gator-clip the radio. Not pictured are 33′ radials running inside my apartment serving as adequate grounding for 40m operation. The antenna feeds into a Pixie II direct conversion receiver / QRP transmitter which dumps its output to a laptop computer. Note that I did *NOT* use this setup to receive my beautiful QRSS signals. With that being said, I have copied PSK-31 transmissions from Canada with this setup. It works way better than a long / random wire antenna because it dramatically reduces noise. Here’s a closeup of the tap points on the inductor base…
ant_2

That’s it for today folks! Back to my crazy projects. Take care!

UPDATE: VA3STL mentioned me on his site! Woo hoo!



HF CW on the Cheap
Posted by
Scott December 10th, 2009 | 5,253 words | 4 Comments »


Scott was 24.21 years old when he wrote this!

Okay, here’s a preview of my project plans for Christmas break! My goal is to make a fun and comfortably functional HF CW transmitter / direct-conversion receiver capable of working any HF band by merging the incredibly simple and cheap (~$10) Pixie II CW transceiver with a SI 570 digital programmable oscillator controlled by an ATTiny 2313 microcontroller! (it’s often used in SDRs controlled by USB as seen here).

AUDIO FILES!!! [80m.mp3] and [40m.mp3] are already ready already!

Preliminary work demonstrates a functional receiver powered by a crystal. I don’t think the currently-configured digital oscillator is putting out enough power to run the circuit, but it’ll take more time to get that up and running. For now, here are some photos of what I’ve got working and real sound clips of the thing are below. I’m happy with the case I built it in (thanks Ron!), and happy with my level drilling of the holes for power, output, and the CW key!
cw_everything
Briefly, the device is powered by a 9V battery. It’s hooked up to an 80m dipole antenna. Output is fed into a computer sound card for amplification / PSK31 analysis.
cw_coke
cw_close
cw_open2
The internals reveal that it’s a simple circuit powered by a single crystal. More crystals are tucked in the case, stuck in foam, for easy transport.
40mPSK
Decoding of PSK31 is happening here, using output from my circuit with the 40m crystal in it.

AUDIO FILES approx. 1 minute in length from my circuit:
>> [80m.mp3]
>> [40m.mp3]

Wish me luck! This project is just beginning…

now for a random video/song:



Mental Viscosity
Posted by
Scott September 23rd, 2009 | 5,253 words | 1 Comment »


Scott was 24.00 years old when he wrote this!

A few weeks into dental school I feel I’m fairing decently. I have reached a point where I know everything will be okay, but am still disappointed at the [immense] amount of time it requires. There are so many things I wish I could do, but all of my projects need to be placed on a 4-year hiatus. I can bask in the satisfaction of the few projects I completed this summer, and I only hope that it’s enough to last me for four years. Dentistry, while important, is nothing more than emulation/repetition of what everybody else does. I simply have to satisfy my creative and ingenuitive desires in my hobbies, whatever they may be. For now, this website will cease to grow. Perhaps when I become more in control of my studies I will contribute to it, but in all likelihood I won’t be able to do anything worth writing about until 4 years from now [sigh]. With that being said, adieu, and goodnight.

I realized I never posted video of my finished prime number generator, so here it is. Full details are described on the project page. In brief, the 2-digit display on the left is the last two digits (in base-10, decimal) of a number currently being tested for primeness. This number is also displayed on the bottom red bar above the yellow lights (in base-2, binary). Once proven to be prime (by attempting to divide it by every number between 2 and its square root, every 1000th attempted number shown in yellow lights in binary), it’s loaded onto the top row of red lights (binary) and on the character LCD. N represents the Nth prime, with V representing its value. Half way through the video, the display says that the 16,595,044′th prime (N) equals 306,692,621 (V). Don’t believe it? Check my work.



DIY ECG Machine On The Cheap
Posted by
Scott August 14th, 2009 | 5,253 words | 34 Comments »


Scott was 23.89 years old when he wrote this!

Note from the Author: This page documents how I made an incredibly simple ECG machine with a minimum of parts to view the electrical activity of my own heart. Feel free to repeat my experiment, but do so at your own risk. There are similar projects floating around on the internet, but I aim to provide a more complete, well-documented, and cheaper solution, with emphasis on ECG processing and analysis, rather than just visualization. If you have any questions or suggestions please contact me. Also, if you attempt this project yourself I’d love to post your results! Good luck!
–Scott

Background

You’ve probably seen somebody in a hospital setting hooked up to a big mess of wires used to analyze their heartbeat. ecgmanThe goal of such a machine (called an electrocardiograph, or ECG) is to amplify, measure, and record the natural electrical potential created by the heart. Note that cardiac electrical signals are different than heart sounds, which are listened to with a stethoscope. The intrinsic cardiac pacemaker system is responsible for generating these electrical signals which serve to command and coordinate contraction of the four chambers at the heart at the appropriate intervals [atria (upper chambers) first, then the ventricles (lower chambers) a fraction of a second later], and their analysis reveals a wealth of information about cardiac regulation, as well insights into pathological conditions. Each heartbeat produces a similar pattern in the ECG signal, called a PQRST wave. ecg_principle_slow [picture] The smooth curve in the ECG (P) is caused by the stimulation of the atria via the Sinoatrial (SA) node in the right atrium. There is a brief pause, as the electrical impulse is slowed by the Atrioventricular (AV) node and Purkinje fibers in the bundle of His. The prominent spike in the ECG (the QRS complex) is caused by this step, where the electrical impulse travels through the inter-ventricular septum and up through the outer walls of the ventricles. The sharp peak is the R component, and exact heart rate can be calculated as the inverse of the R-to-R interval (RRi). Fancy, huh?

Project Goal

The goal of this project is to generate an extremely cheap, functional ECG machine made from common parts, most of which can be found around your house. This do-it-yourself (DIY) ECG project is different than many others on the internet in that it greatly simplifies the circuitry by eliminating noise reduction components, accomplishing this via software-based data post-processing. Additionally, this writeup is intended for those without any computer, electrical, or biomedical experience, and should be far less convoluted than the suspiciously-cryptic write-ups currently available online. In short, I want to give everybody the power to visualize and analyze their own heartbeat!

The ECG of my own heart:

ecg31

Video Overview

I know a lot of Internet readers aren’t big fans of reading. Therefore, I provided an outline of the process in video form. Check out the videos, and if you like what you see read more!

Video 1/3: Introducing my ECG machine

Video 2/3: Recording my ECG

Video 3/3: Analyzing my ECG

Electrical Theory

Measurement: The electrical signals which command cardiac musculature can be detected on the surface of the skin. In theory one could grab the two leads of a standard volt meter, one with each hand, and see the voltage change as their heart beats, but the fluctuations are rapid and by the time these signals reach the skin they are extremely weak (a few millionths of a volt) and difficult to detect with simple devices. Therefore, amplification is needed.

Amplification: A simple way to amplify the electrical difference between two points is to use a operational amplifier, otherwise known as an op-amp. The gain (multiplication factor) of an op-amp is controlled by varying the resistors attached to it, and an op-amp with a gain of 1000 will take a 1 millivolt signal and amplify it to 1 volt. There are many different types of microchip op-amps, and they’re often packaged with multiple op-amps in one chip (such as the quad-op-amp lm324, or the dual-op-amp lm358n). Any op-amp designed for low voltage will do for our purposes, and we only need one.

Noise: Unfortunately, the heart is not the only source of voltage on the skin. Radiation from a variety of things (computers, cell phones, lights, and especially the wiring in your walls) is absorbed by your skin and is measured with your ECG, in many cases masking your ECG in a sea of electrical noise. The traditional method of eliminating this noise is to use complicated analog circuitry, but since this noise has a characteristic, repeating, high-frequency wave pattern, it can be separated from the ECG (which is much slower in comparison) using digital signal processing computer software!

Digitization: Once amplified, the ECG signal along with a bunch of noise is in analog form. You could display the output with an oscilloscope, but to load it into your PC you need an analog-to-digital converter. Don’t worry! If you’ve got a sound card with a microphone input, you’ve already got one! It’s just that easy. We’ll simply wire the output of our ECG circuit to the input of our sound card, record the output of the op-amp using standard sound recording software, remove the noise from the ECG digitally, and output gorgeous ECG traces ready for visualization and analysis!

Parts/Cost

I’ll be upfront and say that I spent $0.00 making my ECG machine, because I was able to salvage all the parts I needed from a pile of old circuit boards. If you need specific components, check your local RadioShack. If that’s a no-go, hit-up Digikey (it’s probably cheaper too). Also, resistor values are flexible. Use mine as a good starter set, and vary them to suit your needs. If you buy everything from Digikey, the total cost of this project would be about $1. For now, here’s a list of all the parts you need:

  • 1x low voltage op-amp LM358N $0.40
  • 1x 100kOhm resistor (brn,blk,yel) virtually free
  • 1x 1kOhm resistor (brn,blk,red) virtually free
  • 1x 0.1uF capacitor (104Z) virtually free
  • Microphone cable to get from the op-amp to your PC
  • Electrodes 3 pennies should do. ($0.03)

Making the Device

Keep in mind that I’m not an electrical engineer (I have a masters in molecular biology but I’m currently a dental student if you must know) and I’m only reporting what worked well for me. I don’t claim this is perfect, and I’m certainly open for (and welcome) suggestions for improvement. With that in mind, here’s what I did!

img_2694

This is pretty much it. First off is a power source. If you want to be safe, use three AAA batteries in series. If you’re a daredevil and enjoy showing off your ghettorigging skills, do what I did and grab 5v from a free USB plug! Mua ha ha ha. The power goes into the circuit and so do the leads/electrodes connected to the body. You can get pretty good results with only two leads, but if you want to experiment try hooking up an extra ground lead and slap it on your foot. More on the electrodes later. The signal from the leads is amplified by the circuit and put out the headphone cable, ready to enter your PC’s sound card through the microphone jack!

img_2686

Note how I left room in the center of the circuit board. That was intentional! I wanted to expand this project by adding a microcontroller to do some on-board, real-time analysis. Specifically, an ATMega8! I never got around to it though. Its purpose would be to analyze the output of the op-amp and graph the ECG on a LCD screen, or at least measure the time between beats and display HR on a screen. (More ideas are at the bottom of this document.) Anyway, too much work for now, maybe I’ll do it one day in the future.

ECG circuit diagram:

simple_ecg_circuit

This is the circuit diagram. This is a classical high-gain analog differential amplifier. It just outputs the multiplied difference of the inputs. The 0.1uF capacitor helps stabilize the signal and reduce high frequency noise (such as the audio produced by a nearby AM radio station). Use Google if you’re interested in learning exactly how it works.

ECG schematic:

simple_ecg_circuit2

This is how I used my LM358N to create the circuit above. Note that there is a small difference in my board from the photos and this diagram. This diagram is correct, but the circuit in some of the pictures is not. Briefly, when I built it I accidentally connected the (-) lead directly to ground, rather than to the appropriate pin on the microchip. This required me to place a 220kOhm between the leads to stabilize the signal. I imagine if you wire it CORRECTLY (as shown in these circuit diagrams) it will work fine, but if you find it too finicky (jumping quickly from too loud to too quiet), try tossing in a high-impedance resistor between the leads like I did. Overall, this circuit is extremely flexible and I encourage you to build it on a breadboard and try different things. Use this diagram as a starting point and experiment yourself!

The Electrodes:

img_2704

You can make electrodes out of anything conductive. The most recent graphs were created from wires with gator clips on them clamping onto pennies (pictured). Yeah, I know I could solder directly to the pennies (they’re copper) but gator clips are fast, easy, and can be clipped to different materials (such as aluminum foil) for testing. A dot of moisturizing lotion applied to the pennies can be used to improve conduction between the pennies and the skin, but I didn’t find this to be very helpful. If pressed firmly on the body, conduction seems to be fine. Oh! I just remembered. USE ELECTRICAL TAPE TO ATTACH LEADS TO YOUR BODY! I tried a million different things, from rubber bands to packaging tape. The bottom line is that electrical tape is stretchy enough to be flexible, sticky enough not to fall off (even when moistened by the natural oils/sweat on your skin), and doesn’t hurt that bad to peel off.

Some of the best electrodes I used were made from aluminum cans! Rinse-out a soda can, cut it into “pads”, and use the sharp edge of a razor blade or pair of scissors to scrape off the wax coating on all contact surfaces. Although a little unconformable and prone to cut skin due to their sharp edges, these little guys work great!

Hooking it Up

This part is the most difficult part of the project! This circuit is extremely finicky. The best way to get it right is to open your sound editor (In Windows I use GoldWave because it’s simple, powerful, and free, but similar tools exist for Linux and other Unix-based OSes) and view the low-frequency bars in live mode while you set up. When neither electrode is touched, it should be relatively quiet. When only the + electrode is touched, it should go crazy with noise. When you touch both (one with each hand) the noise should start to go away, possibly varying by how much you squeeze (how good of a connection you have). The whole setup process is a game between too much and too little conduction. You’ll find that somewhere in the middle, you’ll see (and maybe hear) a low-frequency burst of noise once a second corresponding to your heartbeat. [note: Did you know that's how the second was invented? I believe it was ] Once you get that good heartbeat, tape up your electrodes and start recording. If you can’t get it no matter what you do, start by putting the ground electrode in your mouth (yeah, I said it) and pressing the + electrode firmly and steadily on your chest. If that works (it almost always does), you know what to look for, so keep trying on your skin. For short recordings (maybe just a few beats) the mouth/chest method works beautifully, and requires far less noise reduction (if any), but is simply impractical for long-term recordings. I inside vs. outside potential is less susceptible to noise-causing electrical radiation. Perhaps other orifices would function similarly? I’ll leave it at that. I’ve also found that adding a third electrode (another ground) somewhere else on my body helps a little, but not significantly. Don’t give up at this step if you don’t get it right away! If you hear noise when + is touched, your circuit is working. Keep trying and you’ll get it eventually.

Recording the ECG

This is the easy part. Keep an eye on your “bars” display in the audio program to make sure something you’re doing (typing, clicking, etc) isn’t messing up the recording. If you want, try surfing the net or playing computer games to see how your heart varies. Make sure that as you tap the keyboard and click the mouse, you’re not getting noise back into your system. If this is a problem, try powering your device by batteries (a good idea for safety’s sake anyway) rather than another power source (such as USB power). Record as long as you want! Save the file as a standard, mono, wave file.

Digitally Eliminating Noise

Now it’s time to clean-up the trace. Using GoldWave, first apply a lowpass filter at 30 Hz. This kills most of your electrical noise (> 30hz), while leaving the ECG intact (< 15Hz). However, it dramatically decreases the volume (potential) of the audio file. Increase the volume as necessary to maximize the window with the ECG signal. You should see clear heartbeats at this point. You may want to apply an auto-gain filter to normalize the heartbeats potentials. Save the file as a raw sound file (.snd) at 1000 Hz (1 kHz) resolution.

Presentation and Analysis

Now you’re ready to analyze! Plop your .snd file in the same folder as my [ecg.py script], edit the end of the script to reflect your .snd filename, and run the script by double-clicking it. (Keep in mind that my script was written for python 2.5.4 and requires numpy 1.3.0rc2 for python 2.5, and matplotlib 0.99 for python 2.5 – make sure you get the versions right!) Here’s what you’ll see!

diy_ecg_sample_trace

This is a small region of the ECG trace. The “R” peak is most obvious, but the details of the other peaks are not as visible. If you want more definition in the trace (such as the blue one at the top of the page), consider applying a small collection of customized band-stop filters to the audio file rather than a single, sweeping lowpass filter. Refer to earlier posts in the DIY ECG category for details. Specifically, code on Circuits vs. Software for noise reduction entry can help. For our purposes, calculating heart rate from R-to-R intervals (RRIs) can be done accurately with traces such as this.

diy_ecg_heart_rate_over_time

Your heart rate fluctuates a lot over time! By plotting the inverse of your RRIs, you can see your heart rate as a function of time. Investigate what makes it go up, go down, and how much. You’d be surprised by what you find. I found that checking my email raises my heart rate more than first-person-shooter video games. I get incredibly anxious when I check my mail these days, because I fear bad news from my new university (who knows why, I just get nervous about it). I wonder if accurate RRIs could be used to assess nervousness for the purposes of lie detection?

diy_ecg_rr_beat_interval

This is the RRI plot where the value of each RRI (in milliseconds) is represented for each beat. It’s basically the inverse of heart rate. Miscalculated heartbeats would show up as extremely high or extremely low dots on this graph. However, excluding points above or below certain bounds means that if your heart did double-beat, or skip a beat, you wouldn’t see it. Note that I just realized my axis label is wrong (it should be sec, not ms). Oh well =o\

diy_ecg_poincare_plot

A Poincare Plot is a commonly-used method to visually assess heart rate variability as a function of RRIs. In this plot, each RRI is plotted against the RRI of the next subsequent beat. In a heart which beats at the same speed continuously, only a single dot would be visible in the center. In a heart which beats mostly-continuously, and only changes its rate very slowly, a linear line of dots would be visible in a 1:1 ratio. However, in real life the heart varies RRIs greatly from beat to beat, producing a small cloud of dots. The size of the cloud corresponds to the speed at which the autonomic nervous system can modulate heart rate in the time frame of a single beat.

diy_ecg_rr_deviation_histogram

The frequency of occurrence of various RRIs can be expressed by a histogram. The center peak corresponds to the standard heart rate. Peaks to the right and left of the center peak correspond to increased and decreased RRIs, respectively. A gross oversimplification of the interpretation of such data would be to state that the upper peak represents the cardio-inhibitory parasympathetic autonomic nervous system component, and the lower peak represents the cardio-stimulatory sympathetic autonomic nervous system component.

diy_ecg_power_spectrum_raw

Taking the Fast Fourier Transformation of the data produces a unique trace whose significance is extremely difficult to interpret. Near 0Hz (infinite time) the trace heads toward ∞ (infinite power). To simplify the graph and eliminate the near-infinite, low-frequency peak we will normalize the trace by multiplying each data point by its frequency, and dividing the vertical axis units by Hz to compensate. This will produce the following graph…

diy_ecg_power_spectrum_weighted
This is the power spectrum density (PSD) plot of the ECG data we recorded. Its physiological interpretation is extraordinarily difficult to understand and confirm, and is the subject of great debate in the field of autonomic neurological cardiac regulation. An oversimplified explanation of the significance of this graph is that the parasympathetic (cardio-inhibitory) branch of the autonomic nervous system works faster than the sympathetic (cardio-stimulatory) branch. Therefore, the lower peak corresponds to the sympathetic component (combined with persistent parasympathetic input, it’s complicated), while the higher-frequency peak corresponds to the parasympathetic component, and the sympathetic/parasympathetic relationship can be assessed by the ratio of the integrated areas of these peaks after a complicated curve fitting processes which completely separates overlapping peaks. To learn more about power spectral analysis of heart rate over time in the frequency domain, I recommend skimming this introduction to heart rate variability website and the article on Heart Rate Variability following Myocardial Infarction (heart attack). Also, National Institute of Health (NIH) funded studies on HRV should be available from pubmed.org. If you want your head to explode, read Frequency-Domain Characteristics and Filtering of Blood Flow Following the Onset of Exercise: Implications for Kinetics Analysis for a lot of good frequency-domain-analysis-related discussion and rationalization.

Encouraging Words:

Please, if you try this don’t die. The last thing I want is to have some kid calling me up and yelling at me that he nearly electrocuted himself when he tried to plug my device directly into a wall socket and now has to spend the rest of his life with two Abraham Lincolns tattooed onto his chest resembling a second set of nipples. Please, if you try this use common sense, and of course you’re responsible for your own actions. I provide this information as a description of what I did and what worked for me. If you make something similar that works, I’ve love to see it! Send in your pictures of your circuit, charts of your traces, improved code, or whatever you want and I’ll feature it on the site. GOOD LUCK!

Fancier Circuit:

If you want to try this, go for it! Briefly, this circuit uses 6 op-amps to help eliminate effects of noise. It’s also safer, because of the diodes interconnecting the electrodes. It’s the same circuit as on [this page].

Last minute thoughts:

  • More homemade ECG information can be found on my earlier posts in the DIY ECG category, however this page is the primary location of my most recent thoughts and ideas.
  • You can use moisturizing lotion between the electrodes and your skin to increase conduction. However, keep in mind that better conduction is not always what you want. You’ll have to experiment for yourself.
  • Variation in location of electrodes will vary the shape of the ECG. I usually place electrodes on each side of my chest near my arms. If your ECG appears upside-down, reverse the leads!
  • Adding extra leads can improve grounding. Try grounding one of your feet with a third lead to improve your signal. Also, if you’re powering your device via USB power consider trying battery power – it should be less noisy.
  • While recording, be aware of what you do! I found that if I’m not well-grounded, my ECG is fine as long as I don’t touch my keyboard. If I start typing, every keypress shows up as a giant spike, bigger than my heartbeat!
  • If you get reliable results, I wonder if you could make the device portable? Try using a portable tape recorder, voice recorder, or maybe even minidisc recorder to record the output of the ECG machine for an entire day. I haven’t tried it, but why wouldn’t it work? If you want to get fancy, have a microcontroller handle the signal processing and determine RRIs (should be easy) and save this data to a SD card or fancy flash logger.
  • The microcontroller could output heart rate via the serial port.
  • If you have a microcontroller on board, why not display heart rate on a character LCD?
  • While you have a LCD on there, display the ECG graphically!
  • Perhaps a wireless implementation would be useful.
  • Like, I said, there are other, more complicated analog circuits which reduce noise of the outputted signal. I actually built Jason Nguyen’s fancy circuit which used 6 op-amps but the result wasn’t much better than the simple, 1 op-amp circuit I describe here once digital filtering was applied.
  • Arrhythmic heartbeats (where your heart screws-up and misfires, skips a beat, double-beats, or beats awkwardly) are physiological (normal) and surprisingly common. Although shocking to hear about, sparse, single arrhythmic heartbeats are normal and are a completely different ball game than chronic, potentially deadly heart arrhythmias in which every beat is messed-up. If you’re in tune with your body, you might actually feel these occurrences happening. About three times a week I feel my heart screw up a beat (often when it’s quiet), and it feels like a sinking feeling in my chest. I was told by a doctor that it’s totally normal and happens many times every day without me noticing, and that most people never notice these single arrhythmic beats. I thought it was my heart skipping a beat, but I wasn’t sure. That was my motivation behind building this device – I wanted to see what my arrhythmic beats looked like. It turns out that it’s more of a double-beat than a skipped beat, as observed when I captured a single arrhythmic heartbeat with my ECG machine, as described in this entry.
  • You can improve the safety of this device by attaching diodes between leads, similar to the more complicated circuit. Theory is that if a huge surge of energy does for whatever reason get into the ECG circuit, it’ll short itself out at the circuit level (conducting through the diodes) rather than at your body (across your chest / through your heart).
  • Alternatively, use an AC opto-isolator between the PC sound card and the ECG circuit to eliminate the possibility of significant current coming back from the PC.
  • On the Hackaday post, Flemming Frandsen noted that an improperly grounded PC could be dangerous because the stored charge would be manifest in the ground of the microphone jack. If you were to ground yourself to true ground (using a bench power supply or sticking your finger in the ground socket of an AC wall plug) this energy could travel through you! So be careful to only ground yourself with respect to the circuit using only battery power to minimize this risk.
  • Do not attempt anything on this page. Ever. Don’t even read it. You read it already! You’re sill reading it aren’t you? Yeah. You don’t follow directions well do you?

SAMPLE FILTERED RECORDING:

I think this is the same one I used in the 3rd video from my single op-amp circuit. [scottecg.snd] It’s about an hour long, and in raw sound format (1000 Hz). It’s already been filtered (low-pass filtered at 30Hz). You can use it with my code below!

CODE

print "importing libraries..."
import numpy, pylab
print "DONE"

class ECG:

    def trim(self, data,degree=100):
        print 'trimming'
        i,data2=0,[]
        while i<len(data):
            data2.append(sum(data[i:i+degree])/degree)
            i+=degree
        return data2

    def smooth(self,list,degree=15):
        mults=[1]
        s=[]
        for i in range(degree): mults.append(mults[-1]+1)
        for i in range(degree): mults.append(mults[-1]-1)
        for i in range(len(list)-len(mults)):
            small=list[i:i+len(mults)]
            for j in range(len(small)):
                small[j]=small[j]*mults[j]
            val=sum(small)/sum(mults)
            s.append(val)
        return s

    def smoothWindow(self,list,degree=10):
        list2=[]
        for i in range(len(list)):
            list2.append(sum(list[i:i+degree])/float(degree))
        return list2

    def invertYs(self):
        print 'inverting'
        self.ys=self.ys*-1

    def takeDeriv(self,dist=5):
        print 'taking derivative'
        self.dys=[]
        for i in range(dist,len(self.ys)):
            self.dys.append(self.ys[i]-self.ys[i-dist])
        self.dxs=self.xs[0:len(self.dys)]

    def genXs(self, length, hz):
        print 'generating Xs'
        step = 1.0/(hz)
        xs=[]
        for i in range(length): xs.append(step*i)
        return xs

    def loadFile(self, fname, startAt=None, length=None, hz=1000):
        print 'loading',fname
        self.ys = numpy.memmap(fname, dtype='h', mode='r')*-1
        print 'read %d points.'%len(self.ys)
        self.xs = self.genXs(len(self.ys),hz)
        if startAt and length:
            self.ys=self.ys[startAt:startAt+length]
            self.xs=self.xs[startAt:startAt+length]

    def findBeats(self):
        print 'finding beats'
        self.bx,self.by=[],[]
        for i in range(100,len(self.ys)-100):
          if self.ys[i]<15000: continue # SET THIS VISUALLY
          if self.ys[i]<self.ys[i+1] or self.ys[i]<self.ys[i-1]: continue
          if self.ys[i]-self.ys[i-100]>5000 and self.ys[i]-self.ys[i+100]>5000:
              self.bx.append(self.xs[i])
              self.by.append(self.ys[i])
        print "found %d beats"%(len(self.bx))

    def genRRIs(self,fromText=False):
        print 'generating RRIs'
        self.rris=[]
        if fromText: mult=1
        else: 1000.0
        for i in range(1,len(self.bx)):
            rri=(self.bx[i]-self.bx[i-1])*mult
            #if fromText==False and len(self.rris)>1:
                #if abs(rri-self.rris[-1])>rri/2.0: continue
            #print i, "%.03f\t%.03f\t%.2f"%(bx[i],rri,60.0/rri)
            self.rris.append(rri)

    def removeOutliers(self):
        beatT=[]
        beatRRI=[]
        beatBPM=[]
        for i in range(1,len(self.rris)):
            #CHANGE THIS AS NEEDED
            if self.rris[i]<0.5 or self.rris[i]>1.1: continue
            if abs(self.rris[i]-self.rris[i-1])>self.rris[i-1]/5: continue
            beatT.append(self.bx[i])
            beatRRI.append(self.rris[i])
        self.bx=beatT
        self.rris=beatRRI

    def graphTrace(self):
        pylab.plot(self.xs,self.ys)
        #pylab.plot(self.xs[100000:100000+4000],self.ys[100000:100000+4000])
        pylab.title("Electrocardiograph")
        pylab.xlabel("Time (seconds)")
        pylab.ylabel("Potential (au)")

    def graphDeriv(self):
        pylab.plot(self.dxs,self.dys)
        pylab.xlabel("Time (seconds)")
        pylab.ylabel("d/dt Potential (au)")

    def graphBeats(self):
        pylab.plot(self.bx,self.by,'.')

    def graphRRIs(self):
        pylab.plot(self.bx,self.rris,'.')
        pylab.title("Beat Intervals")
        pylab.xlabel("Beat Number")
        pylab.ylabel("RRI (ms)")

    def graphHRs(self):
        #HR TREND
        hrs=(60.0/numpy.array(self.rris)).tolist()
        bxs=(numpy.array(self.bx[0:len(hrs)])/60.0).tolist()
        pylab.plot(bxs,hrs,'g',alpha=.2)
        hrs=self.smooth(hrs,10)
        bxs=bxs[10:len(hrs)+10]
        pylab.plot(bxs,hrs,'b')
        pylab.title("Heart Rate")
        pylab.xlabel("Time (minutes)")
        pylab.ylabel("HR (bpm)")

    def graphPoincare(self):
        #POINCARE PLOT
        pylab.plot(self.rris[1:],self.rris[:-1],"b.",alpha=.5)
        pylab.title("Poincare Plot")
        pylab.ylabel("RRI[i] (sec)")
        pylab.xlabel("RRI[i+1] (sec)")

    def graphFFT(self):
        #PSD ANALYSIS
        fft=numpy.fft.fft(numpy.array(self.rris)*1000.0)
        fftx=numpy.fft.fftfreq(len(self.rris),d=1)
        fftx,fft=fftx[1:len(fftx)/2],abs(fft[1:len(fft)/2])
        fft=self.smoothWindow(fft,15)
        pylab.plot(fftx[2:],fft[2:])
        pylab.title("Raw Power Sprectrum")
        pylab.ylabel("Power (ms^2)")
        pylab.xlabel("Frequency (Hz)")

    def graphFFT2(self):
        #PSD ANALYSIS
        fft=numpy.fft.fft(numpy.array(self.rris)*1000.0)
        fftx=numpy.fft.fftfreq(len(self.rris),d=1)
        fftx,fft=fftx[1:len(fftx)/2],abs(fft[1:len(fft)/2])
        fft=self.smoothWindow(fft,15)
        for i in range(len(fft)):
            fft[i]=fft[i]*fftx[i]
        pylab.plot(fftx[2:],fft[2:])
        pylab.title("Power Sprectrum Density")
        pylab.ylabel("Power (ms^2)/Hz")
        pylab.xlabel("Frequency (Hz)")

    def graphHisto(self):
        pylab.hist(self.rris,bins=20,ec='none')
        pylab.title("RRI Deviation Histogram")
        pylab.ylabel("Frequency (count)")
        pylab.xlabel("RRI (ms)")
        #pdf, bins, patches = pylab.hist(self.rris,bins=100,alpha=0)
        #pylab.plot(bins[1:],pdf,'g.')
        #y=self.smooth(list(pdf[1:]),10)
        #x=bins[10:len(y)+10]
        #pylab.plot(x,y)

    def saveBeats(self,fname):
        print "writing to",fname
        numpy.save(fname,[numpy.array(self.bx)])
        print "COMPLETE"

    def loadBeats(self,fname):
        print "loading data from",fname
        self.bx=numpy.load(fname)[0]
        print "loadded",len(self.bx),"beats"
        self.genRRIs(True)

def snd2txt(fname):
    ## SND TO TXT ##
    a=ECG()
    a.loadFile(fname)#,100000,4000)
    a.invertYs()
    pylab.figure(figsize=(7,4),dpi=100);pylab.grid(alpha=.2)
    a.graphTrace()
    a.findBeats()
    a.graphBeats()
    a.saveBeats(fname)
    pylab.show()

def txt2graphs(fname):
    ## GRAPH TXT ##
    a=ECG()
    a.loadBeats(fname+'.npy')
    a.removeOutliers()
    pylab.figure(figsize=(7,4),dpi=100);pylab.grid(alpha=.2)
    a.graphHRs();pylab.subplots_adjust(left=.1,bottom=.12,right=.96)
    pylab.savefig("DIY_ECG_Heart_Rate_Over_Time.png");
    pylab.figure(figsize=(7,4),dpi=100);pylab.grid(alpha=.2)
    a.graphFFT();pylab.subplots_adjust(left=.13,bottom=.12,right=.96)
    pylab.savefig("DIY_ECG_Power_Spectrum_Raw.png");
    pylab.figure(figsize=(7,4),dpi=100);pylab.grid(alpha=.2)
    a.graphFFT2();pylab.subplots_adjust(left=.13,bottom=.12,right=.96)
    pylab.savefig("DIY_ECG_Power_Spectrum_Weighted.png");
    pylab.figure(figsize=(7,4),dpi=100);pylab.grid(alpha=.2)
    a.graphPoincare();pylab.subplots_adjust(left=.1,bottom=.12,right=.96)
    pylab.savefig("DIY_ECG_Poincare_Plot.png");
    pylab.figure(figsize=(7,4),dpi=100);pylab.grid(alpha=.2)
    a.graphRRIs();pylab.subplots_adjust(left=.1,bottom=.12,right=.96)
    pylab.savefig("DIY_ECG_RR_Beat_Interval.png");
    pylab.figure(figsize=(7,4),dpi=100);pylab.grid(alpha=.2)
    a.graphHisto();pylab.subplots_adjust(left=.1,bottom=.12,right=.96)
    pylab.savefig("DIY_ECG_RR_Deviation_Histogram.png");
    pylab.show();

fname='publish_05_10min.snd' #CHANGE THIS AS NEEDED
#raw_input("\npress ENTER to analyze %s..."%(fname))
snd2txt(fname)
#raw_input("\npress ENTER to graph %s.npy..."%(fname))
txt2graphs(fname)


Defibrillating My DIY ECG Project
Posted by
Scott August 6th, 2009 | 5,253 words | No Comments »


Scott was 23.87 years old when he wrote this!

I’ve done a lot of random things the last few months, but few things were as random, cool, or googled-for as my Do-It-Yourself Electrocardiography project . My goal was to produce an effective ECG machine which interfaced the computer sound card for as little cost as possible. I started out small with an extremely simple circuit which technically worked, but required a lot of custom-written software to do a ton of math to decipher the ECG signal from the noise (such as inverse fast flourier transformations after band-stopping several bands of predictable, high-frequency noise). I later started building more complicated circuits in an attempt to minimize the noise, which worked well but were much more difficult to construct. For some reason, my nice ECG circuit died (burned? broke? don’t know why) right after I started to actually generate useful data about my occasional double-beats (which apparently are common, normal, and even expected during basal physiological states).
UPDATE: [2am, nextday] Here’s some video of the prototype briefly demonstrating the concept of how to use a minimum of parts to generate a great ECG trace using digital signal processing on the PC side.

simple_ecg_circuit_output

I’ve decided to revitalize this project quickly and effectively, going back to its roots and focusing on cost-minimal solutions, and using software (rather than complicated analog circuitry) to eliminate the noise. This will be a beautiful marriage of biomedical analog circuitry with software-based processing and linear data analysis, all on the cheap. If there were ever a project that represented my early 20s life, this would be it. Briefly, I built a circuit with only 3 components (!) which produces extraordinary results (above). That’s the signal after minimal processing.

Check it out yourself! I’ll provide data file for this trace (snd2.zip) along with the Python code to graph it (below) which requires numpy and matplotlib in addition to the Python scripting language. I’ll post the circuity along with some more intricate code when my project progresses a little further.

import numpy, pylab

def trim(data,degree=100):
    i,data2=0,[]
    while i&ltlen(data):
        data2.append(sum(data[i:i+degree])/degree)
        i+=degree
    return data2

def genXs(length,trim=100,hz=44100):
    step = 1.0/(hz/trim)
    xs=[]
    for i in range(length):
        xs.append(step*i)
    return xs

data = numpy.memmap("ecg2.snd", dtype='h', mode='r')
data = trim(data)
pylab.grid(alpha=.2)
pylab.plot(genXs(len(data)),data)
pylab.title("Simplified ECG Circuit Output")
pylab.xlabel("Time (seconds)")
pylab.ylabel("Potential (Au)")
pylab.show()
« Previous Entries
copyright © 2006 swharden@gmail.com