Hacking Together a Crystal Oven Part 2

With the last post’s promising results, I set out to finish my crystal oven prototype and affix it to my QRSS MEPT prototype. If everything works well, I’m ready to publish the final schematic and parts lists! (and make several MEPTs for people who were interested in having one). I’m not confident my approach to the heater was the best, and am already thinking of ways I could have improved on its performance, but I think this just might work! I’ll test it overnight (styrofoam-enclosed vs. open air) and see how it does. I wonder if this is good enough to be used outside?

Here’s the device attached to the transmitter IMG_3838IMG_3848

here are some closeups IMG_3805IMG_3824IMG_3832IMG_3829


     

Minimalist Crystal Oven

So I’m working on building a crystal oven to keep my QRSS MEPT (radio transmitter) at an extremely stable frequency. Even inside a thick Styrofoam box, slight changes in my apartment temperature caused by the AC turning on and off is enough to change the crystal temperature of the transmitter, slightly modifying its oscillation frequency. For a device that vibrates exactly 10,140,070 times a second, even 3 to many or too few vibrations per second is too much. Keeping in the spirit of hacking things together with a minimum of parts, this is what I came up with!

It uses a thermistor, potentiometer, and comparator of a microcontroller (ATTiny44a) to tightly sense and regulate temperature. The heater element is a junk MOSFET I found in an old battery backup system. I simply have pass a ton of current (turned on/off by the gate) to generate heat, transferred into a piece of steel for smooth regulation. One of the unexpected advantages is that the light flickers rapidly near equilibrium, which is great because it has the ability to turn the heater on a little or a lot based upon the averaging effect of the flicker. Here is the code I wrote on the microcontroller to handle the comparator. It couldn’t be simpler!

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

int main(void) {
	DDRA=0; // all inputs
	DDRB=255; // all outputs

	while (1){
		if (ACSR & _BV(ACO)) {
			/* AIN0 is more positive than AIN1 right now */
			PORTB|=(1<<PB0);
			PORTB&=~(1<<PB1);

		} else {
	  		/* AIN0 is more negative than AIN1 */
			PORTB|=(1<<PB1);
			PORTB&=~(1<<PB0);
		}

	}
}

This is where I harvested the components:mosfet heater 1mosfet heater 2


     

Lost Project Revisited on HackADay

I somehow forgot about a cool project I made over a year ago! I guess dental school got in the way of my productivity. It’s a little ironic how the last post was about something I made a year ago screwing up, and this one is about something I made a year ago turning out well! Anyhow, the world’s only battery powered microcontroller based handheld prime number generator I made last year (documented here, here, and here) got some new exposure this morning when it was posted on HackADay.com! hackaday_swharden_primes

I’m absolutely amazed by how much I learned back in the days when I was working with electronics in the weeks before I began dental school. Perhaps it’s also ironic that my learning decreased dramatically once I resumed graduate school… To give you an idea of how early in my electronics exploration this project was, look at the wires… they’re made from phone cord! I had no wire at my apartment, so I had to scavenge it from whatever I could find, and I ended-up buying a 50ft phone cord at Wall-Mart (super-cheap I’d imagine) and harvesting the colored wires inside.

The code is a joke. There’s no reason for this thing to generate numbers rapidly, so I used the absolute-slowest method for detecting primes possible. The schematic is a joke too. There’s hardly enough current to ignite those LEDs! Notice how the video had to be filmed in a dark room. Ironically enough also, the crystal isn’t even being used! It’s just for show! I’m confident I never changed the ATTiny2313’s fuse bits to rely on th external crystal, so it’s probably running on the 4MHz internal RC oscillator (perhaps with the /8 fuse set by default, so 500kHz?)


     

Tooth as a Radio Receiver?

We’ve all heard the urban legend where someone’s tooth filling picks up radio signals, some versions claim AM radio stations’ music is heard, others that wartime Morse code is heard. Is this really possible? Well, as a dental student and an electrical engineering / RF engineering enthusiast, I can think of no one better prepared to put this myth to the test! Yeah, I’m going to put my money where my mouth is. (zing!) Myth Busters attempted to replicate this, but they concluded it was “busted”, however I think they were going about it the wrong way. Let’s back up! Here’s a quote from Lucille Ball who is often accredited for originating this urban legend:

One night I came into the Valley over Coldwater Canyon, and I heard music. I reached down to turn the radio off, and it wasn’t on. The music kept getting louder and louder, and then I realized it was coming from my mouth. I even recognized the tune. My mouth was humming and thumping with the drumbeat, and I thought I was losing my mind. I thought, What the hell is this? Then it started to subside. I got home and went to bed, not sure if I should tell anybody what had happened because they would think I was crazy.
–Lucille Ball

It was noted that Lucy recently had several temporary lead fillings installed in her teeth which caused this unique phenomenon. Let’s assume this isn’t a made-up story. If this were possible, what would cause it? Without going into detail as to how (whether by galvanic corrosion or other means), we’d have to assume that RF could be absorbed by the filling (whatever type it was), and turned into electrical activity. This electrical activity was either transferred directly to the nerves (felt as tingly electric shocks, which I feel isn’t likely) or converted into mechanical energy (creating vibrations which would be hears as sound waves). The peizoelectric effect may be one method where an electrical signal could produce these vibrations. Many small speakers are called peizoelectric speakers, because they have a small crystal in them (usually quartz) which changes its dimension as electricity is applied to the crystal, creating mechanical vibrations (turned into sound waves). Tooth enamel is 98% hydroxyapatite crystal – I wonder if it could be coaxed to vibrate similarly to quartz? There’s only one way to find out!
IMG_5554

First, I start with a jar of teeth. Yeah, this is mine. Don’t ask how I got it! They’re all nasty as heck, and require sterilization before I will touch them without gloves. There are many advantages of spending every day in a medical setting, one of which is easy access to an autoclave! After picking a tooth which I think will have a lot of enamel I can isolate, I sterilized it.
IMG_5556

This is my test subject. It’s a maxillary left first premolar. My goal is to isolate only enamel from this tooth, take it home and experiment with it.
IMG_5562

I started by sectioning the tooth mesio-distally using a slow-speed air-dirven handpiece and a #2 round burr. As I cut through the enamel, you can see the darker, yellowish dentin layer showing through.
IMG_5563

Although dentin is crystal too, it’s about half organic matter and I feel it’s less likely to exhibit significant peizoelectric effect. Therefore, I’m going to try to eliminate all the dentin attached to the enamel. The image above shows some yellow dentin remaining near the center of the enamel. The lingual surface of the tooth has already been removed, leaving a thin shell of the facial surface. I’ll try to be more aggressive taking out more dentin…
IMG_5567

Oops! Enamel is strong, but brittle. This brittleness is exacerbated by the process of autoclaving. While trying to drill away dentin, a large amount of the enamel chipped off, but I think it’s enough to use for my experiment.
IMG_5573

Here’s what I have to work with. It’s pretty thick – I imagine if I make it thinner still, it will have a better chance of vibrating. Either way, it’s a start! The view above shows the facial aspect of the tooth – just think, this was probably on someone’s mouth for 50 years, viewed by thousands of people. Now it’s in my hands, and I’m about to turn it into a radio. I love my life.
IMG_5570

From the other side, you can see enamel gets thicker toward one side of the tooth. My plan once I go home tonight (after I spend the afternoon in oral surgery, possibly extracting some teeth) is to gator-clip leads onto different sections of this tooth and run current through it. I’m thinking half a watt of 28MHz (since I have that transmitter I made yesterday still on my workbench), amplitude-modulated to produce a 300Hz tone. If my peizoelectric tooth enamel theory holds water, the tooth will vibrate at 300Hz when I do this. I can’t wait to try it out!

Update – 3pm 8/15/2011

We had a cancellation in the student oral surgery clinic, so with my unexpected free time I decided to prepare another tooth and attempt to isolate a larger, thinner selection of enamel. I chose a maxillary left lateral incisor this time, and carefully drilled it down until it was only enamel, and pretty thin at that. Take a look!
IMG_5578
IMG_5577
IMG_5583

I don’t have my calipers on me, so I can only estimate its thickness to be between 500 and 1000 microns. It’s likely still too thick to vibrate extremely well, but it will be a good starting point. We’ll see how it fairs when I apply some RF current through it tonight at home!

To add credibility to this story, here is the official description of an episode from the Gilligan’s Island Episode List wikipedia page:

Gilligan’s mouth becomes a radio when a filling in a tooth is knocked loose. Just in time too, as the regular radio is broken and a monster typhoon is on its way.
“Hi-Fi Gilligan”, Season 2, Episode 10, November 25, 1965

Update – 9:50 pm 8/15/2011

I’m starting to feel like I might have been played. I tried sending different types of current through flakes of enamel and nothing I did seemed to make it vibrate measurably. I tried audio level 5V square waves, audio level modulated RF 30PPV sine waves, and a few other things at all locations on the enamel, but I couldn’t get it to produce sound. I think it’s either (a) not thin enough to vibrate freely, (b) not highly peizoelectric, (c) not fed the correct frequency, for which I really need a RF sweep generator, or (d) simply not possible and I’m chasing a ghost on this one… If someone has any ideas of what to try, I’d appreciate it. If I can’t make it vibrate from electrical current, I’ll never make progress toward proving the “tooth radio” story, so I guess it ends here for now. If you have any ideas, feel free to share them with me! I’ll probably move on to bigger, better things now…

Second wind: I’m starting to think that I’m beginning this project too complexly. I know a quartz peizoelectric speaker works. I should probably start by replicating this, using a fragment of enamel rather than quartz. Also, most of the volume from a peizo speaker comes from its resonant chamber. Technically, this could be vibrating in front of me right now and I wouldn’t be able to hear or see it! I should find a crystal peizo speaker, replace the quartz with enamel, and start from there…

800px-Piezoelectric_buzzer Piezo-speaker

Update – 10:35 pm 8/15/2011

SUCCESS! I can’t believe I gave up that easily! I’d actually started moving onto another project, when I had an idea and revisited this one. So what if the piezoelectric vibration experiment didn’t work? Is it possible that RF could be turned into electrical signals that could be sensed by the mouth? Two dissimilar metals in contact may form a P-N junction, the fundamental unit of semiconductors. A simple diode would take audio-level amplitude modulated radio frequency signal and act as an envelope detector, producing electrical output corresponding to the audio used to modulate the carrier signal. A simple diode should do the same thing. Therefore, if a diode in my mouth produces a tingle of electricity upon RF exposure, and if I can figure out which dental materials are P-type and N-type, I can replicate this! First test, diode.
DSCN1732

There’s a simple 1N914 diode with a tooth beside it for scale reference. A diode, when exposed to RF, acts a bit like a half-wave rectifier, the body acts as a lowpass filter, and the result is a small electrical current delivered upon RF exposure. The black stripe indicates the + side of the diode. I place this on my tongue, touch the other end with my hand and and let’s try keying up a transmitter…
DSCN1733

ZAP! Even though I’m not holding the radio (as evidenced by a black/Mexican hand with nail polish), every time my wife presses the transmit button I feel a slight tingle in my mouth. This is a 5W radio a few feet away. I couldn’t even imagine what a 50,000 watt AM radio station would feel like! Now, if I can just figure out which dental materials would act like a diode, I can construct this dental device in a human tooth and measure the current produced! If I’m confident it’s sterilized, I guess I can put it in my mouth and see if I can feel it tingle. eww! I’ll cross that bridge when I come to it. Time for more research!

TO BE CONTINUED…


     

Epic Failure 1 Year in the Making

My expression is completely flat right now. I simply cannot believe I’m about to say what I’m preparing to say. I spent nearly a year cracking large prime numbers. In short, I took-on a project I called The Flowering N’th Prime Project, where I used my SheevaPlug to generate a list of every [every millionth] prime number. The current “golden standard” is this page where one can look-up the N’th prime up to 1 trillion. My goal was to reach over 1 trillion, which I did just this morning! I was planning on being the only source on the web to allow lookups of prime numbers greater than 1 trillion. flowering_primes

However, when I went to look at the logs, I realized that the software had a small, fatal bug in it. Apparently every time the program restarted (which happened a few times over the months), although it resumed at its most recent prime number, it erased the previous entries. As a result, I have no logs below N=95 billion. In other words, although I reached my target this morning, it’s completely irrelevant since I don’t have all the previous data to prove it. I’m completely beside myself, and have no idea what I’m going to do. I can start from the beginning again, but that would take another YEAR. [sigh]

So here’s the screw-up. Apparently I coded everything correctly on paper, but due to my lack of experience I overlooked the potential for multiple appends to occur simultaneously. I can only assume that’s what screwed it up, but I cannot be confident. Honestly, I still don’t know specifically what the problem is. All in all, it looks good to me. Here is the relevant Python code.

def add2log(c,v):
	f=open(logfile,'a')
	f.write("%d,%dn"%(c,v))
	f.close()

def resumeFromLog():
	f=open('log.txt')
	raw=f.readlines()[-1]
	f.close()
	return eval("["+raw+"]")

For what it’s worth, this is what remains of the log file:

953238,28546251136703
953239,28546282140203
953240,28546313129849
...
1000772,30020181524029
1000773,30020212566353
1000774,30020243594723

     

Converting Numbers to Morse Code with GCC

One of my microcontroller projects requires me to measure values and transmit then in Morse code. There may be code out there to do this already, but I couldn’t find it. I’m sure there are more elegant and efficient ways to handle the conversion, but this works for me. Hopefully someone will find it useful!

binary_to_Morse

#include <stdio.h>

//Morse code numbers from 0 to 9
char * array [10] = {"-----",".----","..---","...--","....-",
	 ".....","-....","--...","---..","----."};

void beep(char v){
	// beep (or print) Morse code as necessary
	printf("%s ",array[v]);
}

void send(int l){
	// convert a number into Morse code
	char d=0;int t=0;int val=0;
	for (t=100000;t>0;t=t/10){ //number of digits here
		if (l>t){d=l/t;beep(d);l-=d*t;}else{beep(0);}
	}
	printf("n");
}

void main(){
	// program starts here
	int l=0b1111111111; //sample number (maximum 10-bit)
	printf("%d ",l);send(l);
	l=0b11010001100101100011; //larger sample number
	printf("%d ",l);send(l);
}