Wednesday, August 26, 2015

My First Metal Detector

Over the past month or so, I've made some progress with building the metal detector circuit for my robot. Its detection range is shorter than predicted by the blog I got the circuit from, but I think that can be improved by more sophisticated programming.

First I built the circuit, using the Arduino Duemilanove and a breadboard. A commentor on the original blog post said that he had trouble prototyping on a breadboard because the "parasitic inductance, capacitance, and resistance" caused the signal to break down after a few minutes. I decided to prototype it on a breadboard anyway and then transfer to something else later (maybe perfboard?) if it became an issue. I haven't observed the signal "breaking down", although the frequency does tend to slowly increase over time.

Here's my circuit on the breadboard:

It was easy once I figured out that the capacitors on the diagram were in nanofarads, not microfarads.


It's messy, I know- I wanted to test it before I went to the trouble of trimming everything down, and since there's still a possibility that I'll do the final version on perfboard or something, I haven't cleaned it up yet. If you want to know more about what breadboards are or how they work, I covered it in a post last summer.

After assembling the circuit, I made the search coil. I wanted to try out a few different sizes of coils, to see which size would work best for this project. This site gives a thorough comparison of different sizes of coils. I wanted one coil that would match the one DZL used, 30 turns of wire around a 15 cm diameter base; the other two are 20 cm and 30 cm in diameter.

I made the coil bases out of an old paint bucket, using a bandsaw. The bucket was originally 30 cm in diameter, so I was able to just use the slice of paint bucket for that base. To make the smaller bases, I made a cut through the side of each slice, pulled the sides to overlap, and then drilled holes and zip tied them together to hold them at the correct size.

I couldn't get DZL's code to work (it kept bringing up errors when I tried to run it). I also didn't understand parts of his code- for example, at one point he sets values to certain bits, and I can't figure out what they were being set to or why. Rather than try to decipher someone else's code, I thought it would be easier to write some of my own. I knew that the premise of the metal detecting circuit was that when metal comes near, the oscillation frequency of the coil changes. After some searching, I found an Arduino library called FreqCount that has a built-in function for measuring the frequency at a node. You can download FreqCount here. I ran my tests using a modified version of the Serial_Output example code that comes with the download. You can read my version of the code here.

For the first search coil, I used the 15 cm diameter base and wrapped about 30 turns of  30AWG enameled copper wire around it, leaving a good six inches at both ends to plug into the breadboard. Enameled copper wire is insulated with a thin layer of enamel (hence the name), which you have to remove in order to electrically connect it to anything. I had heard of people chipping the enamel off with a pocket knife, but since 30 AWG wire is very thin, I wasn't too confident in my ability to make that work. I read a forum that had lots of suggestions for ways to remove enamel from enameled wire, and ended up using 320 grit sandpaper to sand the enamel off. It worked quite well, and that's definitely the way to go in the future. Next time I would get a different color of enamel though- red is so close to copper that it was hard to be sure I'd gotten all the enamel off. Green or blue wire would probably be a little easier.


In my next post (which should be up today or tomorrow), I will reveal the results of testing my first two search coils.

No comments:

Post a Comment