Boxcar Integration, an example using AN231E04 FPAA in a Pulse Induction Metal Detector

App Note AN308 (1.20 MB, 1 pdf file):   Boxcar Integration and Pulse Induction Metal Detector

Introduction
The purpose of this document is to illustrate the use of the boxcar integrator in the AN231E04 to create a possible metal detector circuit.

This application note is not intended to provide a perfectly optimized design for a metal detector, but rather to illustrate how the AN231E04 might be used in one and give a design which is a starting point for the user to try out and improve upon. Okika Devices does not make metal detectors and does not teach how to make metal detectors; it is for the user to develop his own system using the principles set out in this application note as a guide.

The metal detector used here is of the pulse induction type. A large current is sent through an open coil of wire and then switched off very rapidly. This switching off of the current creates a large reverse voltage spike (kick-back) of hundreds of volts which induces eddy currents in any nearby metal objects. As the voltage spike in the coil decays away, its decay is affected by these eddy currents.
Pulse induction metal detectors have always been considered as having good detection range but not being good at discrimination, i.e., distinguishing between ferrous and non- ferrous metals. In this application note, we show how the IntegratorHold CAM, more colloquially known as the boxcar integrator, can be used not only to detect metal but to analyze different portions of the decay curve and use this to discriminate between silver/gold and iron.

This application note describes in detail the back end of a metal detector which includes a coil, coil interface circuit, and FPAA circuits. It does not describe the front end (user interface) although it gives some hints as to how this might be done. What it does describe is how a large signal change can be made on an FPAA output in response to the metal being in the vicinity of the coil.

The purpose of the front end is to allow the user to tune the circuit and to hear or see any responses, e.g., through the speaker, headphones, LEDs, plot on a computer screen, or whatever. The reason for not including any detailed information on the front end is because it is specific to the type of application and so must be designed by the user. For example, the metal detector may be part of a system monitoring objects on a conveyor belt, in which case the front end would consist of a computer with Graphical User Interface. If the metal detector is for treasure hunting, it will be an embedded system with a microcontroller and potentiometers, switches, LCD and speaker/headphone output.

Whichever type of system it is, it will involve software, sometimes called an API. Whether the software resides on a computer or in a microcontroller, what it will do is take inputs from the user (for tuning) and adjust CAM parameters in the FPAA, and it will take the output from the FPAA and convert this to something the user can understand, such as a change in volume or tone of a sound.
In an embedded system there will probably be potentiometers to do the tuning, and these will probably adjust the gain or corner frequency of filter CAMs. There will also be a switch that changes between detection and discrimination.

The switch will change between circuit states. The discrimination circuit has a different boxcar integration window and different settings in the filters.

Note that metal detection is only one example of where boxcar integration can be useful. They are useful for measuring a portion of any noisy but repetitive signal. In this particular application, we are not so much interested in the absolute measurement of a portion of the signal but of the change in that portion. For this reason, we use a technique of integrating across a part of the signal that crosses zero, so producing a zero or near zero net integration. This small output from the boxcar integrator can then be greatly amplified. Any change in the signal, either in voltage or time, will create a change in the net integration output from the boxcar integrator.

The Circuit
The circuit was built on an AN231K04 development board. The board was powered by +5V which gets converted to +3.3V by the on-board regulator for powering the AN231E04 (FPAA) and digital circuitry. A circuit to power the coil was built onto the breadboard area of the development board, and this was powered by the +5V external supply. The next two sections will describe the external coil circuit and the AnadigmDesigner®2 Software circuit that gets configured into the FPAA.

The Coil Circuit

Figure 1 below shows the coil circuit. The coil itself was made from approximately 30m of 24awg single core wire made into an open coil approximately 17cm across. The resistance of this coil is about 2.5Ω.

The purpose of the coil circuit is to allow a large current to flow in the coil and then to switch it off as fast as possible. Most pulse induction circuits use a single N-channel MOSFET for this purpose, but here we use both an N-channel and a P-channel MOSFET. The reason for this is so that the coil can be completely isolated from the supply after the current is switched off, allowing the coil to be pulled to VMR (+1.5V Voltage Mid Rail of the FPAA, also known as signal ground). This method makes full use of the differential architecture of the FPAA as both sides of the coil are monitored by the FPAA’s differential input. The MOSFETs in this circuit were chosen to have the following parameters: high breakdown voltage, high current limit, threshold voltage below 5V (or greater than -5V for the P-channel), and a very fast turn off time. The MOSFETs have to be driven by MOSFET drivers. In this example, we use TC4420’s which are powered from the +5V external supply to the board. These not only boost the drive of the signals from the FPAA but also convert those signals from +3.3V to +5V.

In figure 1 there is a 470uF connected between +5V and ground. This helps keep the +5V supply voltage smooth as it switches between driving a low current for 800us and >1A for
200us. If the power supply is a good one then the capacitor may not be necessary.

The coil requires a damping resistor across it to stop oscillation from occurring when the current is switched off. Usually, this resistor has a value of 470Ω or 680Ω. In this case, we deliberately under-damp the coil with an 820Ω resistor. The reason for this will be explained later.

Finally, there a two 100kΩ resistors between the coil and the FPAA. Since the kick-back voltage spike can exceed 500V, then the need for these resistors is obvious. In combination with the input protection in the FPAA, this is sufficient to protect the FPAA from damage. Note that many pulse induction circuits include back-to-back diodes for protection, but these were found to affect the decay curve after the kick-back so are not used.

Figures 2a and 2b show the bench set-up with home-made coil, development board with coil circuit built onto it, and a scope probe monitoring the output.

 

 

The AnadigmDesigner®2 Software Circuit

Figure 3 shows the AnadigmDesigner®2 circuit. It consists of the following stages:

  1. Primary Pulse – an OscillatorSawSqr custom CAM produces a 2.5V ramp output at 1kHz which drives a comparator whose negative input is connected to +2V. This produces a square wave which is high for 200us and low for 800us. This is the primary pulse that drives the coil.
  2. Secondary Pulse – the primary pulse resets a PeriodicWave CAM. This CAM is used to generate a secondary pulse to drive the IntegratorHold CAM (boxcar integrator). The PeriodicWave CAM uses the LUT (Look- Up Table) to create a user-defined waveform, and by editing the LUT, the user can define the width of the secondary pulse and also its delay following the falling edge of the primary pulse.
  3. Coil Filter – there is a low-pass filter on the input from the coil which can be used to both amplify and filter the voltage from the coil.
  4. Boxcar Integrator – or IntegratorHold CAM will integrate over a section of the coil decay voltage after the kick-back spike. This is controlled by the secondary pulse.
  5. Output Amplifier/Filter – there is another low-pass filter which amplifies the output from the IntegratorHold CAM and filters it to remove noise. The corner frequency is set very low at ~1Hz. This affects the responsiveness of the detector.

The IntegratorHold CAM (boxcar integrator)
Figure 4 shows the IntegratorHold CAM parameter window along with a close-up of the CAM itself. The purpose of this CAM is to integrate a signal on its input over a window in time defined by the input to the comparator. In our application, the comparator input is compared with signal ground, and a high into the comparator will cause the integrator to integrate at a rate defined by the Integration Constant K. When the comparator input goes low the integrator stops integrating and the Hold part of the CAM holds the level at which the integration stopped.

In this application, it is useful to see the direct output from the integrator for setting up the integration constant K. The integration constant should be set at such a level so that the integrator output goes close to its minimum (-3V) or maximum (+3V) level without hitting either rail and so get clipped. The ideal integrator output can be seen in sections 4.1 and 4.2.


The IntegratorHold CAM does not have a direct output from the integrator, but it is possible to view the integrator response by temporarily replacing the IntegratorHold CAM with the standard Integrator CAM. The integrator CAM’s reset function should be enabled and the “Reset When” option set to Control Low. When the control input is high, the integrator output can be monitored, and K adjusted to suit the conditions described above.


NOTE: all voltages inside the FPAA and on its inputs and outputs are differential. For example, a voltage of +3V inside the FPAA means a differential pair with voltages of +3V and 0V, or more correctly +1.5V and -1.5V relative to the FPAA’s signal ground or VMR (Voltage Mid Rail = +1.5V). The point of using 2 MOSFETs on the coil is so that it can be completely isolated and both sides connected to the differential input of the FPAA. This means better accuracy and noise immunity.

Operation
Figure 5 shows the voltage across the coil during 2 cycles (not to scale). Before the main pulse the coil voltage will be close to 0V (there may be some residual voltage from the previous kick-back pulse). During the main pulse, the voltage goes up to some positive voltage dictated by the potential divider of the coil in series with the 2 MOSFETs. In our set-up, this voltage was about 4V. It will not go instantly to this voltage because of the inductance of the coil.

The main pulse should be of sufficient length to allow the coil’s magnetic field to build up because the stronger the magnetic field then the deeper the penetration of the magnetic field into the soil. However, the pulse should not be too long (>250us) because this may over-saturate the ground which makes small objects invisible due to background noise. Also, if current consumption is an issue (most metal detectors are battery powered), then the duty cycle of the main pulse should be kept as low as possible.

At the end of the main pulse, the MOSFETs are turned off very fast, and the current in the coil collapses. This causes a reverse voltage spike or “kick-back” which is hundreds of volts. In our system with a 200us main pulse, the spike was about -500V. With a longer main pulse, this went up to about -700V. Ultimately the size of this spike will be limited by the breakdown voltages of the MOSFETs.

In most systems, a damping resistor of 470Ω or 680Ω is used. If damping is sufficient, then there is no over-shoot when the kick-back decays. This is shown as the blue curve in figure 5.

In our system, we choose to under-damp the coil with an 820Ω damping resistor. This leads to an over-shoot followed by a subsequent decay but no prolonged ringing.

Figure 6 is a close-up view of the over-shoot and subsequent decay after the kick-back pulse. These waveforms are internal to the FPAA and have been amplified by the first stage bilinear low-pass filter CAM. It shows the two regions of interest. 1 Discrimination; the over-shoot is where we discriminate between silver or gold and worthless ferrous metal, and 2 Detection; the decay is where we detect all metal. In the next two sections, we describe in detail how the detection and discrimination are carried out.

NOTE: Unique to Okika Devices FPAA technology: Dynamic reconfiguration of the FPAA is required to change the FPAA configuration between the two circuits required for detection and discrimination.

Metal Detection
Figure 7 shows the same curve as figure 6 but with greater amplification and lower corner frequency in the input filter.

Any metal in the vicinity of the coil will cause the decay part of the curve to drop or become more negative. Figure 8 shows how the IntegratorHold CAM (boxcar) is used to integrate across the portion of the curve that crosses 0V. In this way, we generate a net integration which is small and can be greatly amplified. The green curve shows the integrator output which initially goes close to +3V and then falls back close to 0V. This final (small) level is held on the output of the CAM (sample and hold within the IntegratorHold CAM) and can be amplified by the following CAM. This method is very sensitive to any change in the curve, either in voltage or time.

With no metal near the coil, the integration is balanced across the integration window leading to a near zero result. When metal comes close to the coil, the curve drops causing a negative shift in the integration. This part of the detection process will respond to any kind of metal that comes close to the coil. By carefully setting up the circuit so that the output from the IntegratorHold CAM is close to zero when no metal is near, we can then use high gain to amplify its output to make the detector very sensitive.

To maximise the sensitivity of the metal detector, it is necessary to tune the AnadigmDesigner®2 circuit so that the integrator output finishes as close to 0V as possible with no metal. The integration window can be altered by adjusting the look-up table in the PeriodicWave CAM, but this is a coarse adjustment. To fine tune the circuit, the corner frequency of the input filter can be adjusted.

The next section describes how we discriminate between silver/gold and ferrous metal.

Metal Discrimination

 For discrimination, we use a lower gain and higher corner frequency in the input filter to produce the waveform shown previously in figure 6. We now integrate across the zero crossing immediately after the kick-back voltage spike (figure 9). The filter parameters are chosen in such a way that when there is no metal near the coil, the net integration across the integration window is near to zero. Ferrous metal near the coil makes the curve shift to the right and down causing a negative shift in the net integration. A piece of silver or gold near the coil causes the curve to shift to the left causing a positive shift in the net integration.

By carefully setting up the circuit so that the output from the IntegratorHold CAM is close to zero when no metal is near, we can use high gain to amplify its output to make the discriminator very sensitive.

As in the detection case, to maximize the sensitivity of the metal detector, it is necessary to tune the circuit so that the integrator output finishes as close to 0V as possible with no metal. The integration window can be altered by adjusting the look-up table in the PeriodicWave CAM, but this is a coarse adjustment. To fine tune, the circuit, the corner frequency of the input filter can be adjusted.

 

Complete System

This application note has tended to concentrate on the front end of a pulse induction metal detector, showing how an FPAA can be used to monitor the voltage from the search coil and convert any changes into a voltage level. In particular, it has explained how an IntegratorHold CAM, more colloquially known as a boxcar integrator, can be used to monitor specific parts of the signal from the search coil and convert any changes in the signal into an output voltage. Okika Devices is able to supply both of the circuits (detection and discrimination) as well as the two CAMs that are included in them. These circuits can be downloaded from a PC to the Development Board, and the CAM parameters can be adjusted using AnadigmDesigner®2. NOTE: the user will have to build the coil circuit onto the breadboard area of the board (see figures 1, 2 and 10). The FPAA output can then be monitored with a scope or meter. The next two sections describe better ways to control the metal detector.

GUI CONTROL

To control the metal detector requires the ability to switch between the detect circuit and the discriminate circuit, to adjust the signal conditioning input filter for optimum performance, adjust the output gain, and finally to monitor the output from the FPAA. This can be done using a computer with AnadigmDesigner®2 to load different circuits and adjust CAM parameters, and an oscilloscope or meter to monitor the output. However, this does not make for a very convenient metal detector. It would be far more convenient, though still not very portable, to control everything from a GUI (Graphical User Interface) on a computer. The set-up is shown in figure 10.

In figure 10 it can be seen that the development board consists basically of an FPAA, a microcontroller (PIC), a 3.3V regulator to supply both FPAA and PIC and a breadboard area. The purpose of the PIC is to act as an interface between a computer and the FPAA. Configuration commands are received by the PIC from the computer over a serial link (USB or RS232) and converted into correctly formatted data and clock to send to the FPAA. It can also receive an analog voltage via one of its ADC channels and return the value to the computer.

It is fairly straightforward to construct a GUI which will allow much easier selection of circuits, adjustment of parameters and monitoring of output. This GUI would consist of either radio buttons or push buttons to select operating mode (detect or discriminate) and sliders to adjust CAM parameters. The GUI could also display the response from the FPAA using whichever audio/visual means the user finds most pleasing.

Okika Devices does not supply a GUI with this application note.

Embedded Control

The GUI controlled system described in the last section is not very portable. Most metal detectors are handheld battery powered devices. To achieve this; the FPAA could be controlled from a microcontroller. The microcontroller in figure 10 is acting purely as a conduit for commands and data between FPAA and computer, but it could be loaded with software to make an embedded system which is completely isolated and portable.

Such a system would likely have knobs (potentiometers) and push buttons or switches to control the FPAA. This would work by the knobs and switches changing voltages which can be monitored by the controller’s ADC channels. The controller could then respond with the appropriate commands to the FPAA. Also, the output from the FPAA would be monitored by the controller via an ADC channel, and it would then adjust some sort of audio/visual output accordingly. This might be a tone, or an LCD display, or old fashioned needle display, or combination of these.

NOTE: there is spare resource in the FPAA which could be used for an oscillator CAM. An external driver may be needed to allow the oscillator to drive a speaker. The controller could then adjust the frequency of the oscillator CAM in response to the detector output to provide a tone of varying pitch. This is shown in figure 11.

Okika Devices does not supply embedded code with this application note but there are other application notes that describe how to write such code.

Simulation
It is possible to simulate the circuit by using the simulator signal generator and using the arbitrary waveform selection to copy a coil response. This can be done by creating a waveform in Excel that looks like the coil response, generating a.CSV file from it, and then loading that CSV file into the signal generator.

Excel Spreadsheet
An Excel spreadsheet is provided with this application note. In it the waveform with the following formula is plotted:
Vout = -A.exp(-K.t).sin(2.π.F.t)

This waveform is an attempt to emulate the coil kick-back response. A is the amplitude, K is the decay constant, and F is the frequency. There is a minus sign in front of the equation in order to match the response shown in figure 4, i.e., with the initial high voltage spike being negative. The exponential term provides the decay function, and K should be large to make the waveform highly damped.

It is not easy to calculate values for A, K, and F so the user must use trial and error. By adjusting the values, it should be possible to get a waveform that closely matches the user’s own coil response. As a guide, the frequency F should be adjusted so that the time between the start and end of the main kick-back pulse is the same as the real world response. The amplitude A should be adjusted to achieve the same peak amplitude of the kick-back response.
 Note that the peak amplitude will be considerably less than A because the response is so highly damped. Finally, the constant decay K can be adjusted so that the overshoot following the kick-back pulse is similar to the real world.
Figures 12a, 12b and 12c show the decay curve, the overall waveform, and an expanded voltage scale version clipped at +/-3V. When the user is happy with the waveform, the file should be saved to preserve the parameter settings. Then select sheet two by clicking on the tab labeled CSV data. Save this sheet as a.CSV file (comma delimited).

 

Running the Simulation

To run the simulation, first a simulator signal generator should be connected to the input of the AnadigmDesigner®2 circuit, and then probes added at strategic points in the circuit (see figure 13).


Figure 13: AnadigmDesigner®2 circuit simulation

Double click on the signal generator and select the arbitrary wave setting, then navigate to
the .CSV file and click OK (figure 14).


Figure 14: Simulator signal generator setting

Now click on the “sim” symbol at the top of AnadigmDesigner®2. Figures 15a, b, and c show three simulations.

 

Figures 15a shows a perfectly tuned circuit and a net zero integration across the integration window. In figure 15b the waveform’s damping was increased slightly which has led to a net positive integration. In figure 15c the waveform’s damping was decreased slightly which has led to a net negative integration.

The user needs to experiment to see what adjustments in the three parameters of K, F, and C, lead to the best modeling of metal under the coil. The above simulations were carried out for detection only; the user can experiment himself with modeling discrimination.

NOTE: the circuit in figure 13 is using the standard Integrator CAM so that the actual integrator output can be seen in the simulations. The ideal integrator output should go close to +3V and then return to 0V if there is no metal. In actual use, the IntegratorHold CAM should be used as it is necessary to hold the final value of the integration.