Warning: This post is several years old and the author has marked it as poor quality (compared to more recent posts). It has been left intact for historical reasons, but but its content (and code) may be inaccurate or poorly written.

Man, what a long day! Work is so tedious sometimes. This week I’ve been proofing scientific literature using Office 2003 with “track changes”. I make changes, my boss makes changes, I make more changes, and it goes back and forth a few times. I wonder why office 2007 is so bad. Does anybody truly like it, and find it to be a significant improvement upon 2003? … or Vista over XP? Maybe I’m just getting old, inflexible, and grumpy.

This is what I’m currently working on. The light bubbles on the right are deletions. The dark bubbles on the right are comments. The red text is insertions/modifications I made. Pretty intense, right? Pages and pages of this. I’m starting to grasp the daunting amount of time a scientist must spend writing in the laboratory as opposed to performing actual experiments or even doing literature research.

Last night I assembled a Pixie II circuit similar to the one pictured here. I must say that I’m a little disappointed with the information available on the internet regarding simple RF theory in relation to transceiver circuits. I’m just now starting to get into RF circuitry and the concept looking at circuits and imagining a combination of AC and DC flowing through it is warping my brain. I have everything I need to build a simple Pixie II transceiver (which is supposedly capable of Morse code transmissions over 300 miles, and QRSS applications over 3,000 miles) but I don’t want to use it unless I understand how it actually works.

I’m trying to break this circuit down into its primary components. I understand the role of the lowpass filter. I understand the role of the 1st transistor and related circuitry in amplifying the output of the crystal oscillator (left side). I totally get the audio amplifier circuitry (bottom). It’s that center transistor (which supposedly handles signal amplification, receiving, and mixing) that I can’t get my mind around. Every time I think figure it out for one mode (sending or receiving), I mentally lose the other one. It has me very frustrated because it seems like this should be easier than I’m making it. I selected this circuit because it was simple and I assumed I’d be smart enough to figure it out… maybe I was wrong? I wish I had an oscilloscope so I could probe the RF passing through various stages of this circuit. I guess I should take another stab at reading chapters 5-11 of the ARRL handbook.





Warning: This post is several years old and the author has marked it as poor quality (compared to more recent posts). It has been left intact for historical reasons, but but its content (and code) may be inaccurate or poorly written.

I put the transmitter from the previous post to the test. I changed the circuitry a bit though. I kept the oscillator (50 MHz) is now continuously powered. I programmed the ATTiny 2313 microcontroller (using PWM output) to send an oscillating signal to the base of a transistor (NPN). In this way the microcontroller PWM output didn’t supply power to the oscillator, but rather grounded it. I got a big boost in range this way. Yesterday I couldn’t even hear the signal in the parking lot of my apartment, whereas today I heard it loud and clear. I decided to take a drive with my scanner, laptop, and Argo to see how far away I could get and still detect the signal. With this bare bones transmitter setup (using a 2M J-pole antenna) I was able to detect it over 4,000 ft away. The receiving antenna was a 2m ~1ft high antenna magnet-mounted on top of my car.

This is the signal captured by Argo running on my laptop in my car as I drove away

In retrospect, I should have run Argo at my apartment and drove the transmitter farther and farther away. I presume that my transmitter is functioning decently, and that if I attached it to a proper antenna (and had a better receiving antenna) I might be able to get some cross-town distance? I’m still learning – this is the point though, right?

This is where I was when the signal died. The red marker (upper right) is my apartment where the transmitter was, and the signal began to die right as I traveled south on Chickasaw past Lake Underhill (~4000 ft away). This immediate loss may be due to the fact that I passed under power lines which parallel Lake Underhill which interrupted the line-of-sight path between my 3rd story apartment balcony and me. If this were the case, supposedly if I kept driving south the signal may have improved.





Warning: This post is several years old and the author has marked it as poor quality (compared to more recent posts). It has been left intact for historical reasons, but but its content (and code) may be inaccurate or poorly written.

I’ve been very busy over the past couple weeks. Last Thursday my boss approached me and asked if I could work over the weekend. He wanted to complete and submit a grant by the deadline (Monday at 5 pm). To make a long story short I worked really hard (really long days) on Friday, Saturday, Sunday, and Monday to accomplish this. Monday afternoon when it was done (at about 4 pm), after which I went home and collapsed from exhaustion. I don’t know how my boss does it! He worked on it far more than I did, and over that weekend he didn’t sleep much. Anyway, in exchange for my over-weekend work I got Tuesday and Wednesday off.

I knew in advance that I’d have two days off to do whatever I wanted. I prepared ahead of time by ordering a small handful (I think 4?) of ATMEL AVR type ATTiny2313 chips from Digi-Key at $2.26 per chip. They arrived in the mail on Monday. Unlike the simple PICAXE chips which can be programmed a form of BASIC cod from 2 wires of a serial port, the AVR series of chips are usually programmed from assembly-level code. Thankfully, C code can be converted to assembly (thanks to AVR-GCC) and loaded onto these chips. The result is a much faster and more powerful coding platform than the PICAXE chips can delivery. PICAXE seems useful for rapid development (especially if you already know BASIC) but I feel that I’m ready to tackle something new.

I built a straight-through parallel programmer for my ATTiny2313 chips. It was based upon the dapa configuration and connects to the appropriate pins. To be safe I recommend that you protect your parallel port and microcontrollers by installing the proper resisters (~1k?) between the devices, but I didn’t do this.

I decided to dive right in to the world of digital RF transmission and should probably go to jail for it. I blatantly violated FCC regulations and simply wired my microcontroller to change the power level given to a 3.579545 MHz oscillator. The antenna is the copper wire sticking vertically out of the breadboard.

These crystals release wide bands of RF not only near the primary frequency (F), but also on the harmonic frequencies (F*n where n=1,2,3…). I was able to pick up the signal on my scanner at its 9th harmonic (32.215905 MHz). I think the harmonic output power is inversely proportional to n. Therefore the frequency I’m listening to represents only a fraction of the RF power the crystal is putting out at its primary frequency. Unfortunately the only listening device I have (currently) is the old scanner, which can only listen above 30 MHz.

Remember when I talked about the illegal part? Yeah, I detected harmonic signals being emitted way up into the high 100s of MHz. I don’t think it’s a big deal because it’s low power and I doubt the signal is getting very far, but I’m always concerned about irritating people (Are people trying to use Morse code at one of the frequencies? Am I jamming my neighbors’ TV reception?) so I don’t keep it on long. Once I get some more time, I’ll build the appropriate receiver circuits (I have another matched crystal) and install a low-pass filter (to eliminate harmonics) and maybe even get a more appropriate radio license (I’m still only technician). But for now, this is a proof-of-concept, and it works. Check out the output of the scanner.

Something I struggled with for half an hour was how to produce a tone with a microcontroller and the oscillator. Simply supplying power to the oscillator produces a strong RF signal, but there is no sound to it. It’s just full quieting when it’s on, and static noise when it’s off. To produce an AM tone, I needed amplitude modulation. I activated the oscillator by supplying power from the microcontroller with one pin (to get it oscillating), and fed it extra juice in the form of timer output from another pin. The fluctuation in power to the oscillator (without power-loss) produced a very strong, loud, clear signal (horizontal lines). I wrote code to make it beep. Frequency can be adjusted by modifying the timer output properties. The code in the screenshot is very primitive, and not current (doesn’t use timers to control AM frequency), but it worked. I’m sure I’ll write more about it later.

Thoughts from Future Scott (August 2019, 10 years later):

What a good start! But what a bad design =P

Driving a can oscillator’s power pin with two microcontroller pins is not a good idea. Also, you were SO CLOSE to getting frequency shift keying to work! Rather than turning the can oscillator on/off with the microcontroller, just leave it on continuously and send a microcontroller pin to the can oscillator’s VCO pin. I’m sure I didn’t know what that 4th pin does when did when I originally wrote this (and most diagrams of can oscillators online leave that pin disconnected).

Either way, I’m happy this day happened – this was the start of years of hobby radio frequency circuit design!





Warning: This post is several years old and the author has marked it as poor quality (compared to more recent posts). It has been left intact for historical reasons, but but its content (and code) may be inaccurate or poorly written.

Over the last couple weeks whenever I had the time I’d work on creating a little Morse code keyer. After a few different designs I came up with the winner. Basically it just uses a bar of aluminum which rocks on a metal pin. Thumb-screws on each side of the balance point (fulcrum?) can be adjusted to modulate the distance the paddle has to go down to be activated, and how high the paddle goes up when released. A couple springs (one pull-type and one push-type) help give it a good bounce between keys. Two knobs control volume and frequency. I especially like the ability to control the frequency! A capacitor inline with the speaker helps smooth the output a bit too. It’s not professional, but hey – for a couple bucks of parts I made a functional keyer and had fun doing it. Now I guess I should put more time into learning Morse code…

Thoughts from future Scott (August 2019, ten years later)

Wow this is rough! I’m 90% sure this is based on a 555 circuit. lol @ the use of Jenga blocks. It looks like the wire was sourced from cat5 cable. That aluminum slab later became the base and heat sink for an IRF510-based push-pull amplifier.





Warning: This post is several years old and the author has marked it as poor quality (compared to more recent posts). It has been left intact for historical reasons, but but its content (and code) may be inaccurate or poorly written.

I got an idea today for an odd but interesting project. The idea is still in the earliest stages of development, and I further research the idea (for example, I don’t even know if it’s legal) but it’s a cool idea and I want to try it. I know I’ll learn a lot from the project, and that’s what’s important, right? So, here’s the idea: I want to build an incredibly simple, low power radio transmitter that broadcasts data on a fixed frequency. Data is provided by a microcontroller. What data will it transmit? uh… err… um… okay it doesn’t really matter and I don’t even know, I just want to do this project! Maybe temperature and light intensity or something. Who cares – it’d be fun to make regardless of what it transmits. I could put it all into a drybox (pictured).

Once properly closed, this box will keep everything in pristine working condition by protecting against rain, heat, snow (not that we get much of that in Orlando), hurricanes, and perhaps even Florida panthers and bears (oh my). I’d like to make a glass (or plexiglas) window on the top so that light could get in, hitting solar panels, which trickle-charges the battery housed in the device as well.

My idea is to keep construction costs to a minimum because I’m throwing this away as soon as I make it. My goal is to make it work so I can toss it in some random location and see how long it will run. Days? Weeks? Months? Years? How cool would it be to go to dental school, come back ~5 years from now, and have that transmitter still transmitting data. I’ve been poking around and I found someone who did something similar. They built a 40mW 10m picaxe-powered beacon using a canned oscillator as the transmit element.

I understand the basics of radio, amplitude and frequency modulation (AM and FM), etc., but I’ve never actually built anything that transmits radio waves. I could build a SoftRock radio, but my educational grounding is in molecular biology. I know little about circuit-level electronics, electrical engineering, and radio theory… so my plan is to start small. This project is small enough to attack and understand, with a fun enough end result to motivate me throughout the process.





Warning: This post is several years old and the author has marked it as poor quality (compared to more recent posts). It has been left intact for historical reasons, but but its content (and code) may be inaccurate or poorly written.

Two hours after getting home from work I’m already basking in the newfound carefreeness thanks to the successful completion of my thesis defense (and graduation requirements). Yesterday I went to SkyCraft, early this morning I posted a schematic diagram of a basic circuit concept for a radio/microphone interface box with tone generating functions, and this afternoon I finished its assembly. It’s hacked together, I know, but it’s just a prototype. What does it do? It’s complicated. It’s basically just an exercise in microchip programming.

Future Scott reacts to this in August, 2019 (10 years later)

LOL! That’s a pipette box! A chip socket was sunk into a plastic enclosure somehow! And that “regulated power supply” is an LM7805 on non-metallic perfboard screwed to two Jenga blocks!

Here’s the little setup with the main control unit and a DC to DC regulated power supply / serial microchip programmer I made.

Here’s the main control box. Notice the “2-way lighted switches” which I described in the previous entry. I found that proper grounding (floating pin prevention) was critical to their proper function. I’m still new to these chips, so I’m learning, but I’m making progress!

Getting a little artsy with my photographs now… this is the core of the device. It’s a picaxe 14m!

This is a 5v regulated power supply I built. The headphone adapter is for easy connection to the serial port. It has a power switch and a program/run switch (allowing use of pin 13, serial out) while still “connected” to the PC.

I’ve slightly improved the connection between my radio’s coax cable to the J-pole antenna I made.

I’m able to get pretty good from this antenna, but it’s probably not likely to do much to my assembly skills (and lack of tuning), and more likely due to the fact that I have an unobstructed view of middle/southern Orlando from the 3rd story of my apartment balcony. I could probably wire up a rubber duck on a stick and get good results with that location! I’ll miss my reception when I move.





I’m posting this information hoping that someone else in a position similar to mine can benefit from the experience I gained through trial and error while trying to rapidly design and develop professional-looking QSL cards at low risk. I Googled around for this information, but didn’t find anything too helpful, so I figured I’d come up with something on my own and share my story.

QSL cards are like postcards which amateur radio operators often mail to one another after making long distance contacts. In addition to providing tangible proof of the communication, they’re cool mementos to tote around to remember who you’ve made contact with over the years. QSL cards display information bout the contact (time, date, call sign, frequency, signal report, etc.) and sometimes contain extra pictures/graphics which make them unique and appealing.

Once I got a HF rig for my apartment (a Century 21 CW-only HF rig which puts out ~30 watts), I started making contacts and getting QSL cards myself, so I wanted to send some nice ones in return. Being a poor college student (and a graduate student at that), I was extremely cash-limited, and didn’t want to sit around for weeks while my cards were professionally printed. This post describes how I created nice looking QSL cards in a few hours, for less than $0.25 each!

Step 1: Design the cards with the correct dimensions. The most cost-effective way to print nice digital images is my local Target (a store with a 1-hr photo lab which accepts JPEGs as the image source for $0.20 cents a picture), but the snag was that they only print 4” x 6”. QSL cards need to be 3.5” by 5.25”. I used Inkscape to create an image exactly 4” by 6”, and inside of it I drew a border 3.5” by 5.25”. Everything outside that border I made black. I designed my QSL card inside that border, such that when the images would be printed I could trim-off the black border and have a perfect 3.5” by 5.25” QSL card.

Step 2: Print the reverse side on full-size label paper. All I needed was some framed boxes for QSL information, so I quickly sketched up the design in Inkscape and saved it in the same format as before (4” by 6”). I left a LOT of white space around the edges so it’s very forgiving down the line. I then printed the design on full-page label paper (full-sheet stickers, available at most office stores cheaply in the printer paper section), placing 4 “backs” per page.

03_backs

Here’s what the adhesive paper looked like after printing:

04_cutback
05_back

Step 3: Attach backings to QSL cards. This part is easy if you have a paper cutter. I purchased mine ~5yrs ago and I *LOVE* it. It’s almost as useful as my soldering iron. Seriously, so convenient. I wouldn’t dream of doing this with scissors! Anyhow, roughly cut the sticker paper into quarters.

06_peel
07_overhang

Next, peel and stick on the backs of cards. Don’t worry about overhang, we’ll take care of that later…

09_cut
10_nice

Step 4: Trim the edges. Make sure you do this step after applying the sticker. This was the secret that I wish I realized a while ago. If you trim first, sticker placement is critical and difficult. If you place the sticker before you trim, you get perfect edges every time.

11_niceback

How nice does that look? If you did your math correctly, your new dimensions should be exactly 3.5” by 5.25”.

12_silver2

Step 5: fill-out information. I decided to use a metallic Sharpie to write the name of the call sign I send this to on the front of my card. How cool does that look? This is what the front/back of this card looks like after filling it out.

12_donefront

I hope this information helps you. If you print your own QSL cards using this (or a similar) method, let me know about it! I have to say, for ~5 / $1, these don’t look to bad. It’s especially useful if you only want to print a few cards! Good luck.
— Scott, AJ4VD





Update: The DIY ECG project has had several iterations. The latest one can be viewed here: https://www.swharden.com/wp/2019-03-15-sound-card-ecg-with-ad8232/

Warning: This post is several years old and the author has marked it as poor quality (compared to more recent posts). It has been left intact for historical reasons, but but its content (and code) may be inaccurate or poorly written.

I’ve been spending a lot of time creating a DIY ECGs which produce fairly noisy signals. I have researched the ways to clean-up these signals, and the results are very useful! I document some of these findings here.

This example shows how I take a noisy recording and turn it into a smooth trace. This is achieved by eliminating excess high-frequency components which are in the original recording due to electromagnetic noise. A major source of noise can be from the AC passing through wires traveling through the walls of my apartment. My original ECG circuit was highly susceptible to this kind of interference, but my improved ECG circuit eliminates much of this noise. However, noise is still in the trace and it needs to be removed.

One method of reducing noise uses the FFT (Fast Fourier Transformation) and its inverse (iFFT) algorithm. Let’s say you have a trace with repeating sine-wave noise. The output of the FFT is the breakdown of the signal by frequency. Check out this FFT trace of a noisy signal from a few posts ago. High peaks represent frequencies which are common. See the enormous peak around 60 Hz? That’s noise from AC power lines. Other peaks (shown in colored bands) are other electromagnetic noise sources, such as wireless networks, TVs, telephones, and maybe my computer. The heart produces changes in electricity that are very slow (a heartbeat is about 1 Hz), so if we can eliminate higher-frequency sine waves we can get a pretty clear trace. This is called a band-stop filter (we block-out certain bands of frequencies). A band-pass filter is the opposite, where we only allow frequencies which are below (low-pass) or above (high-pass) a given frequency. By eliminating each of the peaks in the colored regions (setting each value to 0), then performing an inverse fast Fourier transformation (going backwards from frequency back to time), the result is the signal trace (seen as light gray on the bottom graph) with those high-frequency sine waves removed! (the gray trace on the bottom graph). A little touch-up smoothing makes a great trace (black trace on the bottom graph).

Here’s some Python code you may find useful. The image below is the output of the Python code at the bottom of this entry. This python file requires that test.wav (an actual ECG recording of my heartbeat) exist in the same folder.

  • (A) The original signal we want to isolate. (IE: our actual heart signal)
  • (B) Some electrical noise. (3 sine waves of different amplitudes and periods)
  • (C) Electrical noise (what happens when you add those 3 sine waves together)
  • (D) Static (random noise generated by a random number generator)
  • (E) Signal (A) plus static (D)
  • (F) Signal (A) plus static (D) plus electrical noise (C)
  • (G) Total FFT trace of (F). Note the low frequency peak due to the signal and electrical noise (near 0) and the high frequency peak due to static (near 10,000)
  • (H) This is a zoomed-in region of (F) showing 4 peaks (one for the original signal and 3 for high frequency noise). By blocking-out (set it to 0) everything above 10Hz (red), we isolate the peak we want (signal). This is a low-pass filter.
  • (I) Performing an inverse FFT (iFFT) on the low-pass iFFT, we get a nice trace which is our original signal!
  • (J) Comparison of our iFFT with our original signal shows that the amplitude is kinda messed up. If we normalize each of these (set minimum to 0, maximum to 1) they line up. Awesome!
  • (K) How close were we? Graphing the difference of iFFT and the original signal shows that usually we’re not far off. The ends are a problem though, but if our data analysis trims off these ends then our center looks great.
    • Note: these ends can be fixed by applying a windowing function to the original data. The FFT works best if the input data starts and ends at zero.
import numpy, scipy, pylab, random

 # This script demonstrates how to use band-pass (low-pass)
 # filtering to eliminate electrical noise and static
 # from signal data!

 ##################
 ### PROCESSING ###
 ##################

 xs=numpy.arange(1,100,.01) #generate Xs (0.00,0.01,0.02,0.03,...,100.0)
 signal = sin1=numpy.sin(xs*.3) #(A)
 sin1=numpy.sin(xs) # (B) sin1
 sin2=numpy.sin(xs*2.33)*.333 # (B) sin2
 sin3=numpy.sin(xs*2.77)*.777 # (B) sin3
 noise=sin1+sin2+sin3 # (C)
 static = (numpy.random.random_sample((len(xs)))-.5)*.2 # (D)
 sigstat=static+signal # (E)
 rawsignal=sigstat+noise # (F)
 fft=scipy.fft(rawsignal) # (G) and (H)
 bp=fft[:]
 for i in range(len(bp)): # (H-red)
     if i>=10:bp[i]=0
 ibp=scipy.ifft(bp) # (I), (J), (K) and (L)

 ################
 ### GRAPHING ###
 ################

 h,w=6,2
 pylab.figure(figsize=(12,9))
 pylab.subplots_adjust(hspace=.7)

 pylab.subplot(h,w,1);pylab.title("(A) Original Signal")
 pylab.plot(xs,signal)

 pylab.subplot(h,w,3);pylab.title("(B) Electrical Noise Sources (3 Sine Waves)")
 pylab.plot(xs,sin1,label="sin1")
 pylab.plot(xs,sin2,label="sin2")
 pylab.plot(xs,sin3,label="sin3")
 pylab.legend()

 pylab.subplot(h,w,5);pylab.title("(C) Electrical Noise (3 sine waves added together)")
 pylab.plot(xs,noise)

 pylab.subplot(h,w,7);pylab.title("(D) Static (random noise)")
 pylab.plot(xs,static)
 pylab.axis([None,None,-1,1])

 pylab.subplot(h,w,9);pylab.title("(E) Signal + Static")
 pylab.plot(xs,sigstat)

 pylab.subplot(h,w,11);pylab.title("(F) Recording (Signal + Static + Electrical Noise)")
 pylab.plot(xs,rawsignal)

 pylab.subplot(h,w,2);pylab.title("(G) FFT of Recording")
 fft=scipy.fft(rawsignal)
 pylab.plot(abs(fft))
 pylab.text(200,3000,"signals",verticalalignment='top')
 pylab.text(9500,3000,"static",verticalalignment='top',
            horizontalalignment='right')

 pylab.subplot(h,w,4);pylab.title("(H) Low-Pass FFT")
 pylab.plot(abs(fft))
 pylab.text(17,3000,"sin1",verticalalignment='top',horizontalalignment='left')
 pylab.text(37,2000,"sin2",verticalalignment='top',horizontalalignment='center')
 pylab.text(45,3000,"sin3",verticalalignment='top',horizontalalignment='left')
 pylab.text(6,3000,"signal",verticalalignment='top',horizontalalignment='left')
 pylab.axvspan(10,10000,fc='r',alpha='.5')
 pylab.axis([0,60,None,None])

 pylab.subplot(h,w,6);pylab.title("(I) Inverse FFT")
 pylab.plot(ibp)

 pylab.subplot(h,w,8);pylab.title("(J) Signal vs. iFFT")
 pylab.plot(signal,'k',label="signal",alpha=.5)
 pylab.plot(ibp,'b',label="ifft",alpha=.5)

 pylab.subplot(h,w,10);pylab.title("(K) Normalized Signal vs. iFFT")
 pylab.plot(signal/max(signal),'k',label="signal",alpha=.5)
 pylab.plot(ibp/max(ibp),'b',label="ifft",alpha=.5)

 pylab.subplot(h,w,12);pylab.title("(L) Difference / Error")
 pylab.plot(signal/max(signal)-ibp/max(ibp),'k')

 pylab.savefig("SIG.png",dpi=200)
 pylab.show()




Update: The DIY ECG project has had several iterations. The latest one can be viewed here: https://www.swharden.com/wp/2019-03-15-sound-card-ecg-with-ad8232/

Warning: This post is several years old and the author has marked it as poor quality (compared to more recent posts). It has been left intact for historical reasons, but but its content (and code) may be inaccurate or poorly written.

Instead of using a single op-amp circuit like the previous entries which gave me decent but staticky traces, I decided to build a more advanced ECG circuit documented by Jason Nguyen which used 6 op amps! (I’d only been using one). Luckily I got a few couple LM324 quad op-amps from radioshack ($1.40 each), so I had everything I needed.

The results look great! Noise is almost zero, so true details of the trace are visible. I can now clearly see the PQRST features in the wave. I’ll detail how I did this in a later entry. For now, here are some photos of the little device.

UPDATE: After analyzing ~20 minutes of heartbeat data I found a peculiarity. Technically this could be some kind of noise (a ‘pop’ in the microphone signal), but because this peculiarity happened only once in 20 minutes I’m not ruling out the possibility that this is the first irregular heartbeat I captured with my DIY ECG. Note that single-beat irregularities are common in healthy people, and that this does not alarm me so much as fascinate me.





Update: The DIY ECG project has had several iterations. The latest one can be viewed here: https://www.swharden.com/wp/2019-03-15-sound-card-ecg-with-ad8232/

Warning: This post is several years old and the author has marked it as poor quality (compared to more recent posts). It has been left intact for historical reasons, but but its content (and code) may be inaccurate or poorly written.

Last night I finished building my DIY ECG as a prototype (I finally got the circuit off the breadboard and onto a plastic sheet). This is a similar circuit to the one used to record data from the last entry (resister values are now identical to the crude circuit described several posts ago). I left-in the crude band-pass filter (made by grounding my primary electrode sensor through a 0.1µF capacitor) because it seemed to help a great deal, and wasn’t hard to implement. I picked up all of my parts (including the LM324 quad op-amp microchip) at RadioShack. Of note, the quad-op-amp is overkill because I’m only using one of the 4 op-amps. Theoretically I could add 3 more electrodes to this circuit (which would allow for multi-sensor recording) but this would require multiple microphone jacks, which isn’t very common. I guess I could use 2 microphone jacks, and differentiate right/left channels.

I made the prototype by drilling holes in a small rectangular piece of a non-conductive plastic material. I picked up a stack of these rectangular sections for a quarter at a local electrical surplus store and they’re perfect for prototyping. The two green wires coming out the left side attach to a power supply (either a plugged in AC->DC transformer, 3 or 4 AA batteries, or even a 9V should work). The blue wires on the right attach to the electrodes I put on my chest. The black wires go to a headphone-jack which I plug into the microphone hole of my PC to record the signal.

This is the back of the device which shows my crummy soldering. I’m a molecular biologist not an electrical engineer. The white/yellow wires correspond to the left/right channels of the microphone connector. I only use the left one (white), but attached the right channel (yellow) to the op-amp just in case I decide to add another sensor later – this is not required.

Here’s the full device: You can see the circuit (note its small size – easy to mount inside of a tictac box or something) with the green wires leading to a power supply, black cable being the microphone connector, and the blue wires leading to electrodes made… from… Fanta… cans…? Yes, in the spirit of rigging electronics (my specialty) I found that surprisingly nice chest electrodes can be made from aluminum soda cans! If you go this route, cut them delicately so you don’t get metal shards in your skin like I did at first. Also, note that you have to firmly scrape each side of the aluminum to get the insulating waxy-plastic stuff off or it just won’t work. I guess it’s coated with something to prevent the soda from tasting like metal. Aluminum rapidly transfers heat and it’s nearly impossible to solder leads onto these pads, so I wrapped a wire (tipped with a bead of solder) with the edge of the aluminum several times and crushed the heck out of it with pliers and it seems to stay on well and make a good connection. Also, before taping these onto your skin, it helps to put a conductive goo on it to make the connection better. I added skin moisturizer to each electrode and taped the gooey electrode directly onto my chest.

I recorded ~20 minutes of data last night with this rig and it looked pretty good. I went to analyze it with Python and it kept crashing! The python script I gave you previously loads the entire wave file into an array of numbers, but with a 20 minute wave file (at over 40,000 samples a second) it is too big for memory. I wrote an updated wave loader which loads large wave files in parts which is much more efficient. It also performs the condensation method at load time. Basically, it loads 100 data points (or whatever deg is set to), averages them, and adds this value to a list. The result is a smoothed trace with a resolution of 400 Hz instead of 40 kHz. I’d test this on the wave file I recorded last night but that’s on my laptop which is in the car and I’ve got to get back to work. Here’s that function:

 def loadWav(fname,deg=100):
     global hz
     w=wave.open(fname)
     nchannel, width, rate, length, comptype, compname = w.getparams()
     print "[%s]
 rate: %d Hz
 frames: %d
 length: %.02f sec" %
           (fname, rate, length, float(length)/rate)
     hz=rate/deg
     chunks=int(length/deg)
     data=[]
     for i in range(chunks):
         if i%7777==0:
             print "processing chunk %d of %d (%0.02f%%)" %
                   (i,chunks,100.0*i/chunks)
         vals = struct.unpack("%sh" %deg,w.readframes(deg))
         data.append(sum(vals)/float(deg))
     print "complete!"
     return data