Paper Rv5
Paper Rv5
Paper Rv5
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.
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
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)
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)
| |
(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
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 ( )
= (
) 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
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.
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
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)
(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.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.
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 ERROR 1) Send Error message/ type via SPI interface to LCD.
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.
(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.
clear all
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.
Uvi = Unit vectors of directions under consideration. Enter Toroidal Sensor Parameters:
Ba
50*10^50*10^-6; [1,1,0];
Uv1 =
R R1 R2 Ip Nt
= = = = =
% 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
B1 B2 B3
= = =
= = =
alpha1
atand((sqrt(Uv1(1)^2+Uv1(2)^2))/(Uv1(1)^2+Uv1(2)^2+Uv1(3)^2));
= = =
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
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
k T
= =
1.38*10^1.38*10^-23; 298.15;
% %
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
= = =
% Flux Density of Polarization Signal [A/m] % Fraction of Ideal Magnetization(H) % Magnetization due to Polarizing Field
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
SIGNALS:
T2 t = = 2.1; [0:(T2/100):T2];
A B C1 C2 C3
= = = = =
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');
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
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
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));
PHI
First, the flux must be calculated based on v=n*dphi/dt for the drive signal input above.
phi1 phi2
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
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
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
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)-
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')
//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){
//*************** 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;
//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
//
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"
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.
case DONE: SetBit(INTCON,3); state = IDLE; break; case BUTCHCK: ClrBit(INTCON,3); if(test_button(RB6ON)){ state = TEST; } else{ state = DONE; } break;
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