You are on page 1of 58

Theory and Principles Used for Construction of Magnetometers

NAME: CLASS: INSTRUCTOR: SUBMITTED:

Jeff Petermann 4400:693 Sensors and Instrumentation (Special Topics) Dr. Ida 12/13/2010

Department of Electrical and Computer Engineering The University of Akron Akron, OH 44325

Table of Contents
1.0) Introduction 2.0) Proton Precession (PPM) 2.1) Geometry 2.2) Theory 2.3) Matlab Simulation 3.0) Fluxgate 3.1) Linearization of BH Curves 3.2) Field Intensity due to Drive Voltage 3.3) Field Intensity due to External Field 3.4) Sense Winding Output 3.5) Matlab Simulation 4.0) Fluxgate Design 4.1) Circuit Design and PCB Layout 4.2) Firmware Block Diagram 4.3) Preliminary Results: Proof of Concept 4.4) Experimental Results 5.0) Conclusion 6.0) Acknowledgements 7.0) References Appendix A: B: C: D: E: Matlab Code Simulation for Proton-Precession Magnetometer. Datasheets for Cores Used in the Fluxgate Simulation/Design. Matlab Code Simulation of the Fluxgate Magnetometer. Circuit Details for the Fluxgate Magnetometer. Firmware for the Fluxgate Prototype.

1.0) Introduction
Electromagnetics plays a fundamental role in the development of many different types of sensors that cross over into many disciplines of engineering. One interesting example is magnetometers. Magnetometers measure the magnitude and/or direction of magnetic fields depending on the design. A primary application for this device is for characterizing the Earths magnetic field in geophysics although many others applications exist. Early measurements were made with mechanical devices such as dip needles and field balances. These were mostly replaced by the Fluxgate Magnetometer and the Proton Precession Magnetometer (PPMs) [8]. These two devices were inexpensive while maintaining comparable or better accuracy. Other types of magnetometers include the combination of an interferometer and an optical fiber, gas based optically pumped magnetometers, and superconducting quantum interference devices (SQUIDs). This paper will focus on examining the underlying principles of the Fluxgate and PPM style devices. Simulations have been developed for both types using Matlab while a prototype was constructed of the fluxgate. The prototype uses a more recent variety known as Pulse-Position Fluxgates which are also referred to as a Fluxset by some authors [5]. 1.1) Applications: A wider view of applications exists for magnetometers which includes [8], [5]: * Quality Testing. * Detection of Submarines and other vehicles. * Mineral and petroleum exploration. * Geological mapping. * Measurement of magnetic properties of rocks or ferromagnetic objects. * Paleomagnetism. * Archaeological prospecting. * Conductivity mapping. * Magnetic modeling. The fluxgate prototype designed in association with this study was envisioned for use in geophysics applications. Hence it was designed to provide a portable, low power, and inexpensive hand-held device for field measurements in remote areas.

2.0) Proton Precession Magnetometers (PPM)


PPMs utilize some fundamentals used in Nuclear Magnetic Resonance Imaging (NMRI or MRI). Specifically, they utilize the magnetic moment generated by protons. Some materials are more suited for this task based on their atomic nature. In the presence of external magnetic fields the direction of the magnetic moment rotates, or precesses about an axis related to the ambient magnetic field. By polarizing a substance with a magnetic field that is several orders of magnitude greater than the ambient field the precessing magnetic moment aligns itself to the polarizing field. This field is then removed abruptly and this precession returns to a direction associated with the ambient field. The frequency of the precession is dependent on the magnitude of the ambient field. This provides the basis for measurement. Figure[1] demonstrates this process where Ba is the ambient flux density associated with the ambient magnetic field, m is the magnetic moment caused by a spinning proton, which rotates at a frequency 0 which is the Larmor frequency[1]. The precession occurs around the axis of the ambient, or any magnetic field, that is present.

z Ba m y x Spinning Proton m rotates at frequency 0

Figure 1: Proton Precession.

It is known that a relationship exists between the rate of precession and the magnetic field for specific atoms. The relationship has been quantified as the gyromagnetic constant, , shown in Equation[1]. In a typical measurement, 0 is measured, is known based on the material used in the PPM, and B can be solved for. = (1)

Further, the angle can be represented as vector components of m shown in Equation[2]. = ( + ) (2)

2.1) Geometry To facilitate measurements, a winding is constructed to create a polarizing magnetic field and to measure the resulting precession signal. Three common geometries discussed in literature are solenoids[2],[3], cylinders[3], and toroids[2],[3]. The solenoid suffers from a major drawback. When the ambient magnetic field is parallel to the polarizing magnetic field, no signal can be measured. Due to the shape of toroids a signal can be measured at any orientation. The amplitude of the measured signal can be reduced by a less advantageous orientation but it is still measureable. Subsequent discussions on theory will be based upon toroidal configurations. Further details on signal amplitude are discussed in Section 2.3. Figure[2] shows examples of external and internal magnetic fields. Most importantly, for toroidal geometries an ambient field cannot be perpendicular to Bp for all points (which would result in the absence of an induced signal).
Ba

Ba

BP
X X X

X X X X

BP

BP

Solenoid Geometry

Toroidal Geometry

Figure 2: Solenoid and Toroidal Geometries Used in PPMs

When the sample is polarized all, or nearly all, magnetic moments are aligned to the polarizing field and precession ceases. Hence when the polarizing field is turned off no induced voltage occurs since the ambient is already aligned. Thus for the solenoid configuration it will not be able to measure these fields. For the toroidal configuration, since Bp is not constant in only one direction, an induced signal always occurs. 2.2) Theory The theory behind PPMs can be described in three steps. First, the proton-rich material must be polarized. Secondly, the induced signal results from precession when the polarization ends. The amplitude of this signal will be a function of the directions of the fields and will be critical to designing an appropriate sensing coil. Third, the frequency of this signal is used to extract field strength information. The focus of these derivations will be for the toroidal geometry. The proton-rich material will be referred to as a sample and for some examples water will be used, however other materials are suitable based upon their chemical makeup. The polarizing field in a toroid can be determined by application of Amperes Law shown in Equation[3]. Fundamental concepts can be found in [4]. The contour chosen to evaluate Equation[3] is shown in Figure[3] by the dotted line since the tangential magnetic field is

constant along this contour. Evaluating H is straight forward and in Equation[3] r is the average radius and N is the number of turns. Another useful term is the total magnetization, Mt, which is described by Equation[4], where 0 is the volume magnetic susceptibility which is a material property. = (3)

(2 2 = =

)=

BP
X X

Ip

N N2 N1

BP
X X

(4)

Contour for Application of Amperes Law

Figure 3: Calculation of Polarizing Field Density

The magnetic susceptibility is a bulk parameter obtained experimentally and can be found in tables. An alternative method to quantify the total magnetization is as follows. To take into account the likelihood of incomplete polarization of the sample, a fraction of aligned dipoles can be estimated by relating magnetic energy of the protons divided by thermal energy to obtain a fractional coefficient[3]. First, assume that only some of the protons are completely polarized while the remainder is un-polarized. The magnetic energy of the proton is |m|*Bp while the thermal energy is kT where k is Boltzmanns constant (1.38x10-23) and T is the temperature in Kelvins. Thermal agitation prevents some protons form being aligned[3]. Hence the fraction of polarized protons can be related by Equation[5]. = | | (5)

The maximum number of protons that exist in the sample is N by Equation[6] where p is the number of protons in one molecule of the substance, d is the density, and w is the molecular weight (for water p=2, d=997.05 kg/m3 , w=18amu): = (1.67 10 ) (6)

= 66.3 10 Then the total magnetization in A/m will be:

| |

(7)

Next, the magnetic moment needs to be determined from precession. This is described by the Bloch Equations[2] . = (8)

= =

(9) (10)

This vector is described in Cartesian <u,v,w> coordinates that correspond to the ambient field where w is in the direction of Ha, u is parallel to the y axis, and v is the orthogonal to u and w. T1 and T2 are time constants. Note also that u is in a plane of constant z. This is demonstrated from three vantage points in Figure[4].
z w, Ha y u x
(a) 3D View of <u,v,w> and <x,y,z> coordinate systems (b) Looking into x direction (c) Looking into u,y direction

w, Ba

w, Ba

x y

u,y

x v

Figure 4: <u,v,w> coordinate system for Bloch Equations imposed on a Cartesian <x,y,z> system.

This system of equations can be solved by combining Equation[8] and [9] to obtain a relationship which includes the precession frequency, 0. One solution is as follows: i) Rearrange Equation[9] and Differentiate: = = ii) Insert (i) into Equation[8]: 1 1 + + 1

iii) Multiply through (-1/wo): + iv) Collect Terms: + 2 v) Find Roots: = + 1 1 + 1 + 1+ = 2 =0 + 1 + =

vi) Solution Form: Solution for a 2nd Order Constant Coefficient ordinary differential equation: = Similarly =
( ) sin( ( ) cos(

) )

) sin ( ) cos

) )

(11) (12)

To calculate the flux density in the core from the magnetization while neglecting the field strength (assumed small compared to the magnetization) B is estimated by Equation[12]. = (13)

Recall that B in Equation[13] is in the <u,v,w> system. It is necessary to impose this value in the <x,y,z> system and then convert to cylindrical coordinates for use with Equation[3]. By inspection of Figure[4] the transformation to <x,y,z> is shown in Equation[14]. = = cos( ) cos( ) (14 ) (14 )

(14 )

Next to transform to cylindrical coordinates the following transformation can be used[4]: = cos( ) + sin ( ) = = sin( ) + cos ( )

Then B is obtained: = cos( ) sin ( ) = = cos ( )

= (

) cos( ) sin( ) (

) cos( )

(15)

However, there still remains unknown variables Mv and Mu which requires Mv(0+) and Mu(0+) to solve. The initial value at time 0+ is the same value at the end of polarization. The total magnetization, Mt in Equation[5], due to polarization is known in terms of the direction so using the Cartesian to Cylindrical transformation in reverse yields: = cos( )

sin( ) cos ( )

Next, after substituting Equation[11] & [12], inserting Equation[4] into [15], and a great deal of simplification yields Equation[16]: = 2 1 ( ) ( ) cos( ) (16)

The signal voltage of the sensor winding is our goal and can be evaluated from Faradays Law. To do this, the flux () (not the cylindrical axis ) must be solved from as in Equation[17] using B and is shown in Figure[5]. Then the time derivative of Equation[17] can be taken and inserted into Equation[18]. Finally d/dt can be substituted into Faradays Law, Equation[18], to for the sensor voltage. The final solution of sensor voltage is shown in Equation[19]. = = B h 2 = ( )= (17) 1 ( ) ( ) cos( ( ) )

)( ) (18)

) 1 2

( )

2 1

2 1

cos (

sin (

( )=

)(

) 1 2

( )

( )

2 1

cos(

sin(

(19)

dr R1 r R2 h

Figure 5: Cross Section of a Toroid for calculation of .

The derivation for signal voltage is useful for design, however to determine the ambient magnetic field, the Larmor Equation can be related to the precession frequency. The goal of the accompanying electronics is to measure the frequency of the induced signal. Then, with knowledge of the proton contributing material, the gyromagnetic ratio for that material is related to Ba and 0 by Equation[1] which is repeated here. The gyromagnetic ratio is a material property based on atomic structure and is treated as a constant. = (1)

2.3) MATLAB Simulation: The following simulation takes ambient magnetic fields oriented along three different directions and simulates the signal measured by the sensor using the theory presented in the previous section. In the simulation, any direction can be entered. For this example the vectors chosen are shown in Figure[6]. The Matlab output is shown in Figure[7]. The code is included in Appendix A in the standard Matlab publishing format. The simulation confirms that the toroidal configuration allows for measurement regardless of orientation (as opposed to the solenoid configuration) and gives some insight into what the nature of the signal that requires measurement. It can be seen that it is an oscillatory signal that decays with time as the field precesses and that the amplitude can be in the microvolt range for smaller sized sensors.

Z External Field in YZ plane

External Field in XZ plane

External Field in XY plane

Figure 6: Simulated Fields for Matlab Code.

Figure 7: Output Voltage for Selected Field Orientations.

3.0) Fluxgate Magnetometers:


The second class of device that this paper focuses on is the fluxgate style magnetometer; although there are several variations of this device. Fundamentally, the sensor is an inductor that is driven in and out of saturation. The geometry is chosen so that an external field, assumed to be constant, adds to an excitation field such that an induced voltage can be related to the external field. This is the most general statement possible, and not very informative, but will be made clear by example. Suppose a toroidal core is driven (excited) as in Figure[8]. The resulting flux densities will be in opposite directions at opposite points along the core. With no external field, the flux densities are equal and opposite at points crossed by the sense winding so they in effect cancel each other. Now suppose a constant external field is a present. If it is added to both points, the resulting flux density is no longer equal and opposite. The result is a signal in the sense winding, which is wound around the outside of the toroid (the green wire in Figure[8]).
Top View

Bexternal

B1
Sense Winding

Bexcite B2

Drive Winding

Figure 8: Example of a Fluxgate Sensor showing eternal and excitation fields at two opposite points on the toroid.

The resulting waveform is dominated by the 2nd harmonic since the core saturates once per half cycle. One method of measuring the signal is to use a band-pass filter to extract this harmonic and then a phase sensitive circuit[5]. Other types of circuits involve using the element in a vibrator circuit, peak detection, and pulse position fluxgates[5]. This paper will develop pulse position type more thoroughly with simulation and detailed construction notes of a prototype. Certain aspects of the pulse-position type fluxgate make it very useful for integration into digital systems. First, the sensor is driven by a square-wave drive voltage (typically). Secondly, the discriminator for external field strength is the time between pulses created when the unit goes into saturation. Others have referred to this action as flux gating[5]. Since the measurement method is reduced to timing events, this is ideal for digital systems. The resulting current waveform is triangular when the core behaves linearly (not saturated).

When it reaches saturation in either direction voltage spikes occur in the sense winding since each half of the core will not enter saturation at the same instant.

3.1) Linearization of BH Curves: Since this operation relies on saturation, the concept of inductance will be avoided for the following derivation. A common approach is to model the BH curve with a linear model [6],[7]. The optimum choice for a core is one that has a sharp transition between saturated and non-saturated conditions. With this property, the resulting linear model is further simplified. For example, in Figure[9] the simplest model is shown and it is not unreasonable to find magnetic materials with these characteristics. As an example, such materials are used in saturable inductors.
B Bmax Bsat B Line 4 -Hsat -H Line 1 -B -Bsat -Bmax H Line 2 Hsat H Line 3

Figure 9: Linear Model of a BH curve for a material with high permeability.

Based on Figure[9] a linear model can be developed using the usual point-slope form y=mx+b, where m is the slope and b is computed from known points on the line. The results are shown in Equations[20-23] for B as a function of H for any value on that line. Note that the subscript p refers to the primed value for H and B. = =

= ( ( )= ( )+

= ( )=

( ( )+ =

) (

= ( )=

( ( )+

= ( )=

( ( )+

3.2) Field Intensity due to Drive Voltage: To use the linear model for the BH curve several derivations must be made prior. Assuming that the pulse position fluxgate is driven from a square-wave voltage, the flux levels will rise and fall in ramp-like fashion. With voltage constant over each half cycle, the flux can be calculated by Equation[24]. = ( )

Since the flux density(B) is dependent on and the area of the material, using Equation[25] yields the B as a function of time. Since the ultimate goal is to determine induced voltage in the sense winding, the flux density will be calculated for two points opposite each other on the toroid, referring to Figure[8] where B1 and B2 are flux attributed to each half of the core. = = ( )

Next the linear BH model can be used to find the associated field intensity, H1 and H2, for each half of the core. To determine the induced voltage, the external field intensity must be related to the field intensity inside the core at points one and two. The resultant field intensities will be summed together. 3.3) Field Intensity due to External Field: To approximate field inside the core due to the presence of a constant external field, the classical approach[4] shall be taken given by Equations[26] and [27]. Equation[28] and [29] show the calculation with reference to Figure[10]. The components of H (normal and tangential) can be calculated by determining H0n as a function of and distance(x), then integrating from point -a to 0. = ( ) = ( )
H 0 n = H 0 * cos( ) x' cos( ) = R
and

Top View

H0n

H0t

H0
-a

y'

R x' 0 r

0
H 0t = H 0 * sin( ) and sin( ) = y' R

H1

Figure 10: Variables used to estimate the internal field Intensity due to the presence of an external field using relationships at the interface (Equation[26] and [27]).

= = = 2

= =

= 2

sin ( )

=0

To improve accuracy several correction factors have been developed to improve modeling results with respect to actual performance in literature [6], [7]. The correction factors are based on modeling the geometry of the system. It was pointed out in [7] that a solution to magnetostatic potential problem of a long rod (a toroid is an infinite solenoid) the resulting excitation is too small to agree with actual results. No attempt will be made to add to the theory of modeling correction factors, suffice to say that information may be obtained from references. In summary, it is common and plausible to calibrate a measurement scale based on actual results. The Earths magnetic field for given geographical regions has been documented/collected in reference tables over many years. If this data is in terms of flux densities it can be related to field intensity by the permeability of air. If the axis of the external field is not as shown in Figure[10] a transformation is required to obtain the components along the axis shown. A similar method can be used as in Equation[14] using Figure[4] to transform between two separate Cartesian systems. 3.4) Sense Winding Output: Faradays Law dictates the output of the sense winding. Given how the sense winding is wound (Figure[8]) recall that with no external field applied the change in flux is zero due to the equal and opposite values. However in the case of an external field being added to both values, the sum of each of the changing flux densities will no longer be zero. A simple modification to Faradays law is shown in Equation[30] will allow us to calculate the output based on Equation[25] where the flux density was calculated as a function of time.

( )=

( )=

10

10

To evaluate Equation[30], expressions are needed for B1 and B2 which takes into account the external field. In [6] this is shown elegantly as follows where H(t) is the perturbation of the field intensity due to the external field. Note that since the device transitions from one permeability in the linear model to the other, the permeability is a function of time. Lastly, substitution of Equation[31] and [32] yields a more useful equation for the sense winding output (Equation[33]). = ( )+ ( ) ( ) ( ) = ( )+ ( ) 10 () ( )

( )=

( )

( )

Due to the time dependence and the dynamic nature of the permeability, a numerical approach will be used to demonstrate these derivations using Matlab.

3.5) Matlab Simulation: To construct the simulation, a core with a hysteresis curve similar to the linear model was chosen, namely Magnetics Inc #ZJ43813TC. Information on this core can be found in Appendix B and a linear model was created using Equations[20-23] from the datasheet. A low drive frequency of 2.5 KHz was chosen. The device was designed for application to a field sensing unit for geophysics. Thus, portability is an important factor. The system is designed to use a 9V input since the most likely source would be a standard 9V battery in a handheld device. The core is rather large so a minimal number of turns are needed for actual construction. There are 12 windings total in the drive winding and 50 turns in the sense winding. Figure[11a] shows the drive voltage while [11b] additionally shows the flux in one half of the core. To traverse the BH curve symmetrically the first cycle has a duty cycle of 25% while all remaining cycles are 50%. Figure[12a] and [12b] show the field intensities with and without the presence of an external field respectively with respect to time. In [12b] the addition of the external field has the effect of shifting the values upwards. Each half, H1 and H2, are symmetric but opposite in directions.

(a)

(b)

Figure 11: Drive Voltage and Associated Flux in the Core

(a) (b) Figure 12: (a) Field Intensity(H) due only to drive voltage vs. time. (b) Field Intensity due to drive voltage AND External Field (He) vs. time. H1 and H2 each refer to half of the core.

Figure[13] shows the resulting BH curve using the linear model. The blue line traces outs a curve identical to the model with the given properties for the Magnetics Inc core. The green line shows the effect of adding an additional Field Intensity due to the presence of the external field. The effect is it traces out the same pattern but for more instances in time it occupies the positive saturated portion of the curve. This is further shown by noting that the blue trace extends further into negative saturation than the green trace.

Figure 13: BH Curve with no External Field (Blue) and with External Field (Green).

Next, Figure[14] shows the output voltage in the sense winding with several points of reference. The pulses correspond to the moments when the core half enters saturation. Since each half of the core does not enter saturation at the same instant, a signal appears at the sense winding. If there were no external field, the flux in each half would cancel the other half. When H1 enters positive saturation, H2 is approaching negative saturation and vice versa. Taking H1 as an example, this can be seen by comparing the top portion of the plot with the middle portion. The small impulse in the sense winding corresponds to H1 entering saturation. The lower half shows the pulse position (in time) for some other external flux densities. Figure[15] shows a plot of the time difference, or pulse position versus a range of values for an external field in terms of flux density. The complete code can be found in Appendix C. Note that Appendix C contains a published version of the M file in which the code and output appear together arranged in the standard Matlab publishing format.

Figure 14: (Top) Field Intensity in one half of core versus time. (Middle) Input and Output Voltages with the External B field, Be, equal to 500uT. (Bottom) Voltage Output at various external field densities. The time between pulses changes versus field intensity.

Figure 15: Relationship between pulse position (difference in time) and External Field Densities.

4.0) Fluxgate Design


Using the derivations and Matlab simulation from Section 3.0, a prototype unit was constructed. The circuit is considerably digital given that it uses the pulse position principle. The goal is to monitor output pulses from the sense winding and track the time between them. This can then be related to the external field using simulation results. A further step would be to find correction factors to improve accuracy such as the one proposed in [7] as previously mentioned. 4.1) Circuitry The circuit is driven by a square wave drive voltage which is derived from a pulse-width modulator (PWM) peripheral feature of the PIC16F88 microcontroller. The processor speed was 8MHz but the instruction cycle was only 4MHz. This limits the overall capability of the device but a future refinement in this area is certainly possible. This particular microcontroller can be clocked up to 20MHz. Nonetheless, this is interfaced via a FET driver IC which is equipped with a complimentary output. This way the coil can be driven actively high and low. Instead of using a P-channel Mosfet for high side drive, an Nchannel Mosfet is used with a bootstrap circuit for proper turn-on (D1, D2, and C4). In the final design, D3 was omitted. The circuit drives a custom wound inductor which consists of 12T @ 18AWG on the drive winding and 50T @ #30 AWG in the sense winding. The output (sense winding) is connected to an integrated instrumentation amplifier. The simulation suggests output voltages with amplitudes in the low millivolt range so some gain is required. The advantage of the integrated version of instrumentation amplifier is precisely trimmed component values, high speed operation, and low offset voltage ratings. It is critical that the detection circuit can differentiate between noise and actual signals. Since the inductor is switching reasonably high currents, substantial ringing can be observed. The output of the instrumentation amplifier is connected to a window comparator constructed from two high-speed comparator ICs. The window comparator provides the capability to measure whether or not an induced pulse is negative or positive by straddling the DC level output of the instrumentation amplifier. Since a single positive supply is used, this level is one half of Vcc. Note that Vcc was chosen to be 3.3V since the display requires this as well. This eliminates the need for additional circuitry. The outputs of the window comparator are applied to the built in comparators of the PIC16F88 which can be set up to operate on interrupts which start/stop timers within the microcontroller. To limit power consumption, the drive voltage is applied for a short time via a pushbutton interface. Results are designed to be displayed on a 2x16 transmissive character display LCD. The schematic is shown in Figure[16] while the PCB silkscreen is show in Figure[17]. A picture of the unit is shown in Figure[18] while additional information such as PIC16F88 code and a Bill of Materials is listed in Appendix D.

Figure 16: Schematic for a Pulse Position Magnetometer.

Figure 17: PCB for the Pulse Position Magnetometer.

Figure 18: Prototype Fluxgate (PCB Rev 7, Firmware Rev 8)

4.2) Firmware Block Diagram: The basic control and measurement flow can be seen in Figure[19]. This is the firmware block diagram for the pulse position magnetometer.
INITIALIZATION 1) Initialize Peripherals. 2) LCD Test Sequence. DISPLAY SPLASH 1) Send Splash Display via SPI interface to LCD.

IDLE 1) Wait for button press.

Button Pressed?

1) 2) 3) 4)

TEST Power Up Comparator Inputs, timer, and enable interrupts. Control Time Duration of Drive Signal. Record Time Interval in Buffer. Power Down Drive and Measure peripherals

COMPUTE 1) Check for Timer Overflow or failure to start Timer. (Error, Start /Stop signal not received) 2) Compute Field Intensity from measured Time Interval if valid.

Valid Result?

DISPLAY RESULT 1) Send result via SPI interface to LCD.

DISPLAY ERROR 1) Send Error message/ type via SPI interface to LCD.

Figure 19: PIC16F88 microcontroller firmware state chart.

4.3) Preliminary Results: Proof of Concept Prior to implementing the full circuit in Figure[16] the drive section and sensor were constructed and tested informally. To apply a strong external field a stack of common magnets was placed next to the actual sensor. By changing the number of magnets in the stack, a simple test of observing varying time differences was conducted. Figure[20] shows the magnet stack and associated time measurements made with an oscilloscope. The lower trace is the drive waveform while the upper trace is the sense winding output.

(A) Weak Stack

(B) Weak Stack Figure 20: Proof of Concept Test: Two unknown magnetic fields were placed in close proximity to the core. In (A) a weaker field was applied by estimated by the number of magnets. In (B) the magnet stack was increased. A corresponding time difference can be seen from the oscilloscope measurements.

4.4) Experimental Results Work is still being done to complete construction. PWM and high/low side drive signals are complete. Op amp and comparator circuits are biased properly and working. Currently, the firmware is still be completed, namely the portions of the code related to driving the display and verification of proper timing.

5.0) Conclusion
Magnetometers, namely fluxgate designs, have been developed and studied since the 1920s. Most of the theory used in this report comes from robust derivations from the 1950 through the 1970s. The sensitivities achieved in literature, which are thoroughly reported in (5), are remarkable given the circuits used and their relatively low cost. Later studies focused on improving accuracy namely by better models of the magnetic materials. More recent papers have focused on militarization. While many of these details are absent from this paper, the fundamental theory is presented in a practical and straightforward manner. Derivations were provided in a step-by-step manner with little detail spared. This paper focused on the proton-precession and fluxgate style magnetometers. In both cases theory was developed and simulated in Matlab. Simulations provided sufficient basis for prototype construction. In the case of the fluxgate, a prototype was constructed which represents a complete solution that can be implemented in a hand-held style device with reasonable capabilities. Future improvements that can be made to the fluxgate prototype are a reduction in overall size of the magnetic element, a faster microcontroller, and developing correction factors from more experimental testing. A review of simulated time differences for external fields ranging from 100uT to 1mT suggests that faster timing would achieve better resolution considering the speed of the microcontroller is 8MHz.

6.0) Acknowledgements
Thank you to Dr. Ida, University of Akron, for making this study possible. Magnetics Inc in Pittsburgh should be commended for the rapid and willing response to sample requests.

7.0) References:
[1] A.A. Kaufman, Robert L. Kleinberg, Richard Hansen, Principles of the Magnetic Methods in Geophysics, Elsevier 2009. [2] Acker, F.E., "Calculation of the Signal Voltage Induced in a Toroidal Proton-Precession Magnetometer Sensor," Geoscience Electronics, IEEE Transactions on , vol.9, no.2, pp.98-103, April 1971. [3] J.A. Koehler, Proton Precession Magnetometers, 2004, http://www.geotech1.com/cgibin/pages/common/index.pl?page=mag&file=/info/koehler/index.dat, Downloaded 8/16/2010. [4] N. Ida, Engineering Electromagnetics 2nd Ed, Springer, New York, 2003. [5] Gabor Vertesy, Encyclopedia of Sensors, Stevenson Ranch: American Scientific Publishers, 2006. pp. 367-395. Vol. 8., Pl R. [6] Burger, J., "The theoretical output of a ring core fluxgate sensor," Magnetics, IEEE Transactions on, vol.8, no.4, pp. 791- 796, Dec 1972. [7] Acuna, M.H.; Pellerin, C.J., "A Miniature Two-Axis Fluxgate Magnetometer," Geoscience Electronics, IEEE Transactions on, vol.7, no.4, pp.252-260, Oct. 1969. [8] S. Briener, Applications Manual for Portable Magnetometers, Geometrics, San Jose CA, 1999.

APPENDIX A: PPM Simulation


ANALYSIS OF PROTON PRECESSION MAGNETOMETER (PPM) ............................................................ 29 INPUT VECTORS FOR CALCULATION .................................................................................................. 29 CONSTANTS ...................................................................................................................................... 30 COORDINATE SYSTEM CONVERSIONS:............................................................................................... 30 NUMBER OF PROTONS: ..................................................................................................................... 31 POLARIZATION / MAGNETIZATION .................................................................................................... 31 BLOCH EQUATIONS: .......................................................................................................................... 32 SIGNALS: ........................................................................................................................................... 32

clear all

ANALYSIS OF PROTON PRECESSION MAGNETOMETER (PPM)


Date: By: For: 09/20/2010 Jeff Petermann 4400:693 Independent Study, Sensors and Instrumentation Dr. Ida, Fall 2010

The purpose of this simulation is to model operation of a PPM based on variations of the magnetic field to be measured with respect to magnitude, direction, and the resulting Larmour frequency of precession.

INPUT VECTORS FOR CALCULATION


To use this script for simulation enter the following desired information: 1) 2) 3) 4) B = Magnitude of Ambient Magnetic Field. [T]

Uvi = Unit vectors of directions under consideration. Enter Toroidal Sensor Parameters:

Ba

50*10^50*10^-6; [1,1,0];

% Magnitude of Ambient Field [T] % Directed Along X Axis.

Uv1 =

APPENDIX A: PPM Simulation


Uv2 = Uv3 = [0,1,1]; [1,0,1]; % Directed Along Y Axis. % Directed Along Z Axis.

R R1 R2 Ip Nt

= = = = =

.05; .04; .06; 1.2; 200;

% Average Radius of Torroid. [m] % Inner Radius of Torroid. % Outer Radius of Torroid. Current % Inductor Current [A] % Turns [#] [m] [m]

CONSTANTS
gr mp uo ur u %mp Xo = = = = = = = 267.513*10^6; 2.67512*10^8; 4*pi*10^4*pi*10^-7; .999; .999; uo*ur; 14.106067*10^14.106067*10^-27; -9.035*10^-6; 9.035*10^% Magnetic Moment of a Proton [J/T] % Magnetic Susceptibility of Water % Gryomagnetic ratio (Hydrogen) % Proton Magnetic Moment [J/T] % Permeability of Air % Relative Permeability

COORDINATE SYSTEM CONVERSIONS:


Uv's are unit vectors which are multiplied by the magnitude of the external field. directions. This yields example fields oriented in different

Phi and alpha are related to the transformation to

cylindrical coordinates within the core (See Bloch Equations in paper).

B1 B2 B3

= = =

Ba*Uv1; Ba*Uv2; Ba*Uv3;

% Example: % Example: % Example:

External in XY plane External in YZ plane External in XZ plane

phi1 phi2 phi3

= = =

atand(Uv1(2)/Uv1(1)); atand(Uv2(2)/Uv2(1)); atand(Uv3(2)/Uv3(1));

alpha1

atand((sqrt(Uv1(1)^2+Uv1(2)^2))/(Uv1(1)^2+Uv1(2)^2+Uv1(3)^2));

APPENDIX A: PPM Simulation


alpha2 alpha3 = = atand((sqrt(Uv2(1)^2+Uv2(2)^2))/(Uv2(1)^2+Uv2(2)^2+Uv2(3)^2)); atand((sqrt(Uv3(1)^2+Uv3(2)^2))/(Uv3(1)^2+Uv3(2)^2+Uv3(3)^2)); atand((sqrt(Uv3(1)^2+Uv3(2)^2))/(Uv3(1)^2+Uv3(2)^2+Uv3(3)^2));

wo_1 wo_2 wo_3

= = =

mp*Ba; mp*Ba; mp*Ba;

% Freq related to Mag Moment of proton.

NUMBER OF PROTONS:
Based on material, density, and quantities.

p d

= 2; = 997.0479;

% Two protons(H) in water molecule % Density of H20 at room temp [kg/m^3] % 2(H)+(O) = 2(1.0079)+(15.999) = 18[amu] % Number of Protons

wgt = 18; N (p*d)/(1.67*10^= (p*d)/(1.67*10^-27*wgt);

POLARIZATION / MAGNETIZATION
The ideal case for total mangetic moment would be N(protons) x mp (mag moment of one proton). However due to thermal noise not all protons

can be aligned, hence a fractional value shall be applied and it is assumed some portion are totally magnetized while another portion is not. For this simulation it is assumed that the geometry of the

magnetometer is based on a torroidal winding.

k T

= =

1.38*10^1.38*10^-23; 298.15;

% Boltzman Constant % Room Temp[K], @25C

% %

For torroids, as long as the average radius(R) is much bigger than the radius of the ring(r), Bp can be approximated by:

Bp Kp Mt

= = =

(u*N*Ip)/(2*pi*R); (mp*Bp)/(k*T); N*Kp;

% Flux Density of Polarization Signal [A/m] % Fraction of Ideal Magnetization(H) % Magnetization due to Polarizing Field

APPENDIX A: PPM Simulation


BLOCH EQUATIONS:
The following solution of the Bloch Equations yields the flux along the axis defined <u,v,w>. <u,v,w. is a cartesian system where w is

directed along the applied field, u is in a plane of constant z and parallel to the y axis (taken as -pi/2 in cylindrical coordinates), and v is orthogonal to both. Note the X axis that <u,v,w> will be related

to by Eularian angles is 0 degrees in cylindrical coordinates. (Appended to Coordinate Systems Section).

SIGNALS:
T2 t = = 2.1; [0:(T2/100):T2];

A B C1 C2 C3

= = = = =

-(u*Xo*Nt^2*Ip)/(2*pi); log(R2/R1); (1(1-sind(phi1)^2*sind(alpha1)^2); (1(1-sind(phi2)^2*sind(alpha2)^2); (1-sind(phi3)^2*sind(alpha3)^2); (1-

(A*B*C1).*exp(-t/T2).*((cosd(wo_1.*t)./T2)v1t = (A*B*C1).*exp(-t/T2).*((cosd(wo_1.*t)./T2)-(wo_1*sind(wo_1.*t))); (A*B*C2).*exp(-t/T2).*((cosd(wo_2.*t)./T2)v2t = (A*B*C2).*exp(-t/T2).*((cosd(wo_2.*t)./T2)-(wo_2*sind(wo_2.*t))); (A*B*C3).*exp(-t/T2).*((cosd(wo_3.*t)./T2) o_3.*t)./T2)v3t = (A*B*C3).*exp(-t/T2).*((cosd(wo_3.*t)./T2)-(wo_3*sind(wo_3.*t)));

v1tn = v1t./max(v1t); v2tn = v2t./max(v2t); v3tn = v3t./max(v3t);

plot(t,v1t,t,v2t,t,v3t) xlabel('Time'); ylabel('Voltage'); legend('With Bext in XY Plane','With Bext in YZ Plane',... 'With Bext in XZ Plane'); title('Simulated Outputs with External Field at Different Orientations');

APPENDIX A: PPM Simulation

APPENDIX B: MagInc Info

APPENDIX B: MagInc Info

APPENDIX B: MagInc Info

APPENDIX C: Fluxgate Simulation Code FLUXGATE SENSOR SIMULATION


By: Class: Inst: Jeff Petermann Sensors and Instrumentation (ST), Fall 2010 Dr. Ida

This simulation demonstrates the theory of a pulse position Fluxgate Sensor. It consists of two windings, one drive winding around a

toroidal core, Magnetics Inc #ZJ43813TC and one sensing winding that is wound around the outside of the toroid in between the drive windng. With no external field the voltage induced in the sensing winding is zero, but with a constant(assumed) external field a magnetic field is added to each half which eliminates the symmetry. the moment that each half enters saturation. A pulse results at

Traditional fluxgates

(non-pulse position) extracted 2nd Order harmonics and analyzed them to relate amplitude to field strength. Pulse Position fluxgates relate

the time between these pulses to field strengths.

ENTER SIMULATION CONSTANTS ...................................................................................................... 37 SPECIFIC CORE PARAMETERS ............................................................................................................ 38 BH CURVE APPROXIMATION ............................................................................................................. 38 BUILD DRIVE VOLTAGE ...................................................................................................................... 39 PHI .................................................................................................................................................... 39 MAGNETIC FLUX DENSITY ................................................................................................................. 40 MAGNETIC FIELD INTENSITY .............................................................................................................. 40 ADDITION OF EXTERNAL FIELD .......................................................................................................... 41 SIGNAL VOLTAGES (vst) ..................................................................................................................... 42 STORE RESULTING Vst FOR GIVEN He ................................................................................................ 43 TIMING ............................................................................................................................................. 43 PLOTTING.......................................................................................................................................... 44

ENTER SIMULATION CONSTANTS


N1 and N2 are half of the drive windings. In other words the total

APPENDIX C: Fluxgate Simulation Code


number of drive turns is the sum of these two values.
clear all L fiveL F T fiveT Vmax Vmin N1 N2 Ns t = 1000; = (5*L)+1; = 5e3; = (1/F); = 5*T; = 4.5; = -4.5; = 6; = 6; = 50; = [0:(T/L):fiveT];

SPECIFIC CORE PARAMETERS


%MagInc ZJ43813TC InR OutR A1 Bsat Bp Hsat Hp = = .01955; = .03925; = 114.2*(1/1000)^2; = .350; = .335; = 79.5; 47.7; %Amps/Meter % Meters % Meters; % MagInc ZJ43825TC = 231mm^2 % Teslas

BH CURVE APPROXIMATION
The following linear approximations use the above values to estimate the BH Curve: Line 3 __ Line 4 _/__/ Line 2 Line 1 For increased accuracy with this model, a core with high permeability is best. Hp and Bp refer to points points where the curve switches from usat to udiff. The model is constructed form basic point slope calcs.
(-Bp- Bsat))/(Hpm1 = (-Bp-(-Bsat))/(Hp-(-Hsat)); Bsat-(m1*(b1 = -Bsat-(m1*(-Hsat)); (Bsat- Bp))/(Hsatm2 = (Bsat-(-Bp))/(Hsat-Hp); Bsatb2 = Bsat-(m2*Hsat); (Bp-Bsat)/(-Hpm3 = (Bp-Bsat)/(-Hp-Hsat); Bsatb3 = Bsat-(m3*Hsat); (-Bsat-Bp)/(-Hsatm4 = (-Bsat-Bp)/(-Hsat-(-Hp)); (-Bsat)-(m4*(b4 = (-Bsat)-(m4*(-Hsat));

APPENDIX C: Fluxgate Simulation Code


BUILD DRIVE VOLTAGE
The drive voltage is a square wave. waveform for simulation.
for i=1:fiveL if i<(L/4) vt(i) = Vmax; elseif i>=(L/4) && i<L vt(i) = Vmin; elseif i>=L && i<(fiveL*(2/5)) vt(i) = Vmax; elseif i>=(fiveL*(2/5)) && i<(fiveL*(3/5)) vt(i) = Vmin; elseif i>=i<(fiveL*(3/5)) && i<(fiveL*(4/5)) vt(i) = Vmax; elseif i>=(fiveL*(4/5)) && i<fiveL vt(i) = Vmin; elseif i==fiveL vt(i) = Vmax; end end

The following constructs the

PHI
First, the flux must be calculated based on v=n*dphi/dt for the drive signal input above.
phi1 phi2

1 and 2 refer to flux in each half of the core.

fiveL= [0: fiveL-1]; fiveL= [0: fiveL-1];

for i=1:fiveL if i==1 phi1(i) = 0; else phi1(i((vt(i)*(t(i)-t(iphi1(i) = phi1(i-1) + ((vt(i)*(t(i)-t(i-1)))*(1/N1)); end end for i=1:fiveL %Assumes equal number of turns

phi2(i) = -phi1(i); end

APPENDIX C: Fluxgate Simulation Code


MAGNETIC FLUX DENSITY
Calculate the Flux Density(B) based upon the flux and the area of the core.
% Theoretical Values for B (not taking into account material) for i=1:fiveL B1(i,1) = (phi1(i)./A1); B2(i,1) = (phi2(i)./A1); end

MAGNETIC FIELD INTENSITY


With the flux density calculated, use the BH model to evaluate H.
for i = 1:fiveL if i == fiveL H1(iH1(i,1) = H1(i-1,1); H2(iH2(i,1) = H2(i-1,1); elseif B1(i+1,1) > B1(i,1) % Incresing B

if B1(i,1) <= -Bsat (B1(i,1)H1(i,1) = (B1(i,1)-b1)/m1; (B2(i,1)H2(i,1) = (B2(i,1)-b3)/m3; elseif B1(i,1) <= -Bp (B1(i,1)H1(i,1) = (B1(i,1)-b1)/m1; (B2(i,1)H2(i,1) = (B2(i,1)-b3)/m3; elseif B1(i,1) < Bsat (B1(i,1)H1(i,1) = (B1(i,1)-b2)/m2; (B2(i,1)H2(i,1) = (B2(i,1)-b4)/m4; else (B1(i,1)H1(i,1) = (B1(i,1)-b3)/m3; (B2(i,1)H2(i,1) = (B2(i,1)-b1)/m1; end else if B1(i,1) >= Bsat (B1(i,1)H1(i,1) = (B1(i,1)-b3)/m3; (B2(i,1)H2(i,1) = (B2(i,1)-b1)/m1; elseif B1(i,1) >= Bp (B1(i,1)H1(i,1) = (B1(i,1)-b3)/m3; (B2(i,1)H2(i,1) = (B2(i,1)-b1)/m1; elseif B1(i,1) > -Bsat % Line 3 % Line 1 % Line 3 % Line 1 % Line 3 % Line 1 % Line 2 % Line 4 % Line 1 % Line 3 % Line 1 % Line 3

APPENDIX C: Fluxgate Simulation Code


(B1(i,1)H1(i,1) = (B1(i,1)-b4)/m4; (B2(i,1)H2(i,1) = (B2(i,1)-b2)/m2; else (B1(i,1)H1(i,1) = (B1(i,1)-b1)/m1; (B2(i,1)H2(i,1) = (B2(i,1)-b3)/m3; end end end % Line 1 % Line 3 % Line 4 % Line 2

ADDITION OF EXTERNAL FIELD


Approximate the effects of an external field.
u0 u1 Be_air He_air He 4*pi*10^= 4*pi*10^-7; = 5000*u0; [50e-6:50e-6:1000e= [50e-6:50e-6:1000e-6]; = Be_air./u0; = (He_air*OutR)./(2*u1); % Perm free space % Perm inside core material. % Test Range of Flux Densities % between 50uT to 1mT. % Resulting H inside core

for j=1:length(He) %Add External Field for i=1:fiveL H1e(i,1) = H1(i,1)+He(1,j); H2e(i,1) = H2(i,1)+He(1,j); end %Calculate New B for i=1:fiveL if i == fiveL B1e(iB1e(i,1) = B1e(i-1,1); B2e(iB2e(i,1) = B2e(i-1,1); elseif H1e(i+1,1) > H1e(i,1) % Incresing B

if H1e(i,1) <= -Hsat m1*H1e(i,1)+b1; B1e(i,1) = m1*H1e(i,1)+b1; B2e(i,1) = m3*H2e(i,1)+b3; elseif H1e(i,1) <= Hp B1e(i,1) = m1*H1e(i,1)+b1; B2e(i,1) = m3*H2e(i,1)+b3; elseif H1e(i,1) < Hsat B1e(i,1) = m2*H1e(i,1)+b2; B2e(i,1) = m4*H2e(i,1)+b4; % Line 2 % Line 1 % Line 1 % Line 3

APPENDIX C: Fluxgate Simulation Code


else B1e(i,1) = m3*H1e(i,1)+b3; B2e(i,1) = m1*H2e(i,1)+b1; end else if H1e(i,1) >= Hsat B1e(i,1) = m3*H1e(i,1)+b3; B2e(i,1) = m1*H2e(i,1)+b1; elseif H1e(i,1) >= -Hp B1e(i,1) = m3*H1e(i,1)+b3; B2e(i,1) = m1*H2e(i,1)+b1; elseif H1e(i,1) > -Hsat B1e(i,1) = m4*H1e(i,1)+b4; B2e(i,1) = m2*H2e(i,1)+b2; else B1e(i,1) = m1*H1e(i,1)+b1; m3*H2e(i,1)+b3; B2e(i,1) = m3*H2e(i,1)+b3; end end end % Line 1 % Line 4 % Line 3 % Line 3 % Line 3

SIGNAL VOLTAGES (vst)


% Compute Change in flux with respect to time in each half. for i=1:fiveL if i==1 dB1dt(i,1) = 0; dB2dt(i,1) = 0; else (B1e(i,1)-B1e(i-1,1))/(t(1,i)-t(1,idB1dt(i,1) = (B1e(i,1)-B1e(i-1,1))/(t(1,i)-t(1,i-1)); (B2e(i,1)-B2e(i-1,1))/(t(1,i)-t(1,idB2dt(i,1) = (B2e(i,1)-B2e(i-1,1))/(t(1,i)-t(1,i-1)); end end % Use change in flux to calculate sensor output voltage. for i=1:fiveL (Ns/2)*A1*10^vst(i,1) = -(Ns/2)*A1*10^-8.*(dB1dt(i,1)+dB2dt(i,1)); end

APPENDIX C: Fluxgate Simulation Code


STORE RESULTING Vst FOR GIVEN He
These arrays hold values for all tested external fields.
vst_all(:,j) = vst(:,1); H1e(:,1); H1e_all(:,j) = H1e(:,1); H2e_all(:,j) = H2e(:,1); B1e_all(:,j) = B1e(:,1); B2e_all(:,j) = B2e(:,1); maxB1(:,j) maxB2(:,j) maxH1(:,j) maxH2(:,j) maxvst(:,j) end = max(B1e(:,1)); = max(B2e(:,1)); = max(H1e(:,1)); = max(H2e(:,1)); max(vst(:,1)); = max(vst(:,1));

TIMING
Calculate the time between induced pulses in the sensing winding.
Tmg_all(:,1) = Be_air(1,:); for j=1:length(Be_air) MaxMeas_plus = 0; MaxMeas_minus = 0; for i=L:(3*L) if vt(i) > 0 if vst_all(i,j) >= MaxMeas_plus MaxMeas_plus = vst_all(i,j); Tind(j,1) = i; end end if vt(i) <= 0 if vst_all(i,j) >= MaxMeas_minus MaxMeas_minus = vst_all(i,j); Tind(j,2) = i; end end end end for i=1:length(Tind) Tind(i,3) = (abs(Tind(i,1)-Tind(i,2)))*(T/L); (abs(Tind(i,1)-

APPENDIX C: Fluxgate Simulation Code


end

PLOTTING
figure(1) subplot(1,2,1) plot(t,vt) Voltage') xlabel('Time'); ylabel('Voltage'); title('Input Drive Voltage') subplot(1,2,2) plotyy(t,vt,t,phi1) xlabel('Time'); ylabel('Voltage'); legend('Drive V','Phi1'); (halftitle('Flux vs Drive Voltage (half-core)'); figure(2) subplot(1,2,1) plot(t,H1,t,H2) xlabel('Time'); ylabel ('H [A/m]'); legend('H1','H2','H1e','H2e'); title('H(each half) vs. Time'); subplot(1,2,2) plot(t,H1e,t,H2e) xlabel('Time'); ylabel ('H+dH [T]'); legend('H1+He','H2+He'); title('Total title('Total Field Intensity (each half, He=External) vs. Time'); figure(3) '---g') plot(H1,B1,H1e_all(:,10),B1e_all(:,10), '--g') xlabel('H [A/m]'); ylabel ('B [T]'); legend('BH No Ext. Field','BH W/ Ext. Field'); title('BH Curve w/ and w/o External Field'); figure(4) subplot(2,1,1) plot(t,H1e_all(:,1),t,H1e_all(:,5),t,H1e_all(:,20)) legend('H1, Be=50uT','H1, Be=250uT','H1, Be=1mT'); xlabel('Time'); ylabel('H'); title('Selected Field Strengths vs. Time'); subplot(2,1,2) plot(t,B1e_all(:,1), t,B1e_all(:,5), t,B1e_all(:,20) ); legend('B1, Be=50uT','B1, Be=250uT','B1, Be=1mT'); xlabel('Time'); ylabel('B'); title('Selected Flux Densities vs. Time')

APPENDIX C: Fluxgate Simulation Code


figure(5) subplot(3,1,1) plot(t,H1e_all(:,10)) plot(t,H1e_all(:,10)) xlabel('Time'); ylabel ('H1+dH [A/m]'); legend('H1+He for B External=500uT'); title('Total Field Intensity Inside the Core with Bext=500uT'); subplot(3,1,2) plotyy(t,vst_all(:,10), t,vt); legend('Vout with Be=500uT','Vin'); title('Vin and Vout vs. Time with an External Field of 500uT'); xlabel('Time'); ylabel('Voltage'); subplot(3,1,3) plot(t,vst_all(:,1),t,vst_all(:,5),t,vst_all(:,10),t,vst_all(:,3)) legend ('Be=50uT','Be=250uT','Be=500uT','Be=150uT'); title('Vout @ Hexternal'); xlabel('Time'); ylabel('Voltage'); figure(6) plot(Be_air,Tind(:,3)); xlabel('External Field (B)'); ylabel('Pulse Position: dTime'); Measurement title('Timing Measurement vs Ext Field Densities');

Warning: Ignoring extra legend entries.

APPENDIX C: Fluxgate Simulation Code

APPENDIX C: Fluxgate Simulation Code

APPENDIX C: Fluxgate Simulation Code

APPENDIX D: Additional PCB/Circuit Details

APPENDIX D: Additional PCB/Circuit Details


BOM: C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 D1 D2 D3 D4 D5 J Q1 Q2 R1 R2 R3 R4 R5 R6 R7 R8 R9 R10 R11 R12 R13 R14 R15 R16 R17 R18 R19 100nF, Metal Film, 63V 10uF 10uF 100nF , Metal Film, 63V 470uF 10uF 100nF, Metal Film, 63V 100nF, Metal Film, 63V 100nF, Ceramic, 50V 1uF, 50V, Electrolytic 1uF, 50V, Electrolytic 100nF, Metal Film, 63V .1uF .1uF 10nF, Metalized Polyester Film, 63V 1N4148, Small Signal Diode, 500mA, 100V 1N4148, Small Signal Diode, 500mA, 100V Not Used Not Implemented. Not Used For Debug FQI50N06, N-Channel FQI50N06, N-Channel 10K Ohms, 1/4W, 1% Resistor 10K Ohms, 1/4W, 1% Resistor 10K Ohms, 1/4W, 1% Resistor 10K Ohms, 1/4W, 1% Resistor 10K Ohms, 1/4W, 1% Resistor 4.7 Ohms, 1/4W, 5% Resistor 1 Ohm, 1/4W, 5% Resistor 10K Ohms, 1/4W, 1% Resistor Not Implemented Not Implemented Not Implemented 10K Ohms, 1/4W, 1% Resistor 10K Ohms, 1/4W, 1% Resistor 10K Ohms, 1/4W, 1% Resistor 10K Ohms, 1/4W, 1% Resistor 20K Ohms, Potentiometer, .5W 20K Ohms, Potentiometer, .5W 10K Ohms, 1/4W, 1% Resistor 10 Pin, 560 Ohm Resistor Network, Common Bus.

APPENDIX D: Additional PCB/Circuit Details


R20 R21 SW T1 U1 U2 U3 U4 U5 U6 10K Ohms, 1/4W, 1% Resistor 10K Ohms, 1/4W, 1% Resistor Push-Button Switch Custom LP2951, LDO Regulator, Onsemi, PDIP-8 UC3715, TI FET Driver with Complimentary Outputs, PDIP-8 IN126A, TI Instrumentation Amplifier, PDIP-8 TI714, TI High Speed Comparator, PDIP-8 TI714, TI High Speed Comparator, PDIP-8 PIC16F88, 8 bit Microcontroller, 8MHz, SPI, PWM, Comparators

APPENDIX E: PIC16F88 Firmware


/* Jeff Petermann 4400:693, Ida, Fall 2010 Firmware for Driving the Fluxgate Sensor Compiler: HiTech for Pic Micro 12/16 Midrange */ #include<stdio.h> #include<stdlib.h> #include <htc.h> #include <hitech.h> #include <pic16f87.h> //USEFUL MACROS #define SetBit(x,y) (x|=(1<<y)) //Set pos y of reg x. #define ClrBit(x,y) (x&=~(1<<y)) #define ToggleBit(x,y) (x^=(1<<y)) #define FlipBit(x,y) (x^=(1<<y)) // Same as ToggleBit. #define TestBit(x,y) (x&(1<<y)) #define __delay_5uS(T) ( _delay(T*3)) #define __delay_mS(T) {int i; for (i=0 ;i<(2*T) ;i++) _delay(975);} //CONSTANTS __CONFIG(CCPRB0 & UNPROTECT & WDTDIS & INTIO & DEBUGDIS & MCLRDIS & BORDIS); #define PERIOD 49 //(Period+1)*4*Tosc*Pscale #define DUTY 100 //D=(CCPR1L:CCP1CON<5:4>)*Tosc*Psc #define DUTY_25 50 //Define State Variables #define IDLE 0 #define TEST 1 #define MEASURE 2 #define OUTPUT 3 #define DONE 4 #define BUTCHCK 5 //Define Other Parameters and Globals #define RB6ON 6 #define SCALE 333 #define SCALE2 20 #define CS 4 #define MS_1 134 #define FET_EN 6 #define CUTOFF 768 #define C1OUT_H 7 #define C2OUT_L 6 volatile char state; volatile unsigned int start; volatile unsigned int stop; int tx_packet[15];

//Chip Select RA4(Pin3)

//Delay after Enabling FET Driver //For testing RA0 (high pulse) //For testing RA1 (low pulse) //Start Time for Measurement //Stop Time for Measurement //SPI Transmit Buffer

int setup_dev(void){

APPENDIX E: PIC16F88 Firmware


//********** General and Special ****************** OPTION = 0b11010011; //PullUps disabled. Tmr0 source //is Fosc/4, not used as counter. //Prescaler assigned to Tmr0, 1:16. TRISA = 0b11101111; TRISB = 0b11111110; OSCCON = 0b01111110; ANSEL = 0b00000000; //Input=1, Output=0 //PWM Pin on RB0

//*************** Setup Timers *********************** /* Timer0 set up with Option register, 1:2, 8b, INT enablTed on overflow, must clear flag in software */ T1CON = 0b10000000; //Pscale=1:1, Initially off. T2CON = 0b00000011; //Prescale=1:16, Postscale=1:1, //Initially Off. //*************** Interrupts *********************** INTCON = 0b00000000; //Global interrupt,enable PIE1 = 0b00000000; // //*************** PWM CONFIG *********************** SetBit(TRISB,0); //Disable PWM Out. PR2 = 49; //P=[PR2+1]*4*Tosc CCPR1L = 25; //D=(CCPR1L:CCP1CON<5:4>)*Tosc CCP1CON = 0b00001111; //PWM Mode ClrBit(TRISB,0); //Enable PWM Out //SetBit(T2CON,2); //Enable Timer2 //*************** COMP CONFIG *********************** CMCON = 0b00000011; //Two inputs, V+ tied to Vref. CVRCON = 0b11101111; //Vref=2.0625V, Output on RA2.

}//ENd Setup Device int test_button(char button){ int hit, result,i; hit, result,i = 0; for(i=0; i<12; i++){ TMR0IF = 0; while(TMR0IF==0){ //wait } if(TestBit(PORTB,button)){ hit = hit+1; if(hit >= 2){ result = 1; } } } return result;

APPENDIX E: PIC16F88 Firmware


} //End TestButton int set_PWM(unsigned int period, unsigned int duty){ char low, high; high = (duty & 0b11111100)>>2; low = (duty & 0b00000011)<<4; PR2 = period; CCPR1L = high; CCP1CON = CCP1CON | low; if(!TestBit(T2CON,2)){ SetBit(T2CON,2); } } //End PWM Set int init_SPI(void){ //TRISB = ; SSPCON = 0x32; SSPSTAT = 0x80; SSPOV = 0; SSPIF = 0; } // End int send_packet(unsigned int x){ //Send 'x' byte of tx_packet to the serial port unsigned int ix; int temp; _delay(5); for (ix=0; ix<x;ix++){ SSPBUF = tx_packet[ix]; while(!BF); temp = SSPBUF; __delay_5uS(1); }

//If PWM disabled by way of T2, start up.

//Master, 125KHz, CKP=1 //Master

//Delay 5 cycles

//Delay 5uS

_delay(5); } // End Send Packet int set_contrast(unsigned int value){ tx_packet[0] = 0xFE; tx_packet[1] = 0x52; tx_packet[2] = value; send_packet(3); } //End Contrast Setup int set_backlight(unsigned int value){ tx_packet[0] = 0xFE; tx_packet[1] = 0x53; tx_packet[2] = value;

//Delay 5 cycles

//Contrast Value 1-50

//Backlight Value 1-15;

APPENDIX E: PIC16F88 Firmware


send_packet(3); tx_packet[1] = 0x48; send_packet(2); //__delay_mS(1000); //ms_Delay(1000); } // End Function int set_cursor(unsigned int value){ tx_packet[0] = 0xFE; tx_packet[1] = 0x45; tx_packet[2] = value; send_packet(3); __delay_mS(10); //ms_Delay(10); } // End Function int clear_line(unsigned int x){ unsigned ij; for(ij=0; ij<x; ij++){ tx_packet[ij] = 0x20; } send_packet(x); } // End Function int lcd_clear(void){ tx_packet[0] = 0xFE; tx_packet[1] = 0x51; send_packet(2); __delay_mS(10); //ms_Delay(10); } // End //Turn Off Underline Cursor

//

void main(){ // STATE: INITIALIZE //int tx_packet[15]; //unsigned int splash[15]= {52,45,41,44,59}; unsigned int i; unsigned int result; unsigned int tval; unsigned char iserror; start = 0; stop = 0; result = 0; iserror = 0; i = 0; tval=0;

//"READY"

APPENDIX E: PIC16F88 Firmware


di(); state = IDLE; setup_dev(); // **SPI Setup** init_SPI(); set_contrast(25); set_backlight(10); lcd_clear(); //************** ClrBit(INTCON,0); while(1){ switch(state){ case IDLE: if(result==0){ tx_packet[0] = 52; send_packet(5); } SetBit(INTCON,3); //state = TEST;

//Clear Flag, RBIF

//STATE: SPLASH DISPLAY

//Enable button //Debug

//State Machine advances to TEST from Interrupt. break;

case TEST: ClrBit(TRISA,FET_EN); //RA6 enabled as output pin _delay(5); //Wait before enabling. SetBit(PORTA,FET_EN); //Enable FET Driver set_PWM(PERIOD, DUTY_25); //First cycle is 25% set_PWM(PERIOD, DUTY); //After that 50%. SetBit(T1CON,0); //Start Timer1 (16 bit) // ************* SKIP FIRST CYCLE ****************** while(tval <= CUTOFF){ tval = TMR1H; //Skip first cycle. //800 cycles = 1 period } // ********* RUN 32.7mS, RECORD RESULT ************* ClrBit(PIR1,0); //Clear Tmr1 flag. SetBit(PIE2, 6); //Enable comaparator Interruprs while(TMR1IF==0){ //Tmr1 overflows @ 500nS x 2^16 /* The Timing Measurement is handled in the interrupt routine for the Comparators. */ } ClrBit(PIR1,0); //Clear Tmr1 flag.

APPENDIX E: PIC16F88 Firmware


ClrBit(T1CON,0); ClrBit(T2CON,2); ClrBit(PORTA,FET_EN); state = MEASURE; break; case MEASURE: if(stop > start){ result = stop - start; } else iserror = 1; result = 64; state = OUTPUT; break; case OUTPUT: lcd_clear(); if(iserror){ tx_packet[] = 'ERROR'; send_packet(5); } else{ itoa(tx_packet,result,10); send_packet(5); } state = DONE; break; //debug //Disable Tmr 1. //Disable Timer2 and PWM //Disable FET Driver

case DONE: SetBit(INTCON,3); state = IDLE; break; case BUTCHCK: ClrBit(INTCON,3); if(test_button(RB6ON)){ state = TEST; } else{ state = DONE; } break;

//Enable RB# Interrupt

//Switch Debounce //Disable interrupt(button)

default: state = IDLE; break; }//End Switch

APPENDIX E: PIC16F88 Firmware


}//End Endless Loop }// End Main

void interrupt isr(void){ unsigned char temp; temp=0; //Push Button Detect if(RBIE && RBIF){ state = BUTCHCK; TestBit(PORTB,RB6ON); ClrBit(INTCON,0); //Clear Flag, RBIF }//End If, PORTB IOC //Comparator Check if(CMIE && CMIF){ if(!TestBit(CMCON,C1OUT_H) && start == 0 ){ start = TMR1H; start = start << 8; start = start | TMR1L; } if(!TestBit(CMCON,C1OUT_H) && (start!=0) ){ stop = TMR1H; stop = stop << 8; stop = stop | TMR1L; } ClrBit(PIR2,6); //Clear Interrupt Flag } }//End Interrupt Routine

You might also like