Higher current into ADC

Hi, I have made a metal detector with arduino. As you probably figured the range is not so long. (10cms on medium sized items, and up to 20cms on large items) thus, I want to increase the power running into the coils to get a larger magnetic field.

In my thought I am planning on connecting a transistor (ex. PN2222) to A0, for controlling a higher current (ex. A 9v battery) that will go into the coil, but here comes my problem, can I connect the other end of the coil to A1? (Just for clarification, A0 is output, and A1 is input). If not, how can I lower the current to an acceptable point.

Or do you have any tips for a more approchable method of increasing the range without modyfing the circuit too much. this is the instructable I followed.

If you read that article you will see that A0 is also used as an output to discharge the capacitor.

The capacitor can then be quickly discharged by changing the readout pin to output and setting it to 0V for a few microseconds.

So you have a double problem of having 9V on the input when A1 is an input and 9V on the output when A1 is an output. However, your problems do not stop there. It is likely that the voltage on the coil will be greater than the voltage you supply to it, that's what inductors do.

I can't see a simple change being possible especially when the original design is so poor in the first place.

Well thats nice… I guess I’ll just have go to for something more advanced.
Thank you.

Grumpy_Mike is probably right, this is probably a poor design. But, "poor" could be considered subjective. I mean, context is everything, right? And as a fun, little, hobbyist project, what the heck. And, if I were to attempt to tweak this project, to wring out a bit more range, I would try the following:

  • A larger diameter coil -- more like 9 to 12 inches.
  • Magnet wire, instead of that thick insulation stuff.
  • And, yes, more current. And I would use something more like a buck-converter arrangement. That way, the coil is in more of a current mode, rather than a voltage mode, which is more harmonious with a Digital input, or an ADC input, on an Arduino.

Thus, I would play around with something like this:


D6 drives a High-Side switch that when turned on, applies roughly 9V to L1 which induces a current that flows through L1 to C2 [and parasitically through R3]. This causes the current to ramp up as it charges C2 -- thus the voltage across C2 also ramps up. To extend the timing so the Arduino can keep up, you might need to cause a kind of stair-step sort of thing, by turning the High-Side switch ON and OFF, over an over. When the voltage reaches Vth, which is determined by the trip point on the D7 input [we're taking advantage of the Schmitt Trigger behavior of an Arduino input, here], the algorithm, notes the time, and turns the High-Side Switch OFF, allowing R3 to discharge the capacitor.

So, the goal is to time how long it takes for the capacitor to charge from some lower voltage [doesn't have to be zero] to the threshold voltage. Changes in that timing will hopefully be enough to detect when the inductance in the sensor coil changes, when the coil runs over some metal.

Now, using the Digital input as a "Comparator" is, possibly, more "poor design", because of the lack of consistency in the input parameters in play. BUT, since this is a relative measurement, it, essentially, self calibrates. The reason I'm using a Digital input, rather than an Analog input, is because it's far faster than the ADC [which can, probably, only manage around 77k samples per second, which may not be fast enough -- but, what the heck, experiment, etc...:wink:

I set R1 to a, probably, ridiculously low resistance, so there will be plenty of Gate Discharge current. It might be possible to reduce this. This is, basically, a poor-mans gate driver.

Usually, when designing a Buck Switching circuit, you try for minimal ripple, but in this case, we want enough ripple for the ramping voltage to be slow enough for the Arduino to keep up. But, it needs to be fast enough to not swamp out the small changes in inductance we're trying to read. So, not sure if this thing can be made to run slow enough for an Arduino UNO, and still provide enough sensitivity for good detection. You might need to go to something like a DUE.

An improvement would be to add a MOSFET to switch R3 in an out of circuit, so it's not bleeding off current when we're trying to charge C2. And, perhaps, add a second resistor, with a second MOSFET, so we can have a high current path, to quickly discharge the capacitor, and a lower current path to more slowly discharge the capacitor during that stair-step affair.

Note: I added Z1 to make sure the C2 voltage never gets high enough to threaten the Arduino input. So, the trick will be to tune the timing, as driven by the Arduino Sketch, so C2 is never allowed to get that high -- this would, of course, be controlled by turning Q2 OFF before this happens. But, overshoot is possible, so, hopefully, Z1 will save the day! BUT, if Q2 is left on too long, Z1, and/or Q2 could become toast! Why "4V" on that Zener, and not, say, 4.5V or 5V? To stay on the safe side of tolerances, and temperature effects, etc, and because I'm too lazy to dally in the details.

Note2: C1 is there to supply immediate current to the task of charging the L1/C2 pair. Place C1 as close to the Q2 Source, as possible. And, for that matter, keep both C1 and Q2 as lose to L1 as possible.

Note3: In case it wasn't obvious, configure D6 as an Output, and D7 as a Digital Input. And, of courses, you can use other Digital pins -- it doesn't have to be D6 and/or D7. Also, it might be peachy to use a PWM Output [analogWrite] for driving Q1, then you could set the Duty Cycle to produce that sawtooth affect. But, you'll probably have to override the PWM defaults to get a high enough frequency to make it work. And, for the UNO, D6 happens to be PWM enabled! Here's the official take on speedier PWM: https://www.arduino.cc/en/Tutorial/SecretsOfArduinoPWM

BTW: here's a thread on speeding up the Arduino ADC, in case you want to try that: https://forum.arduino.cc/index.php?topic=6549.0Fboost

Just a note:-

is because it's far faster than the ADC [which can, probably, only manage around 77k samples per second, which may not be fast enough

The normal unspeeded up rate from the A/D is 10K samples per second. But I can't see that making a difference to the sensitivity of the circuit. The responsiveness yes, you could sweep the thing faster, but not the actual sensitivity.

Grumpy_Mike: Just a note:-The normal unspeeded up rate from the A/D is 10K samples per second. But I can't see that making a difference to the sensitivity of the circuit. The responsiveness yes, you could sweep the thing faster, but not the actual sensitivity.

I agree. And, I only spoke of ADC speed in terms of keeping up with the C2 ramp speed -- i.e. so the threshold is detected at near enough real-time to make it viable.

ReverseEMF: Note: I added Z1 to make sure the C2 voltage never gets high enough to threaten the Arduino input.

You can achieve the same with a current limiting resistor in series with the pin. Then the clamping diodes will do the voltage limiting, the resistor protecting those in turn against over current.

This then also allows you to increase the voltage swing in your inductor, increase the current, and increase the range.

For measuring the discharge time of the capacitor I'd use a digital input and an interrupt - much better timing precision than the ADC could dream of. Use D2 or D3 as the sensing input, interrupt on either falling or rising as appropriate.

Part of the trick is going to be to sync your timing with the PWM output: you'll want to count clock cycles (timer set to no prescaler) for maximum resolution. If you keep your frequency low enough to have at least 1,000 cycles (i.e. 62.5 us before the interrupt occurs; so aiming for an LC of about 100 us and frequency 50 kHz) you'd get a nice resolution.

Of note: C2 must be a film type. Polyester (the cheaper, smaller film caps) will do great, polypropylene (the larger, bigger film caps - often used as safety caps in 220V AC operations) are even better. Ceramic will give unstable results.

A very different, possibly easier approach, is to use an LC tank circuit: Clapp oscillators can be made ridiculously sensitive, that I experienced when playing with theremin type sensors. The theremin uses a fixed inductor and variable capacitor (the sensing wire); you can of course turn this around. The Arduino in this case is not measuring the discharge time, but rather the frequency (my experimental oscillators were working at 3-6 MHz, which an Arduino handles just fine, though I'd want to bring it down by a factor 10).

Grumpy_Mike: Just a note:-The normal unspeeded up rate from the A/D is 10K samples per second. But I can't see that making a difference to the sensitivity of the circuit. The responsiveness yes, you could sweep the thing faster, but not the actual sensitivity.

Yes, I should have noted that I was talking about the MCU's ADC limit, not the limit imposed by the Arduino system.