While browsing the 'net the other day, looking for information about inductors (what they are, what they do, what they're used for) I stumbled upon this interesting animation. They say a picture speaks a thousand words; this one explained inductors and LC oscillators beautifully:
It came from this website: http://www.talkingelectronics.com/projects/Inductor/Inductor-2.html
Now in itself this demonstrates a fascinating property of inductors and capacitors when connected together. But then we came across this - http://www.schoenbuch-electronic.de/index.php?id=145
Which suggests that placing a metal object near an inductor affects the magnetic field and causes the frequency of the oscillator to change. Now that got us thinking:
If instead of the blue wire we connected the LC oscillator to a PIC i/o pin, we could set the pin to output mode and "charge" the circuit. After a delay, we could turn the pin to an input and set a timer running. When the input on the pin changes from low-to-high, we've got a means to calculate the frequency of the oscillator. We've ignored the negative voltage from the circuit because with PIC microcontrollers, every input pin has a clamp diode ensuring only voltages within the range 0-Vcc are accepted. In fact, a PIC is a pretty robust device and can handle really large +ve and -ve voltages (http://www.electro-tech-online.com/microcontrollers/96653-detecting-12v-pic-input-running-5v-off-7805-a.html ). The only thing we need to do is make sure the input diodes are protected by large value resistors.
So the principle is we send a pin high, wait, set it to an input then wait to see how long it is before we get a response back on the input pin. If the delay is larger or smaller than expected, we can confidently say that a metallic object is present. If only we could work out the "natural" oscillation of our LC circuit....
This website had just what we were looking for! http://www.deephaven.co.uk/lc.html
If we type in an inductor and capacitor value, it works out the expected frequency of the circuit. Perfect!
So now we have a very basic metal detector circuit. What now?
About a year ago, we started work on an electronic board game (Blood Bowl). After hitting problems with capacitive sensing, not much more was done with it. But this latest development has got us thinking - the playing pieces in the game are (pewter) metal (but the same approach could be used for many board games, with a small piece of metal inserted into the base of the playing pieces). If we could use inductive sensing to detect when a piece is placed/removed from the board, our idea of a digital board game could well be back on! And coupled with the alarm clock audio player we came up with a few months back, could even include sound effects too!
Given that a chess board has 8x8 = 64 squares, and a board game has 300 or more playing squares, it's going to be important to keep costs down on this idea. So we're looking for
a) cheap inductors
b) cheap capacitors
c) accurate capacitors (there's no point using -20%/+80% caps to detect a 25% change in inductance!)
d) easy to use components (there's going to be a lot of soldering!)
So we came up with a shopping list.
These surface mount inductors from Farnell are less than 5p each in volumes of 100+
They're 1.5mH and accurate to 10%. They're in an 1812 surface mount package, so just a bit bigger than the SMT resistors we're already familiar with
These surface mount capacitors are 1.5uF, also accurate to 10% and cost less than 3p each.
They're also in the familiar 1206 SMT package so should be quite easy to work with.
If we use a 1.5mH inductor and a 1.5uF capacitor, in theory we should be able to create an LC oscillator which runs at about 100khz - ideally we could use "bigger" value components and get a slower oscillation; but a PIC micro running of a 20Mhz crystal should be plenty fast enough to read any variance in a 100khz signal, so we're trying to keep the cost down and use as cheap components as we can get hold of!
Using the components we've identified, each square on the board will cost 8p in components (not including the MCU or any external i/o expanders or shift registers). Although this isn't a massive cost, for anything more than a simple chess-type board, things could easily get very expensive, very quickly. For example, a Blood Bowl board is 15x26 squares in size: that's 390 squares. For just the inductors and capacitors, that's £31.20. Not a massive cost for a one-off prototype, but quite pricey if we ever decide to make more than one!
Before we go crazy buying up loads of kit and components, it's probably best to try the idea out with a few rows and columns on a board game board. That's exactly what we're going to do - and post the results here in a few days.......