Compass Thesis 2010

download Compass Thesis 2010

of 102

Transcript of Compass Thesis 2010

  • 8/8/2019 Compass Thesis 2010

    1/102

    Development of an Electronic Compass

    1

    Development of an Electronic Compass

    Presented by

    Ting Song

    A Thesis Submitted

    In Total Fulfillment of the Requirements forThe Degree of

    Master of Engineering in Electrical Engineering and

    Information Technology

    Department of Electrical Engineering and Information Technology,

    Faculty of Electrical Engineering, Production Engineering and Information Technology

    University of Applied Science Rosenheim

    Rosenheim, February, 2006

  • 8/8/2019 Compass Thesis 2010

    2/102

    Development of an Electronic Compass

    2

    TABLE OF CONTENTS

    1 SYSTEM DESCRIPTION............................................................................................................................. 4

    1.1 OVERVIEW OF THE SYSTEM ........................................................................................................................ 41.2 GENERAL INTRODUCTION ABOUT THE SIGNAL GENERATION ...................................................................... 61.3 SENSOR MODEL.......................................................................................................................................... 71.4 HOW TO OPERATE AND SWITCH SENSORS ................................................................................................... 81.5 LOW PASS FILTER AND GAIN ADJUSTMENT................................................................................................. 91.6 SYNCHRONOUS RECTIFIER......................................................................................................................... 91.7 INTEGRAL CONTROLLER........................................................................................................................... 101.8 U/I CONVERTER....................................................................................................................................... 121.9 DC ZERO_BIAS GENERATION ................................................................................................................... 131.10 DC-DC CONVERTER AND INVERTER...................................................................................................... 14

    2. MATHEMATICS PART........................................................................................................................... 15

    2.1 TASK OF THE MATHEMATICS PART ........................................................................................................... 152.2 GENERAL INTRODUCTION ABOUT EARTH MAGNETIC FIELD...................................................................... 172.3 COORDINATE TRANSFORMATION ............................................................................................................. 17

    2.3.1 Changing the heading angle ........................................................................................................ 182.3.2 Changing the pitch angle ............................................................................................................... 192.3.3 Changing the roll angle.................................................................................................................. 20

    2.4 CALCULATE Z COMPONENT WITH MAGNITUDE........................................................................................ 21

    2.5 CALCULATE PITCH ANGLE AND ROLL ANGLE USING AN ACCELEROMETER......................................... 222.6 CALCULATE HEADING ANGLE .................................................................................................................. 232.7 PROBLEM: THE SIGN OF THE HZ3 .............................................................................................................. 24

    3 HARDWARE DESCRIPTION .................................................................................................................. 27

    3.1 DC-DC CONVERTER................................................................................................................................ 27

    3.2 DC-DC INVERTER.................................................................................................................................... 283.3 TILT MEASUREMENT (ACCELEROMETER PART)........................................................................................ 29

    3.3.1 Introduction of the tilt sensor ......................................................................................................... 293.3.2 Circuit description.......................................................................................................................... 29

    3.4 SIGNAL GENERATION ............................................................................................................................... 303.4.1 Clock signal generation.................................................................................................................. 303.4.2 Switch signal generation ................................................................................................................ 313.4.3 Sinusoidal signal generation .......................................................................................................... 333.4.3.1 The Fourier Transform of the 50% duty cycle signal.................................................................. 333.4.3.2 Design the low pass filter .......................................................................................................... 333.4.3.3 Design the voltage divider. ........................................................................................................ 363.4.3.4 All pass filter network and amplification for the sinusoidal signal ........................................... 37

    3.5 SENSOR MODEL........................................................................................................................................ 393.5.1 The material and the structure of sensors ...................................................................................... 393.5.2 Sensor output signal ....................................................................................................................... 39

    3.6 SENSOR ACTIVATION ............................................................................................................................... 403.6.1 Switch signal to active one sensor at a time................................................................................... 403.6.2 Switch the sensor output signal ...................................................................................................... 42

    3.7 LOW PASS FILTER AND NON-INVERTING AMPLIFIER FOR THE SENSOR OUTPUT SIGNAL............................. 423.8 SYNCHRONOUS RECTIFIER....................................................................................................................... 43

    3.8.1 The function of synchronous rectifier............................................................................................. 433.8.2 Mathematical description of the synchronous rectifier .................................................................. 443.8.3 How to realize the function by hardware? ..................................................................................... 46

    3.9 INTEGRAL CONTROLLER........................................................................................................................... 473.9.1 Controller activation signal switch ................................................................................................ 473.9.2 Design the integral controller ........................................................................................................ 48

    3.10 U/I CONVERTER..................................................................................................................................... 483.11 DC ZERO_BIAS GENERATION ................................................................................................................. 503.12 MICROCONTROLLER PART ..................................................................................................................... 51

  • 8/8/2019 Compass Thesis 2010

    3/102

    Development of an Electronic Compass

    3

    3.13 LAYOUT DESCRIPTION............................................................................................................................ 533.14 CONNECTOR PIN DESCRIPTION ............................................................................................................... 56

    3.14.1 Connector between the microcontroller board and Sensor board ............................................... 563.14.2 Connector between Sensor board and Oscillation board............................................................. 56

    4 SOFTWARE PART..................................................................................................................................... 59

    4.1 THE MAIN PROGRAM ................................................................................................................................ 594.2 MICROCONTROLLERINITIATION .............................................................................................................. 614.3 DISPLAY INITIATION ................................................................................................................................ 634.4 FUNCTION: ACCELEROMETER_CALIBRATION ........................................................................................... 654.5 FUNCTION: START_CONDITION ................................................................................................................ 674.6 FUNCTION: VERTICAL_CHECK.................................................................................................................. 684.7 FUNCTION: A_CALCULATION ................................................................................................................... 694.8 FUNCTION: WAIT...................................................................................................................................... 704.9 FUNCTION: MAGNITUDE_MEASUREMENT ................................................................................................. 714.10 FUNCTION: HEADING_CALCULATION..................................................................................................... 754.11 FUNCTION:ADC_READING ................................................................................................................... 784.12 FUNCTION: CONVERT ............................................................................................................................. 794.13 FUNCTION:WRITE_STRING.................................................................................................................. 80

    5. TEST DOCUMENTATION...................................................................................................................... 82

    5.1 TESTING FOR THE DC-DC CONVERTER AND INVERTER............................................................................ 825.2 TESTING FOR THE DC-DC CONVERTER AND INVERTER ON THE FINAL PCB............................................. 835.3 TESTING FOR THE TILT MEASUREMENT CIRCUIT....................................................................................... 845.4 TESTING THE OSCILLATOR PART .............................................................................................................. 845.5 CALIBRATION FOR THE ACCELEROMETER................................................................................................ 855.6 CALIBRATION FOR THE MAGNETIC FIELD DETECTOR CIRCUIT OUTPUTS ................................................... 865.7 TESTING THE HORIZONTAL DEVIATION WITH ACCELEROMETER SUPPLY VOLTAGE CORRECTION AFTEREVERY 10 TIMES OF THE HEADING CALCULATION.............................................................................................. 86

    5.8 TESTING THE DEVIATION WITH 40,30,20,10 PITCH ....................................................................... 88

    APPENDIX SOURCE CODE ..................................................................................................................... 89

  • 8/8/2019 Compass Thesis 2010

    4/102

    Development of an Electronic Compass

    4

    1 System description

    1.1 Overview of the system

    This new electronic compass is based on the old one made in Operational Amplifier lab course

    2004 in University of Applied Sciences in Rosenheim. The improvements are included:

    A new software programming A new layout design A new design for +5V and 5V power supply A new housing

    The target of the thesis is to make electronic compass that can display the heading angle with

    respect to geographic north when its pitch range is 45,roll range is 15. The oldelectronic compass only can be used in the horizontal position. This new function is mainly

    realized by software. The layout is another part of work in order to minimize the size. One of

    the disadvantages of the old electronic compass is the power supply. The +5V and 5V that are

    generated by a DC-DC converter and inverter is too noisy. In the software, we have to calculate

    the average over 128 samples. It needs much time. To redesign the DC-DC converter and

    inverter is also the task of this thesis.

    The function of the electronic system is to display the direction of the electronic compass with

    respect to geographic north.The angle between the magnetic and geographical meridians is

    expressed as the magnetic declination. It is about 1.8 degree in Rosenheim. So if we get thedirection of the magnetic north, the geographic north can be easily calculated.

    In order to calculate the direction of the electronic compass with respect to magnetic north, we

    need the value of the components of the earth's magnetic field in two perpendicular directions,

    i.e. we need two sensors. However, the sensors are not closed magnetic loops without leakage

    flux. If they are mounted not to far apart (the electronic compass shall be small in order to use

    it) one sensor will influence the other, if both are operated simultaneously and at the same

    frequency. Experience shows, that the deviations arising from the mutual influence of one

    sensor on the other lead to non-tolerable errors. /Mayr 2003/ So there are two possibilities:

    both sensors are operated at different frequencies or only one sensor is operated at a time

    The latter method has the additional advantage, that the operating current is lower. However,

    operating only one sensor at one time will make the entire system more complicated. Digital

    control signals have to be generated in order to switch from one sensor to the other.

    If one uses a relaxation oscillator (with the LMC 555 CMOS universal timer), it can be used to

    generate the control signals as well as two other signals

    the sinusoidal signal with frequency0

    f by the use of a low pass filter and

    the digital signal with frequency 02f with exactly 50% duty cycle for the synchronousrectifier ( mixer) /Mayr 2003/

    http://geotools.haifa.ac.il/index.php?fflag=SHOW_TERM&lang=eng&id=136http://geotools.haifa.ac.il/index.php?fflag=SHOW_TERM&lang=eng&id=136
  • 8/8/2019 Compass Thesis 2010

    5/102

    Development of an Electronic Compass

    5

    Two magnetic field controllers exist in the magnetic detector circuit. The controller generates

    an zero_bias current, so that the static magnetic field component of the earths magnetic field is

    exactly compensated. So the output of the controller can be used to measure the magnetic earth

    field along the sensor axis.

    The system block diagram is shown in figure 1.

    Figure 1: System block diagram of electronic electronic compass /Mayr 2003/

  • 8/8/2019 Compass Thesis 2010

    6/102

    Development of an Electronic Compass

    6

    1.2 General introduction about the signal generation

    This part is the general introduction about signal generation. In this system, we need to

    generate the sensor switch signal, the synchronous rectifier switch signal, the integral

    controller control signal and the sensor operation signal.

    The block diagram of the signal generation is shown in Figure 2.

    Figure 2: The block diagram of signal generation part

    A signal with frequency 4f0 with 6364Hz is generated from LMC555 timer circuit. A trimm

    resistor can adjust this frequency. In order to get an exact 50% duty cycle signal, the frequency

    of the LMC555 output signal is first reduced by a counter (MM74HC393) by a factor of two to

    get 02f . This signal is used to control the synchronous rectifier for the extraction of the

    second harmonic. In order to operate the sensors, the frequency of this signal is reduced by

    factor of two again to get 0f . By a 4th order low pass filter, a low THD sinusoidal signal is

    generated for sensor excitation. The following all pass filter is used to adjust the phase of the

    sensor excitation signal, so that it fits to the phase of the synchronous rectifier.

    With the counter, the frequency is reduced to 4/0f . This signal is used to be the CLK of a D

    flip flop. Then the frequency is reduced by a factor of 16 that is 64/0f by the 2nd 4 bit counter.

    This signal from the counter with frequency 64/0f is the sensor switch signal. It controls,

    that only one sensor active at a time. After a D flip flop, the input signal with frequency

    64/0f is delayed by a clock pulse. Then, the two signals with same frequency 64/0f are

    used as inputs to a NOR and an AND gate in order to generate the controller activation signals.(The AND gate is realized by three NOR gates is our design, because they are already there in

    the chip. See chapter 3.4.2 in detail)

  • 8/8/2019 Compass Thesis 2010

    7/102

    Development of an Electronic Compass

    7

    1.3 Sensor model

    Figure 3: The structure of the sensor

    The structure of the sensor is shown in figure 3. There are two coils around the ceramic tube.

    One is the excitation coil for sinusoidal current input. Another one is the signal coil to output

    the signal.

    The sensors are made by soft magnetic materials, which are very nonlinear. So, there is a non

    linear dependence of the magnetic flux density B within the soft magnetic material and the

    magnetic field H that is described in the famous hysteresis loop. Because of the hysteresis loop,the actual magnetic flux density does not only depend on the current magnetic field H, but also

    on the entire history of H. For this feature, the magnetic field controller is used in the system.

    This part will be introduced in 1.7 integral controller. /Mayr 2003/

    Another of fact of nonlinearity is generating of harmonics. If a linear system is excited by a

    purely sinusoidal signal, the output signal of this system will also be purely sinusoidal with the

    frequency of the input signal. There will be no harmonics. But if the system is nonlinear,

    harmonics will be generated. The output signal will contain additional frequency with 2f0, 3f0,

    4f0.nf0, n=2,3,. /Mayr 2003/

    The sensor is excited by sinusoidal current signal with frequency 0f . With the theory above,

    the output voltage signal contains the base sinusoidal voltage signal with frequency 0f and its

    harmonics.

    For the pure sinusoidal magnetic field, the hysteresis loop will run through symmetrically and

    B(t+T/2)=-B(t). If the magnetic field H gets a DC component, i.e. the component of the earths

    magnetic field in sensor direction, then B(t+T/2) -B(t). This means, that now there will be afrequency component with for example 2f0 in the output signal. Experiments show, that the

    second harmonic (frequency 2f0) is the even harmonic with the highest level. So the amplitude

    of the second harmonic (frequency 2f0) is the best suited for use as quantity to measure

    magnetic field. /Mayr 2003/

  • 8/8/2019 Compass Thesis 2010

    8/102

    Development of an Electronic Compass

    8

    1.4 How to operate and switch sensors

    In order to avoid any influence between two sensors, only one sensor is operated at a time. We

    use a multiplexer to realize this function.

    The function diagram of sensor switching is shown in figure 4. The input of the switch is the

    sinusoidal signal. The 50% duty cycle square signal with frequency 25Hz controls the switch.

    The diagram of switching the sensors is shown in figure 5. When the switch control signal is

    high, the sinusoidal signal is used as the input to the E/W sensor. The sensor E/W sensor is

    active. However, when the switch control signal is low, the N/S sensor is active.

    Figure 4: The function diagram of sensor switching

    1591Hz_sine

    Sensor switch sensor N/S active

    control signal sensor E/W active

    E/W sensor

    switch control

    signal

    N/S sensorswitch control

    signal

    Figure 5: The diagram of switching sensor

    The outputs from the sensors have to be combined to one signal since the following part of the

    electronic circuit only exists once. In one period, the combined signal is the output from E/W

    sensor in the half of the time. For another half of the time it is the output from N/S sensor. The

    principle diagram of the sensor output signal switching is shown in figure 6. The signals from

    two sensors are the inputs of the switch. In the time that sensor N/S is active and sensor switchcontrol signal is low, the output is the signal from sensor N/S. However, in the time that sensor

    E/W is active and sensor control switch signal is high, outputs is the signal from sensor E/W.

  • 8/8/2019 Compass Thesis 2010

    9/102

    Development of an Electronic Compass

    9

    Sensor switch control signal with frequency 25Hz

    Output

    Figure 6: The principle of sensor output signal switching

    1.5 Low pass filter and gain adjustment

    This part consists of a low pass filter and a gain adjustment for the sensor output signal. The

    output of the sensors contains harmonics. We use the low pass filter to attenuate the harmonics

    of the sensor output signal with frequencies higher than 02f because they would also

    generate a DC-output at the synchronous rectifier.

    We use an operational amplifier IC OPA4743 to realize the low pass filter. The following part

    after the low pass filter is a gain adjustment, which is a non-inverting amplifier circuit. The

    amplitude is amplified by a factor of 3.2. It is also realized by OPA4743.

    1.6 Synchronous rectifier

    In order to measure the amplitude of the 2nd harmonic, the signal output from the gain

    adjustment is used as input to a synchronous rectifier. It extracts the second harmonic

    (frequency 0f ) of the input signal.

    The principle of this part is showed in figure 7. The synchronous rectifier consists of a voltage

    inverter and a multiplexer. The inverter is realized by an operational amplifier. The U in is the

    input for synchronous rectifier. It is a combined of the base signal with frequency 0f and itsharmonics. The switch control signal is U_2F. It is a square signal with frequency 02f . The

    value of the output of this synchronous rectifier depends on the component of the magnetic

    field in sensor direction. The switch function is realized by an analog multiplexer, 75HC4053.

    Signal from

    E/W sensor

    Signal from

    N/S sensor

    Switch

    Signal

    U_2F

  • 8/8/2019 Compass Thesis 2010

    10/102

    Development of an Electronic Compass

    10

    Figure 7: The principle of synchronous rectifier

    1.7 Integral controller

    The rectified signal is used for an integral controller to measure the magnetic field.

    First, I want to introduce the generation of the switch signal to activate and deactivate the

    integral controller. The switch signal that is used to control the switching from one sensor to

    another is very slow. It is generated at the very end of the signal generation part. There is aproblem for the following integral controller. The transient behaviour of the low pass filter and

    gain adjustment during the switching process will disturb the controller. In order to neglect this

    switching transient behaviour, we have to generate two additional signals that activate the

    controller a certain time after the switching over. This part is done in the end of the signal

    generating part. /Mary 2003/ The principle of generating the switch signal to control the

    integral controller is shown figure 8.

    With the two 4 bit counters, we get the square signal with frequency 64/0f that called signal

    A. It is used as input to a D flip flop to get signal B. B has one clock time delay compared with

    A. Then signals A and B are used as inputs to a AND gates to generate the controller signals,

    UZ_E/W and UZ_N/S.

    BASNUZ

    BAWEUZ

    /_

    /_(from chapter 3.4.2)

    UinInverter

    amplifierUout

    Synchronous

    rectifier

  • 8/8/2019 Compass Thesis 2010

    11/102

    Development of an Electronic Compass

    11

    Figure 8: The principle of generating switch signal to control the integral controller.

    There are several reasons that we prefer an integral controller as the analogue controller. They

    are expressed clearly in the lecture of Op Amp circuit design by Prof.Mayr.

    The excitation frequency to excite the coil is about 1590 Hz that is f0 / 4. So the time, for which

    a single controller is active (hereafter referred to as the active time in contrast to the inactive

    time), is

    msHzf

    tactive 1.20256/6360

    1

    2

    1

    256/

    1

    2

    1

    0

    .

    If one would like to have longer active times, he would have to use an additional counter.

    However, note that both sensors have to be operated in order to get the angle with respect to

    magnetic north. The active time for a single sensor cant become too long, otherwise the time

    for a reaction of the electronic compass display will become very long (i.e. seconds), which

    will be very inconvenient.

    The controller cannot be made very fast. The reason is the following. The input signal for the

    controller is not a "DC voltage", i.e. a very slowly changing signal, but the switched output

    signal of the sensor coil after notch filtering, amplification and phase shifting. The

    synchronous rectifier acts like a mixer: the local oscillator frequency is 02 f , the input signal

    from the sensor contains components with frequencies ...,8,4,2, 0000 ffff So the lowest

    components in the output signal of the "mixer" will be a DC part (from the 02 f component)

    and 0f (from the 0f component of the sensor signal mixed with the local oscillator

    frequency 02 f ). Many higher frequency components will also be generated.

    CLK

    D input of Dflip flop

    Output Q of

    D flip flop

    UZ_E/W

    UZ_N/S

    Controller E/W

    active

    Controller E/W

    inactive

    Controller N/S

    inactive Controller N/Sactive

  • 8/8/2019 Compass Thesis 2010

    12/102

    Development of an Electronic Compass

    12

    The output of the controller should be a very slowly changing signal, which is proportional to

    the component of the earth's magnetic field in the direction of the sensor. In a fixed position,

    the controller output signal would ideally be a pure DC voltage. However, the controller is a

    linear system with a specific frequency response. So the non-DC frequency components have

    to be attenuated by the controller to a sufficiently small level.

    This means, that during one active time, the controller will not be able to settle to its final

    value. It must remain in the state, which is reached at the end of the active time during its

    inactive time and then begin again at the state, which has been reached at the end of the former

    active time. The only controller with this behaviour is the integral controller: If the input

    during the inactive time is identically zero (in our case zero input current!), the output will not

    change. So an integral controller will be best suited for our purposes. Another advantage of the

    integral controller is the fact, that there will not be any static control deviation. /Mayr 2003/

    The principle of integral controller is shown in figure 9.

    Figure 9: The principle of integral controller

    The output voltage can be calculated as follows:

    t

    inout tVdttuRC

    tV0

    )0(')'(1

    )(

    )0( tV is the initial output voltageRC1 is the integral gain

    1.8 U/I converter

    This part is to convert the sum of the excitation voltage from sensors and the controller outputvoltage to a current. There are three voltage inputs of this converter. They are the sinusoid

    sensor switch signal, the controller output voltage and the zero_bias compensation voltage.

    The principle of U/I converter is shown in figure 10.

  • 8/8/2019 Compass Thesis 2010

    13/102

    Development of an Electronic Compass

    13

    Figure 10: The principle of the U/I converter

    If 11* RR , 22* RR , and 33* RR ,

    then we can calculate the output current.

    *** 3

    3

    2

    2

    1

    1

    R

    U

    R

    U

    R

    UIout

    1.9 DC zero_bias generation

    In order to be used as input to the ADC of the microcontroller, the signal has to be between 0V

    to the reference voltage of microcontroller, which is 2.5V. The controller output contains

    positive and negative voltages. So the VREF from the microcontroller that about 2.5V is used to

    generate the DC zero_bias voltage. The principle of DC zero_bias generation is shown in

    figure 11.

    Figure 11: The principle of DC zero_bias generation.

  • 8/8/2019 Compass Thesis 2010

    14/102

    Development of an Electronic Compass

    14

    1.10 DC-DC converter and inverter

    The DC-DC converter and inverter are not included in the system diagram. They generate the

    +5V and 5V power supply for the whole system. We use the MAX1706 to be the DC-DC

    converter. The noise of the +5V output is much lower than the old electronic compass. It has amaximum value of +3mV and minimum value of 3mV.

    The DC-DC inverter is realized by MAX1853. It generates the negative output about 5V.

    Literature

    /Mayr 2003/ Mayr Wolfgang,Lecture in Operational Amplifier circuit design 2,

    University of Applied Sciences Rosenheim

    Winter 2003/04

  • 8/8/2019 Compass Thesis 2010

    15/102

    Development of an Electronic Compass

    15

    2. Mathematics part

    2.1 Task of the mathematics part

    The aim of the mathematics part is to use the signals from the magnetic detector circuit and tilt

    measurement circuit to calculate the heading angle with respect to magnetic north.

    We use the definition of heading, pitch and roll for an airplane. Airplane convention defines

    the attitude parameters in terms of three angles: heading , pitch and roll (see figure

    12). These angles are referenced to the local horizontal plane. That is, the plane perpendicular

    to the earths gravitational vector. Heading is defined as the angle in the local horizontal plane

    measured clockwise from a true North (earth polar axis) direction. Pitch is defined as the

    angle between the aircrafts longitudinal axis and the local horizontal plane (positive for nose

    up). Roll is defined as the angle about the longitudinal axis between the local horizontal plane

    and the actual flight orientation (positive for right wing down). /Michael/ For the electronic

    compass, when looking at the display, it is like we watch the airplane from backward.

    Figure 12: Coordinate direction (X,Y,Z) and attitude orientation (roll, pitch) on an airplane.

    /Michael/

    Figure13: The heading angle .

  • 8/8/2019 Compass Thesis 2010

    16/102

    Development of an Electronic Compass

    16

    There are two perpendicular magnetic sensors fixed on the electronic compass. The directions

    of the sensors are X1 and Y1. The magnetic components we get from the circuit are in the

    sensor direction. The earth magnetic vector H

    is in the plane XZ. Assume that the electronic

    compass is horizontal, so the axes X, Y, X1 and Y1 are horizontal. There is a heading angle between the X axis and the sensor direction X1. This angle is what we want to know.

    In the case that the electronic compass is horizontal like in figure 13. It is very easy to calculate

    the heading angle .

    sin

    cos

    1

    1

    HxH

    HxH

    Y

    X(1)

    (HX1 is the earth magnetic component in X1 direction and HY1 is the magnetic component in

    Y1 direction. HX1 and HY1 can be measured by the sensors.)

    But if the electronic compass is not horizontal, the calculation is much more complicated. Wemust first calculate the magnetic value in the horizontal plane. And then calculate the heading

    angle with formula 5.

    Figure 14: The electronic compass is no more horizontal. Axes X1 and Y1 are

    perpendicular and in the horizontal plane. They have been the sensors directions before the

    electronic compass was tilt. Z1 is vertical to ground. X3 and Y3 are the actual sensors

    direction. Z3 is vertical to the X3Y3 plane.

    In figure 14, the electronic compass is not horizontal anymore. It has a roll angleand pitchangle. The output magnetic value HX3 and HY3 are in the directions X3 and Y3. In order to

    calculate the heading angle by formula 5, we need to transfer the HX3, HY3, HZ3 to thedirection X1, Y1 and Z1. So the main task of the mathematics part is to find this transformation

    and how to get the values of the variables in the transformation.

    X1

    X3

    Y1

    Y3

    Z1

    Z3

  • 8/8/2019 Compass Thesis 2010

    17/102

    Development of an Electronic Compass

    17

    2.2 General introduction about earth magnetic field.

    Figure 15: Magnetic field in the earth /Honeywell 2003/

    The earth magnetic vectors are shown in figure 15. The earth's magnetic field is about 0.6

    gauss in an open-air environment, and has a direction from the magnetic south pole to the

    magnetic north pole. This pointing to the north pole is the basis for magnetic electronic

    compassing. At the equator, the magnetic field direction is entirely a horizontal vector, but as

    the electronic compass is moved further into the northern or southern hemispheres, the

    magnetic field will point partially downwards (northern hemisphere) or upwards (southern

    hemisphere). This angle down or up at the earth's surface is called the inclination (dip) angle.

    /Honeywell 2003/

    city Berlin Dsseldorf Frankfurt Hamburg Mnchen

    inclination 67.6 68.8 65.6 66.9 63.9

    Table 1: The inclination of five city in Germany /Boll 1990/

    2.3 Coordinate transformation

    The sensors are fixed with respect to the electronic compass. So every time you move the

    electronic compass, the magnetic values are in different directions. The values that are not in

    horizontal plane are not suitable to be used directly to calculate the heading angle. It is

    necessary to transfer them to the direction that is horizontal.

    We assume that, the movement of the electronic compass is divided to three steps. The original

    directions of two sensors are X and Y. First, turn left or right that the electronic compass has a

    heading angle . The directions of sensors become X1 and Y1. The plane X1Y1 is horizontal.Second, move the electronic compass, so that has a pitch angle with respect to horizontal

    plane. The directions of sensors become X2 and Y2. Third step, turn up or down so that the

  • 8/8/2019 Compass Thesis 2010

    18/102

    Development of an Electronic Compass

    18

    electronic compass that has a roll angle . The directions of sensors become X3 and Y3.Finally, two magnetic components are in the directions X3 and Y3. So if we can transfer the

    magnetic components to the directions X1 and Y1, the heading angle can be easilycalculated.

    2.3.1 Changing the heading angle .

    Figure 16: The axis changes if electronic compass has a heading angle with respect to

    magnetic north. In the left diagram, the compass is seen from the back. In this case, 0 .The electronic compass is seen from top in the right diagram.

    The transformation of the coordinates when the electronic compass has a heading angle withrespect to the earth magnetic vector H

    is shown in figure 16. The directions of the sensors are

    X1 and Y1.

    In figure 16, the earth magnetic vector H is in the XZ plane, that we call it magnetic plane. The

    axis Z is vertical to ground. Magnetic vector H

    has its value HX, HY and HZ in XYZ

    coordinates. We initially 0YH , so that the X-axis points exactly towards magnetic north.Now, we assume the electronic compass is horizontal, but has a heading angle with respect to

    the magnetic north. The magnetic components Hx1 and Hy1 are in the directions X1 and Y1.

    The Z direction doesnt change. The magnetic vector expressions in XY coordinate and X1Y1

    coordinate are as follows:

    V

    H

    Z

    Y

    X

    H

    H

    H

    H

    H

    H 0

    (2)

  • 8/8/2019 Compass Thesis 2010

    19/102

    Development of an Electronic Compass

    19

    V

    H

    H

    Z

    Y

    X

    H

    H

    H

    H

    H

    H

    H

    sin

    cos

    1

    1

    1

    1

    (3)

    2.3.2 Changing the pitch angle

    Figure 17: In the left diagram, the compass is seen from the back. The X1Y1 plane is

    horizontal. The sensors are in the directions X1 and Y1 before the movement. After the

    movement, the sensors are in the directions X2 and Y2. The direction of the Y1 axis does notchange. The right diagram is seen from left.

    The electronic compass is not horizontal anymore after adding a pitch angle. It turns around the

    Y1 axis. The relation of the magnetic vectors value in two coordinates is shown below.

    1

    1

    1

    1

    1

    1

    2

    2

    2

    cos0sin

    010

    sin0cos

    Z

    Y

    X

    P

    Z

    Y

    X

    Z

    Y

    X

    H

    H

    H

    D

    H

    H

    H

    H

    H

    H

    (4)

    cos0sin

    010

    sin0cos1

    PD (5)

    Using1

    PD instead

    2

    2

    2

    1

    1

    1

    1

    Z

    Y

    X

    P

    Z

    Y

    X

    H

    H

    H

    D

    H

    H

    H

    (6)

    X1

    Y1

    Z2

    X2

    X1

    X2

    Z2

    Z1

    HZ1

    HX1

    Electronic

    compass

  • 8/8/2019 Compass Thesis 2010

    20/102

    Development of an Electronic Compass

    20

    2.3.3 Changing the roll angle

    Figure 18: In the left diagram, the compass is seen from the back. The sensors are in the

    directions X2 and Y2 when the roll 0 . After the movement, the directions of sensorschange to X3 and Y3. The direction of the X2 axis does not change in this case. The right

    diagram is seen from the back.

    The electronic compass is turned around the X2 axis and then the directions of sensors are Y3

    and Z3. The X2 direction does not change. So there is a roll angle between the Y2 and Y3

    axes. We can find out the relation of magnetic vectors value in two coordinates:

    2

    2

    2

    2

    2

    2

    3

    3

    3

    cossin0

    sincos0

    001

    Z

    Y

    X

    R

    Z

    Y

    X

    Z

    Y

    X

    H

    H

    H

    D

    H

    H

    H

    H

    H

    H

    (7)

    cossin0

    sincos0

    0011

    RD (8)

    Using1

    RD instead

    3

    3

    3

    1

    2

    2

    2

    Z

    Y

    X

    R

    Z

    Y

    X

    H

    H

    H

    D

    H

    H

    H

    (9)

    With the calculation above, we can easily get

    1

    1

    1

    3

    3

    3

    Z

    Y

    X

    RP

    Z

    Y

    X

    H

    H

    H

    DD

    H

    H

    H

    (10)

    Z3

    Y3

    Y2

    Y2

    Z3

    Z2

    X2Electroniccompass

    Y3HZ2

    HY2

  • 8/8/2019 Compass Thesis 2010

    21/102

    Development of an Electronic Compass

    21

    3

    3

    3

    11

    1

    1

    1

    Z

    Y

    X

    RP

    Z

    Y

    X

    H

    H

    H

    DD

    H

    H

    H

    (11)

    With equation 9 and 12, the 11 RP DD can be calculated as follows:

    coscossincossin

    sincos0

    cossinsinsincos

    cossin0

    sincos0

    001

    cos0sin

    010

    sin0cos11

    RP DD (12)

    3331

    331

    3331

    coscossincossin

    sincos

    cossinsinsincos

    ZYXZ

    ZYY

    ZYXX

    HHHH

    HHH

    HHHH

    (13)

    In the above formula, there are five variables. They are , , Hx3, Hy3 and Hz3. The Hx3 andHy3 we get from the magnetic detector circuit. So the next step is to calculate the unknown

    variables , and Hz3.

    2.4 Calculate Z component with magnitude.

    The magnitude is calculated with software. The electronic compass has two perpendicular

    direction sensors. The magnitude of magnetic vector is sensitivityant in any position. i.e.2222

    ZYX HHHH (14)

    XH and YH are the sensor direction. ZH is in the direction vertical to the electronic

    compass. So the ZH can now be calculated as:222

    YXZ HHHH

    In order to fix the sign, restrictions on the roll and pitch angle have to be made. (see chapter

    2.7)

    Figure 19: How to calculate the magnitude. The sensors are in the directions X and Y. Z

    axis is vertical to XY plane.

  • 8/8/2019 Compass Thesis 2010

    22/102

    Development of an Electronic Compass

    22

    In figure 19, when the electronic compass is horizontal, we can get the magnetic component in

    X and Y directions. Because the magnetic vector is downwards, the z component is

    sensitivityant and the x and y components are sinusoidal function in principle. If the electronic

    compass is vertical, the sensor direction X becomes vertical and Y is still horizontal. The

    magnetic value in X direction becomes sensitivityant and the components in the Y and Z

    direction are a sinusoidal function. The software calculates the 22 YX HH when theelectronic compass is turning around 360 degree. There must have the maximum value that

    equals to 2H , in which place the Z component is zero. In this case, the magnitude22

    XY HHH . In this way, we can get the magnitude H. Even, if the compass is not

    exactly turned down vertically during the rotation. There must be a position, where 0ZH ,because ZH is sometimes positive sometimes negative and continues. So it must go through

    zero.

    2.5 Calculate pitch angle and roll angle using anaccelerometer.

    The pitch and roll value we get from accelerometer ADXL203. It can be used as 2-axis tilt

    sensor with a roll axis and a pitch axis. The output signals AX and AY from the accelerometer

    is converted to an acceleration that varies between 1g and +1g.

    Figure 20: The gravity vector when the electronic compass has a pitch angle

    The accelerometer can detect the gravity vector in two directions: the direction in electronic

    compass plane and another direction vertical to the compass. These two directions are Hg

    and g in the figure.

    The gravity vector when the electronic compass only has a pitch angle is:

    g gravity field

    direction

    gH

    g

  • 8/8/2019 Compass Thesis 2010

    23/102

    Development of an Electronic Compass

    23

    cos

    sin

    gg

    ggH(15)

    If turn the electronic compass has a roll angle , the Hg doesnt change and g is calculated

    as follows: sincos gg /Analog 2004/

    So, the output signals of the accelerometer are:

    sincos_

    sin_

    gysensitivitbiaszeroAY

    gysensitivitbiaszeroAX

    The nominal sensitivity value is 1000mV/g if VVS 5 . The zero bias is the accelerometeroutput if it is horizontal, and it is 2.5V nominally.

    The allowed pitch and roll value is -45 +45 cos > 0-15 +15 cos > 0

    So

    2

    2

    sin1cos)cos/()_(sin

    sin1cos)/()_(sin

    gysensitivitbiaszeroAY

    gysensitivitbiaszeroAX(16)

    In this case, we can use the square root function to get the sine from the cosine.

    2.6 Calculate heading angle

    We now have all the value needed. With formula 17,

    3331

    331

    3331

    coscossincossin

    sincos

    cossinsinsincos

    ZYXZ

    ZYY

    ZYXX

    HHHH

    HHH

    HHHH

    With

    2sin1cos

    )/()_(sin

    gysensitivitbiaszeroAX

    2sin1cos

    )cos/()_(sin

    sensitivitbiaszeorAY

    2

    3

    2

    3

    2

    3 YXZ HHHH

    We can get the value of the magnetic components in horizontal.

    Because:

    sin

    cos

    1

    1

    HY

    HX

    HH

    HH

  • 8/8/2019 Compass Thesis 2010

    24/102

    Development of an Electronic Compass

    24

    So the heading angle is: 11 /cos/sintan XY HH 9090),/tan( 11 XY HHa

    We use the following formula to transfer the heading angle to 360~0 . The heading is thedegree we want to display. The is the angle we get from the arc tangent function.

    0.180heading if 01 XH

    0.360heading if 0,0 11 YX HH In other cases, heading

    The detailed explanation for the above transformation is in chapter 4.10.

    2.7 Problem: the sign of the HZ3

    Only the value HX3 and HY3 for H-measurement can be known directed from sensor that fixed

    on the electronic compass. The HZ3 can be calculated as follows:

    2

    3

    2

    3

    2

    3

    22

    3

    2

    3

    2

    3

    YXZ

    ZYX

    HHHH

    HHHH

    But in the calculation, HZ3 is considered positive. The allowed pith angle is 45, and theallowed roll angle is 15. So we must be sure that in the pitch angle range and the roll anglerange, HZ3 is positive all the time. The following two figures show the situation, when the

    electronic compass has largest pitch.

    Figure 21: HZ3 when the pitch angle is 45 .

    geog.North

    Worst negative pitchZ

    X

    H

    Hz3

  • 8/8/2019 Compass Thesis 2010

    25/102

    Development of an Electronic Compass

    25

    Figure 22: HZ3 when the pitch angle is 45 .

    So HZ3 should be positive even in the worst case. We checked the allowed value range when

    is 0~360 and is +15 and -15. The allowed range of the value means, for example,

    is 15 and =15 , in this range, HZ3 is positive all the time.

    The heading

    angle ()

    The allowed range of pitch

    angle when =15 ()The allowed range of pitch

    angle when = -15 ()

    0 >-65 () >-65 ()

    15 >-68 >-64

    30 >-72 >-6545 >-77 >-67

    60 >-83 >-71

    75 >-90 >-71

    90 -90

  • 8/8/2019 Compass Thesis 2010

    26/102

    Development of an Electronic Compass

    26

    We can see the minimum allowed value is period and larger than -45(the minimum value that

    the user will turn) whatever equals to any value. But when is -15 and is 0~30, the

    value is critical. So I decrease the distance to 2.

    () The allowed range of pitch

    angle when = -15 ()2 >-64.8 ()

    4 >-64.7

    6 >-64.5

    8 >-64.4

    10 >-64.3

    12 >-64.2

    14 >-64.1

    16 >-64.1

    18 >-64.1

    20 >-64.122 >-64.2

    24 >-64.3

    26 >-64.4

    28 >-64.6

    30 >-64.8

    Table 2: Checking the allowed value when is from 2to 30.

    From the above two tables, we can make sure that in the range -45 +45and -15 +15, value of HZ3 must be positive.

    Literature

    /Honeywell 2003/ www.ssec.honeywell.com

    Internet text and figure

    Honeywell International

    2003

    /Boll/ Boll Richard

    Weichmagnetische WerkstoffeVacuumschmelze GmbH

    Hanau, 1990

    /Michael/ Michael J. Caruso

    Application of Magnetic Sensor For Low Cost Compass System

    Honeywell, SSEC

    /Analog 2004/ Datasheet for the ADXL 203,

    Analog Devices, Inc.

    One Technology Way, P.O.Box.9106, Norwood, MA02062-9106, USA,2004

  • 8/8/2019 Compass Thesis 2010

    27/102

    Development of an Electronic Compass

    27

    3 Hardware description

    3.1 DC-DC converter

    The system needs +5V as the positive power supply. For the old electronic compass, the +5V

    power supply has strong ripples with +600mV for the maximum value and -400mV for the

    minimum value. The noise of the power supply causes ripples of the accelerometer outputs and

    also the magnetic circuit outputs that are input to the analog to digital converter (simply use

    ADC instead below) of the microcontroller. So in the software for the old electronic compass,

    the inputs for the ADC of the microcontroller are read 128 times and divided by 128 to get the

    average. That needs lot of time. This situation is improved in the new electronic compass. The

    maximum positive value is reduced to +3mV and the minimum negative value is -3mV.

    We use the MAX 1706 to generate the +5V from battery input. The allowed range of thebattery voltage is from 0.7V to 5.5V. The circuit diagram is shown in figure 23.

    Figure 23: The circuit diagram of the DC-DC converter.

    There are two main functions of the Max1706. One is a step-up converter with step-up output

    POUT. Another is a linear regulator with output LDO. The step-up converter generates an

    adjustable output to supply both power circuitry and the internal low-dropout linear regulator.

    The linear regulator steps down the output from the step-up converter and reduces switchingripples. The maximum output current is limited by the current available from the boost

    converter and by the voltage different between OUT and LDO. We use a 22uF capacitor C6

    with a low equivalent series resistance (ESR) at the output for low ripples. During power-up,

    the linear regulator remains off until the step-up converter goes into regulation for the first

    time. /MAXIM 97/

    The linear regulator is working in track mode. Connecting TRACK to the step-up converter

    output implements a tracking mode, that sets the step-up converter outputs to 300mV above the

    linear-regulator output, improving efficiency. In track mode, the feedback for the step-up

    converter is derived from the OUT pin. When TRACK is low, the step-up converter and linear

    regulator are separately controlled by their respective feedback inputs, FB and FBLCO.

    TRACK is a logic input with a 0.5Vout threshold, and should be hardwired or switched with a

  • 8/8/2019 Compass Thesis 2010

    28/102

    Development of an Electronic Compass

    28

    slew rate exceeding 1V/us. VLDO must be set above 2.3V for track mode to operate properly.

    /MAX IM 97/

    On power-up with TRACK=OUT, the step-up converter initially uses the FB input to regulates

    its output. After the step-up converter goes into regulation for the first time, the linear regulator

    turns on. When the linear regulator reaches 2.3V, track mode is enabled and the step-upconverter is regulated to 300mV above the linear regulator output. /3/

    To set the low-dropout linear-regulator output, we use a resistor voltage-divider connected to

    FBLDO from LDO to GND. We set the output to be 5.0V using the following formula:

    5554 31250.1

    0.51 R

    V

    VR

    V

    VRR

    FBLDO

    LDO

    , (17)

    where VFBLDO, the linear-regulator feedback input, is 1.250V. The above formula is from the

    datasheet of Max1706 by MAXIM. Since the input bias current into FBLDO is less than 50nA,and R4 can be a large value. We choose

    kR 4704 and kR 1505

    With the above values, the linear regulator output is:

    Vk

    kV

    R

    RVV FBLDOLDO 17.51

    150

    470250.11

    5

    4

    (18)

    The step-up converter output POUT is above the linear regulator by 300mV and is 5.47V.

    The inductor L2 with H330 is used to reduce the ripples to the value of mV3 as stated inchapter 3.1.1.

    3.2 DC-DC inverter

    We use the MAX1853 to realize the DC-DC inverter. It generates a negative output of

    inV1 . The circuit diagram is shown in figure 24. The input voltage is +5V. The output is

    5V. SHDN is driven to high for normal operation. The C1- ad C1+ is the negative and

    positive terminal of the flying capacitor C1. The value of C1 and output capacitor C2 isrecommended in the datasheet. R17 and C19 are used for filtering.

    Figure 24: The circuit diagram of the DC-DC inverter.

  • 8/8/2019 Compass Thesis 2010

    29/102

    Development of an Electronic Compass

    29

    3.3 Tilt measurement (Accelerometer part)

    3.3.1 Introduction of the tilt sensor

    The pitch and roll value are measured by the accelerometer ADXL203 that is used as a

    dual-axis tilt sensor. It uses the force of gravity as an input vector to determine the orientation

    of an object in space. When the accelerometer is oriented in such way that both its X axis and

    Y axis are initially parallel to the earth's surface, it can be used as a 2-axis tilt sensor with a roll

    axis and a pitch axis. Once the output signals from the accelerometer have been converted to an

    acceleration, that varies between -1g and +1g, the sine value of the pitch and roll angle are

    calculated as: (/Analog 2004/ and chapter 2.5 of this thesis)

    ))cos(()_()sin(

    )()_()sin(

    pitchgysensitivitbiaszeroAYroll

    gysensitivitbiaszeroAXpitch

    (19)

    The AX and AY are the accelerometer outputs from XOUT and YOUT. The zero bias is the

    accelerometer output, if it is horizontal.

    3.3.2 Circuit description

    Figure 25: Circuit diagram of the tilt measurement.

    The circuit diagram of this part is shown in figure 25. R2 and the capacitors C26 and C9 are

    used to decouple the ADXL203 from power supply noise, as recommended in the datasheet.

    The bandwidth of the accelerometer output is selected by capacitor C13 and C8. These two

    capacitors are added to implement low-pass filtering and noise reduction. The accelerometer

  • 8/8/2019 Compass Thesis 2010

    30/102

    Development of an Electronic Compass

    30

    has an internal filter resistor kRfilt 32 for outX and outY . So the bandwidth of output is

    calculated by:

    CRf

    filt

    dB

    2

    13 /Analog 2004/ (20)

    We choose the bandwidth to be 3.3Hz by using a 1.5uF filter capacitor. The Xout and Yout varyfrom 1.5V to 3.5V at -1g and +1g, respectively. Because the reference voltage of the

    microcontroller is 2.5V, the Xout and Yout have to be below 2.5V. The voltage dividers (R11

    and R10, R14 and R19 respectively) realize this function. So the range of the voltage, which isinput to the ADC of is reduced to value between 0.75V~1.75V. The voltage followers (IC3A,

    IC3B) after the voltage dividers are used as a buffer to eliminate loading effects.

    The outputs sensitivity varies proportionally to supply voltage. According to the datasheet of

    ADXL203, at VVS 5 , the sensitivity is gmV/1000 . At VVS 3 , it is gmV/560 . The

    zero g bias output is also ratiometric, so the zero g output is nominally equal to 2/S

    V at all

    supply voltages. In the software, after every 10 times of the heading calculation, the supply

    voltage of the accelerometer is read once to adjust the sensitivity, if necessary.

    Because the output of accelerometer is very sensitive with respect to the power supply voltage(see above), a power testing circuit is necessary. The reference voltage of the microcontroller is

    2.5V and the power testing signal has to be below 2.5V in order to be used as input to the ADC.

    The voltage at the supply power pin Vs of accelerometer is about 5.0V. It is divided by a factorof 2.79 by a voltage divider and then inputs to the ADC of microcontroller after a voltagefollower.

    3.4 Signal generation

    3.4.1 Clock signal generation

    The signal generation is divided to 3 parts: clock signal generation, switch signal generation

    and sinusoidal signal generation. We introduce the clock signal generation part first.

    Figure 26: The circuit diagram of the clock signal generation.

  • 8/8/2019 Compass Thesis 2010

    31/102

    Development of an Electronic Compass

    31

    The circuit diagram of the clock signal generation is shown in figure 26. The clock of thewhole system is generated by a 555 timer circuit. The frequency of the output is determined as

    follows:

    1924230 2

    43.1

    CRRRf

    trimm /National 2000/ (21)

    The trim resistor is used to adjust the output frequency, in order to get output signal with

    frequency 04f (the reason is explained in chapter 3.4.3.2). This frequency is determined by

    the operation frequency of the magnetic field detector circuit. The values of the components

    are set as follows: kR 5.123 , kR 1024 and nC 1019

    The trim resistor is kRtrimm 1 . By adjusting this resistor, the frequency of the output signal canbe set from 6651Hz to 6085Hz.

    3.4.2 Switch signal generation

    The second part is the switch signal generation. The circuit diagram is shown in figure 27.

    Figure 27: The circuit diagram of the switch signal generation.

    The clock signal generated by the timer 555 is the input to an 8 bit counter to generate 4 signals

    with frequency 02f , 0f , 4/0f and 64/0f . With the first counter, the signals withfrequency 02f , 0f , 4/0f are generated. The functions of these signals are follows: We

    require a 50% duty cycle signal. However, the output signal of the 555 is not a 50% duty cycle

    signal. So the frequency of the 555 circuit output signal is first reduced by a counter

    (MM74HC393) by a factor of two, which is 02 f (3183Hz). This signal is named U_2F. It is

    used in the synchronous rectifier part. The signal with frequency 0f (1591Hz) is used to

    generate the sinusoidal signal. The signal with frequency 4/0f is used to generate a delay

    between the sensor and controller activation. (see chapter 3.9.1)

    The signal with frequency 4/0

    f is also the input to the second counter to generate the signal

    with frequency 64/0f . This 50% duty cycle signal controls, that only one sensor is active at

    one time.

  • 8/8/2019 Compass Thesis 2010

    32/102

    Development of an Electronic Compass

    32

    The following part consists of a D-flip flop and NOR gates. The purpose of this part is to

    generate additional two switch signals with frequency 64/0f , that are needed for activating

    the controllers. These two signals are called UZ_N/S and UZ_E/W. The generation of thesignals UZ_N/S and UZ_E/W is described now.

    The 4/0f signal inputs to a D flip flop, that is also called delay flip flop. The delay flip-flop

    transfers whatever is at the input D to the output Q. This does not happen immediately, butonly happen on a rising clock pulse (i.e. as CLK goes from 0 to 1). The input is thus delayed by

    up to a clock pulse before appearing at the output. (see figure 28)

    Figure 28: Generation of the controller switching signals. /Mayr 2003/ When the signalUZ_E/W is high, the sensor E/W is active. When the signal UZ_N/S is high, the sensor N/S is

    active. From the above figure we can see, that only one sensor is activated at a time.

    The signals UZ_N/S and UZ_E/W are generated by 4 NOR gates. There are two input signals

    for the gates. One is the sensor switch signal (input of the D flip flop), another is the output of

    the D flip flop. Call the two inputs A and B for simplification. The expression of UZ_N/S andUZ_E/W are as follows:

    BABAWEUZ / _ (22)

    BABASNUZ /_

    The reason that to generate two such signals will be explained in detain in chapter 3.6.

    CLK

    Sensor

    switch signal

    Output Q of

    D flip flop

    UZ_E/W

    UZ_N/S

    Sensor E/W

    active

    Sensor N/S

    active

  • 8/8/2019 Compass Thesis 2010

    33/102

    Development of an Electronic Compass

    33

    3.4.3 Sinusoidal signal generation

    3.4.3.1 The Fourier Transform of the 50% duty cycle signal

    We use a 4th order low pass filter to generate a low THD sinusoidal voltage from a square

    signal. The THD of the sinusoidal output signal shall be less than 0.05%. This filter is realized

    by two 2 order Sallen & Key filters. The calculations below are from Theorie & Design eines

    Tiefpassfilter mit Q>1. /Andreas/

    Figure 29: 50% square input for the low pass filter.

    The input of the low pass filter is shown in figure 29. As a Fourier series we get

    1

    000 ))sin()cos((k

    kk tkbtkayy (23)

    With T

    k dttktyT

    a0

    0 )cos()(2 T

    k dttktyT

    b0

    0 )sin()(2 for ...5,3,1k (24)

    We getk

    Ubk

    04 for ...5,3,1k and 00 y , 0ka , 022 kk ba for ...6,4,2k

    So the amplitude of the partial waves in the signal is:

    00

    1 2732.14

    UU

    b

    (25a) 00

    2 4244.03

    4U

    Ub

    (25b)

    00

    3 2546.05

    4 UUb

    (25c) 00

    4 1819.074 UUb

    (25d)

    3.4.3.2 Design the low pass filter

    We use the Sallen & Key Filter to realize the function. The typical circuit of the Sallye & Key

    filter is shown in figure 30.

    U

    U0

    U0

    T

    t

  • 8/8/2019 Compass Thesis 2010

    34/102

    Development of an Electronic Compass

    34

    Figure 30: Salley & Key Filter

    We use the same value resistors and capacitors.

    kRRR 1021 and nFCCC 1021

    Figure 31: Simulation the logUout with PSPICE. The 1Q at the frequency Hzf 15910

    We can calculate the transfer functions )(1 jH , )(2 jH of the two equal Sallen & Key

    Filters.

    2

    0

    2

    0

    211

    1

    )()(

    Q

    j

    KjHjH (26)

    For the two filters 21 HHH

    The transfer function at RC10 of one Sallen & Key filter is for high Q

  • 8/8/2019 Compass Thesis 2010

    35/102

    Development of an Electronic Compass

    35

    QKHH )()( 0201

    So the transfer function at 0 of two equal Sallen & Key Filters is

    2

    02010 )()()()( QKHHH (27)

    The transfer function at 03 of two equal Sallen & Key Filters is

    2

    2

    2

    2

    2

    2

    2

    0

    2

    02

    2

    0

    2

    0

    2

    2

    0

    22

    2

    0

    2

    2

    02010

    9)8(9

    1)91(

    )3(1)

    )3(1(

    1)1(

    )3()3()3(

    Q

    K

    Q

    K

    Q

    K

    Q

    KHHH

    (33)

    The THD of the sinusoidal output shall be less than 0.05%. We get approximately

    0005.0

    ...

    ...

    1

    3

    2

    4

    2

    3

    2

    2

    2

    1

    2

    4

    2

    3

    2

    2

    u

    u

    UUUU

    UUU(28)

    1u and 3u are the amplitudes of the partial waves at 0 and 03 in the output.Their ration is

    )(

    )3(

    01

    03

    1

    3

    Hb

    Hb

    u

    u

    If we use formula 29, 32 and 33 to instead of 1b , 3b , )( 0H and )3( 0H , we get

    0005.0

    27192

    1

    3)964(

    1

    4

    3)964(

    4

    4

    964

    3

    4

    22

    0

    22

    2

    0

    22

    220

    2

    2

    0

    1

    3

    QQUKQ

    Q

    UQK

    KQU

    Q

    KU

    u

    u

    This is equal to 200027192 2 Q 276.102 Q 206.3Q

    For a Sallen & Key filters with CCRR 121 , , the Q- factor is given byk

    Q

    3

    1.

    So that we get 69.2206.3

    13

    13

    QK

    The value of K depends on the 3R and 4R ,4

    31R

    RK .

  • 8/8/2019 Compass Thesis 2010

    36/102

    Development of an Electronic Compass

    36

    It follows, that )1(43 KRR 43 69.1 RR

    We decide to use two resistors with following value:

    kR 1003 and kR 564

    The value of K then is: 786.256

    10011

    4

    3 k

    k

    R

    RK ,

    and the Q- factor of the filter is 67.4786.23

    1

    3

    1

    KQ

    This is sufficient, since it is only required, that 206.3Q .

    3.4.3.3 Design the voltage divider.

    The transfer factor of the entire low pass filter at 0 should be 1 . But according to theabove calculation, we have

    1301.1367.4786.2)()( 0201 QKHH

    So 16913)()()( 202010 HHH

    The operation amplifier would limit the output signal to not be sinusoidal any longer. So we

    need to add a voltage divider with the relation 13/1/' inin UU before the low pass filter. The

    circuit diagram of the voltage divider and low pass filter is shown in figure 32.

    Figure 32: The circuit diagram of the voltage divider and low pass filter. The equivalent

    resistance of the left two parallel resistors ( aR and bR ) is the output impedance of the

    equivalent circuit for the voltage divider.

    The R should be the same value as R1.

  • 8/8/2019 Compass Thesis 2010

    37/102

    Development of an Electronic Compass

    37

    k

    RR

    RRR

    ba

    ba 10' (29)

    Because 13/1/' inin UU , we get

    13

    1'

    ba

    b

    in

    in

    RR

    R

    U

    U kRb 10

    13

    12 kRb 833.10

    We use two resistors Rb1 and Rb2 to combine k833.10 .

    kRb 101 and 5602bR to get kRRR bbb 56.1021

    For aR we get: kRR ba 12012

    The final design of the two Sallen & Key filters with voltage dividers is shown in figure 33.

    Figure 33: Generation of the sinusoidal signal by two Sallen & Key Filters.

    3.4.3.4 All pass filter network and amplification for the sinusoidal signal

    Figure 34: The circuit diagram of the phase adjustment and amplitude amplifier.

    The circuit diagram of the phase adjustment stage and amplitude amplifier is shown above.

    The reason for using the phase adjustment is explained in chapter 3.8.

    The C19 and C13 are parellel connected. The equal capacitance C is:

  • 8/8/2019 Compass Thesis 2010

    38/102

    Development of an Electronic Compass

    38

    nCCC 101319 (30)

    The theory of the all pass filter network for phase adjustment shall be given now. /Mayr 2004/

    The voltage at the non inverting input is given by

    1

    1_

    1

    1_

    1

    1

    1

    1

    UCRj

    U

    CjR

    CjU

    TrimmTrimm

    (31)

    And the voltage drop at the feed back resistor is

    UU

    k

    UUk

    R

    UURIRUFB 1

    1

    27

    110110

    1010 (32)

    From a loop around the circuit we get 02 UUU FB

    Because the both inputs of an ideal Op Amp are at the same potential UU

    We get

    1

    1_

    1_

    1

    1_

    1_

    1

    1_

    1

    1_

    11

    1_

    2

    1

    1

    1

    12

    11

    2

    1

    1

    1

    1

    U

    CRj

    CRjU

    CRj

    CRj

    UCRj

    UCRj

    UUCRj

    UUU

    Trimm

    Trimm

    Trimm

    Trimm

    TrimmTrimmTrimm

    FB

    (33)

    The phase shift therefore is

    )arctan(2arctan20

    CRTrimm

    if we set CRTrimm 1_0 /1 (34)

    The circuit after the phase adjustment is an inverting amplifier. The capacitor C9 is to filter the

    DC zero_bias. The gain is given by:

    22_ RRK Trimm

  • 8/8/2019 Compass Thesis 2010

    39/102

    Development of an Electronic Compass

    39

    3.5 Sensor model

    3.5.1 The material and the structure of sensors

    Figure35: The photo of the magnetic sensor.

    The structure of the sensors has been shown in chapter 1.3. The sensors are made by a ceramic

    tube with a metallic glass in it. It contains two equal coils, made of 0.05, copper wire. The

    input of the excitation coil is a low THD sinusoidal current with frequency 0f . There are two

    sensors in the system. One in east, west direction is called sensor E/W. Another in north, south

    direction is called sensor N/S.

    3.5.2 Sensor output signal

    The metallic glass is magnetically very soft and non linear. This causes a non linear

    dependence of the magnetic flux density B within the soft magnetic material as function of the

    magnetic field H. There are two influence of the soft magnetic material. One is the actual

    magnetic flux density does not only depend on the current magnetic field H, but also on the

    entire history of H, which is described by the famous hysteresis loop. The second influence is

    the generation of harmonics. The output will contain additional frequency components with

    frequencies of ,...5,4,3,20 fn , if 0f is the input signal frequency.

    Figure 36: The output from the magnetic sensor and its Spectrum when there is static

    magnetic field. /Compass 2003/

  • 8/8/2019 Compass Thesis 2010

    40/102

    Development of an Electronic Compass

    40

    If there is static magnetic field component along the sensor axis, then there are harmonics with

    frequency ,...6,4,2 ooo fff (see figure 36). Otherwise, there are no harmonics (see figure 37).

    The integral controller in the magnetic detector circuit generates an zero_bias current to

    compensate the static magnetic field component of the earths magnetic field. So the output of

    the controller can be used to measure the magnetic earth field along the sensor axis. Thecriterion for compensation is, that the 02f frequency component vanishes. The 02f

    component is used, because it has the highest amplitude of the even harmonics.

    Figure 37: The output from the magnetic sensor and its Spectrum when there is no static

    magnetic field. /Compass 2003/

    3.6 Sensor activation

    3.6.1 Switch signal to active one sensor at a time

    Only one sensor is active at a time to avoid the influence of each other. This is realized by a

    switch between the sinusoidal sensor excitation signal and 0V. A multiplexer 74HC4053 isused to realize the switching function.

    74HC4053 are triple 2-channel analog multiplexers with a common enable input (E). Eachmultiplexer has two independent inputs (nY0 and nY1), a common output (nZ) and three

    switch control inputs (S1 to S3).

    With E low, the switches can be controlled by S1 to S3.

    With E HIGH, all switches are in the high impedance OFF-state, independent of S1 to S3.

  • 8/8/2019 Compass Thesis 2010

    41/102

    Development of an Electronic Compass

    41

    Inputs

    E nS Channel on

    L

    L

    H

    L

    H

    X

    nY0 nZ

    nY1 nZ

    none

    Table 3: The function table of 74HC4053 /PHILIPS/

    There are three channels used. The control inputs of three channels (S1 to S3) are the signal

    called sensor switch signal Uy.

    For channel one, the input 1Y0 is connected to GND and another input 1Y1 is connected to a

    sinusoidal signal with frequency 0f . When the sensor switch signal Uy is low, the output 1Z

    is GND. Otherwise; the 1Z is the sinusoidal signal. The output is used to active the E/W

    sensor.

    For channel two, the input 2Y0 is connected to the sinusoidal signal. Another input 2Y1 is

    GND. The situation in channel two is opposite to channel 1. When the sensor switch signal Uy

    is low, the output 2Z is the sinusoidal signal. Otherwise, it is GND. The output of channel two

    is used to active the N/S sensor.

    In channel three, the output signals from the two sensors are connected to the inputs 3Y0 and

    3Y1. So the output 3Z is always the output of the currently active sensor.

    1591Hz_sine

    Sensor switch sensor N/S active

    Signal Uy sensor E/W active

    About 25Hz

    The output of

    channel one,

    1Z

    The output of

    channel two,

    2Z

    Figure 38: Sensor activation switch signal.

  • 8/8/2019 Compass Thesis 2010

    42/102

    Development of an Electronic Compass

    42

    3.6.2 Switch the sensor output signal

    Since the switching behavior of the sensor input signal, the output of one sensor appears one

    half of every period, while the output of another sensor appears another half of the period. We

    need to switch two outputs to one signal, because the following low pass filter and gainadjustment exist only once. This function is also realized by the multiplexer 74HC4053. The

    principle diagram is shown in figure 39. The signals from E/W sensor and N/S sensor are

    mixed into one signal called sensor output signal.

    Sensor switch signal Uy

    Sensor output

    signal

    Figure 39: Sensor output switch

    3.7 Low pass filter and non-inverting amplifier for the sensor

    output signal

    The sensor output signal inputs to a low pass filter to attenuate the higher harmonics of thesensor output signal with frequencies higher than 02f . This improves the performance of the

    synchronous rectifier, where higher harmonics would also contribute to its output signal (see

    chapter 3.8)

    Since the filters Q- factor is 2, the frequency component with frequency

    0233887.4102

    1fHz

    knFf

    is amplified by a factor of 2 compared to a filter with

    an initially completely feat amplitude response like a Bufferworth type low pass filter.

    Figure 40: Circuit diagram of the low pass filter and non-inverting amplifier.

    Signal from E/W

    sensor

    Signal from

    N/S sensor

  • 8/8/2019 Compass Thesis 2010

    43/102

    Development of an Electronic Compass

    43

    After the low pass filter is a non-inverting amplifier. The amplitude is amplified by the

    following factor:

    2.318

    1813

    R

    RRK

    3.8 Synchronous rectifier

    3.8.1 The function of synchronous rectifier

    Because of the non linear behavior of the sensor material, the output from sensors is a

    combined of signals with many harmonics of the base signal. The base signal frequency

    depends on the sensor generation signal frequency that is 0f (1591Hz). So the output contains

    the sinusoidal signal with frequency 0f , 02 f , 04 f , 0nf , ...2,1n Experiments show that the

    second harmonic (frequency 02 f ) is the even harmonic with the highest level. So the

    amplitude of the second harmonic is the best suited for using as quantity to measure magnetic

    field. /Mayr 2003/

    H is not only necessary to measure the component of the 2nd harmonic at Hzf 159122 0 , butalso its phase. The controller, that generates the zero_bias current of the excitation coil must

    know, whether to increase or to decrease the zero_bias current in order to get zero amplitude of

    the 2nd harmonic. Fortunately, the second harmonic changes its phase by 180 , when thecomponent of the earth magnetic field along the sensor axis changes its direction. In a

    simplified figure that looks as follows:

    Figure 41: The synchronous rectifier

  • 8/8/2019 Compass Thesis 2010

    44/102

    Development of an Electronic Compass

    44

    3.8.2 Mathematical description of the synchronous rectifier

    The Uout is multiplied with Uin like in figure 42.

    Figure 42: The diagram of signal multiplexer.

    The synchronous rectifier acts like a mixer. The following calculation is from Synchronous

    rectifier by Milan. /Milan/

    ctrlinout nUU (35)

    The ctrln controls the switch, the zero_bias in inU is described by ctrls .

    We define the input signal as follows:

    ctrlctrl

    ctrlctrlctrl

    ininin

    nnt

    nnt

    tsn

    tUU

    2,1

    ,1

    )(

    )sin(

    (36)

    sctrl is a rectangular signal that can be described by Fourier transform.

    0 ))12sin((1214

    nctrlctrl tnns for ...3,2,1,0n (37)

    So we can get the description of Uout

    0

    ))12sin((12

    14)sin(

    n

    ctrlinin

    ctrlinout

    tnn

    tU

    UUU

    (38)

    outU is used as input to a integral controller. For its output mainly the DC- part of outU is

    important, called outU .

  • 8/8/2019 Compass Thesis 2010

    45/102

  • 8/8/2019 Compass Thesis 2010

    46/102

    Development of an Electronic Compass

    46

    For the second harmonic signal: ctrlin ,

    cos2

    inout UU

    The other harmonics can be neglected. The phase difference can be adjusted in the

    sinusoidal generation circuit part by the all pas filter network to get the maximum of cos .

    So, this output from synchronous rectifier is suited to input to an integral controller to calculate

    the history of the second harmonic.

    3.8.3 How to realize the function by hardware?

    The block diagram is shown in figure 43. The input signal Uin is a combined of the base signal

    of the sensor output (1591Hz sinusoidal signal) and the second harmonic. The Uin inputs to an

    inverting amplifier. The amplitude doesnt change. The switch between the Uin and its

    inverting signal is controlled by signal Uctrl, which is a square signal with frequency 3182Hz.

    Figure 43: The block diagram of synchronous rectifier.

    The switch function is realized by a multiplexer 74HC4053. The circuit diagram is shown in

    figure 44. In channel one, the Uin and its inverting signal Uin are connected to two individual

    inputs 1Y1 and 1Y0. The switch between Uin and Uin is controlled by Uctrl. The output of this

    channel is Uout.

    Figure 44: The circuit diagram of the switch.

  • 8/8/2019 Compass Thesis 2010

    47/102

    Development of an Electronic Compass

    47

    3.9 Integral controller

    3.9.1 Controller activation signal switch

    Because of the transient behavior of the low pass filter during the switching process, the

    controller will be disturbed. So two additional switch signals are needed to activate the integral

    controllerat a certain time after the switching over. How to generate these controller activation

    signals is described in 3.4.2 Switch signal generation.

    The two sensors output signals are mixed in one signal. The function of the switch is to pick up

    the signal from one sensor to input to certain integral controller. Like, pick up the part from

    E/W sensor and then input to the E/W integral controller. The principle diagram of this

    function is shown in figure 45.

    Figure 45: The principle of the controller activation signal switch

    Signal UZ_E/W and UZ_N/S control the switch behavior. The frequency is about 25Hz. When

    the signal UZ_E/W is high, the E/W integral controller is active. At this time, the signal

    UZ_N/S is low and the N/S integral controller output remains sensitivityant. And when the

    signal UZ_N/S is high, the N/S integral controller is active. At that time, the E/W integral

    controller output is sensitivityant.

    This switch function is realized by the multiplexer 74HC4053.

    Figure 46: The circuit diagram of the integral controller input signal switch.

  • 8/8/2019 Compass Thesis 2010

    48/102

    Development of an Electronic Compass

    48

    3.9.2 Design the integral controller

    Figure 47: Circuit diagram of the integral controller

    The reason to choose integral controller is in chapter 1.7. The controller integrates the input

    signal to produce the output signal. Integration is obtained by reversing the resistor and the

    capacitor. For an ideal operational amplifier, there is no current into or out of any input. Since

    the inverting input is at virtual ground, the current through R must flow to the capacitor C. Sothe output voltage is:

    t

    inoutout dttURC

    tUtU0

    ')'(1

    )0()( (44)

    TheRC

    1 is the gain that is -45.45 in our case.

    3.10 U/I converter

    Figure 48: Circuit diagram of U/I converter.

  • 8/8/2019 Compass Thesis 2010

    49/102

    Development of an Electronic Compass

    49

    The sensors are excited by a current through the excitation coil, so an U/I converter is needed.

    There are 3 inputs for the U/I converter. U1 is the controller output. It is a DC voltage. U2 is a

    sinusoidal voltage signal with frequency Hzf 15910 . In one period, this signal is active forabout 20ms and then becomes 0V for 20ms. This is controlled by the sensor switch signal

    which frequency is Hzf 85.2464/0 . This function is used to activate two sensors one byone. U3 is the zero_bias voltage. It is used for adjusting the controller output, to be symmetric

    with respect to ground.

    The relation between the non inverting input of the Op Amp and three input signals can be

    calculated as follows: /Milan 2/

    03

    3

    2

    2

    1

    1

    R

    UU

    R

    UU

    R

    UU(45)

    From this formula we can get

    213132

    321231132

    RRRRRR

    URRURRURRU

    (46)

    Assume the following: 1*

    1 RR , 2*

    2 RR and 3*

    3 RR

    Because*

    1R ,*

    2R and*

    3R are parallel connected with each other, the equivalent resistance of

    these resistor is as follows:

    *

    3

    *

    2

    *

    1

    *

    2

    *

    1

    *

    3

    *

    1

    *

    3

    *

    2

    *

    3

    *

    2

    *

    1

    *2

    *1

    *3

    *1

    *3

    *2

    *

    3

    *

    2

    *

    1

    111

    RRR

    RRRRRRU

    R

    UI

    RRR

    RRRRRR

    RRRR

    sum

    sum

    (47)

    We use 1R , 2R and 3R to express*

    1R ,*

    2R and*

    3R , and get

    321

    213132

    321

    3

    21

    2

    31

    2

    32

    21

    RRR

    RRRRRRU

    RRR

    RRRRRRUI

    (48)

    Because for an ideal operational amplifier, we have UU

    We get

    *

    3

    3

    *

    2

    2

    *

    1

    1

    3

    3

    2

    2

    1

    1

    321

    321231132

    321

    213132

    213132

    321231132

    1

    11

    R

    U

    R

    U

    R

    U

    R

    U

    R

    U

    R

    U

    RRR

    URRURRURR

    RRR

    RRRRRR

    RRRRRR

    URRURRURRI

    (49)

  • 8/8/2019 Compass Thesis 2010

    50/102

    Development of an Electronic Compass

    50

    So the output current is determined by the input voltage and the in parallel connected output

    resistors. The value of is set as:

    01.0 , kRR 10021 and MR 13

    kRR 1** 21 , kR 10*3

    The R4 and C1 are used to make the circuit stable, since the sensor acts as an inductive load,

    and so the phase margin is very low.

    3.11 DC zero_bias generation

    The signal from the integral controller is polar, from about -1.5V to +1.5V. The positive and

    negative parts are symmetric. The allowed range for the input of the ADC is 0V~+2.5V. The

    DC zero_bias is used to fulfill the requirement. The circuit diagram is shown in figure 49. Thesignal from the integral controller is called Ucontroller. The DC zero_bias voltage is called Vref. It

    is the reference voltage of the microcontroller, about 2.5V. The output signal with DC

    zero_bias is called UADC. It is used as input to a voltage follower and then to the ADC.

    Figure 49: The circuit diagram of the DC zero_bias generation

    The voltage of UADC is calculated as follows:

    k

    VU

    k

    UU refADCADCcontroller

    200200

    2

    refcontroller

    ADC

    VUU

    (50)

    Because VVref 5.2 , we get VU

    U controllerADC 25.12

    (51)

    If Ucontrollervaries in the range from -1.5V to +1.5V, the ADC input voltage will have values

    between +0.5V and +2V. It is suitable to input to the ADC.

  • 8/8/2019 Compass Thesis 2010

    51/102

    Development of an Electronic Compass

    51

    3.12 Microcontroller part

    The microcontroller is ADuC832. It has embedded 12 bits ADCs and DACs. The ADCs is

    used to convert the analog signals of the tilt measurement circuit outputs and the magnetic field

    detector circuit outputs from analog to digital. The microcontroller is connected to the displaywith, its P0 and P2 port. There is also a connection for downloading programs via the serial

    interface.

    Figure 50: The connection of the microcontroller

    Pin no. Name Function1 ADC0 ADC channel 0. The component of the earth magnetic field

    in the N/S sensor direction is used to as input to this pin.

    2 ADC1 ADC channel 1. The component of the earth magnetic field

    in the E/W sensor direction is used to as input to this pin.

    3 ADC2 ADC channel 2. The tilt measurement circuit output in X

    direction is used as input to this pin. It is used for the tilt

    measurement.

    4 ADC3 ADC channel 3. The tilt measurement circuit output in Y

    direction is used as input to this pin. It is used for the tilt

    measurement.

    5 AVDD Analog power supply.6 AGND Analog ground.

    7 CREF Decoupling Input for On-Chip voltage reference. A 0.1uF

  • 8/8/2019 Compass Thesis 2010

    52/102

    Development of an Electronic Compass

    52

    capacitor is connected between this pin and AGND.

    8 VREF Reference Output. It is used as a reference voltage for the

    DC-zero_bias generation circuit.

    9 DAC0 Not used.

    10 DAC1 Not used.

    11 ADC14 ADC channel 4. Test power supply from the accelerometerinputs to this pin. Its for testing the supply voltage of the

    accelerometer and adjusting the zero bias and sensitivity of

    the outputs.

    12 P1.5/ADC5 Not used.

    13 P1.6/ADC6 Not used.

    14 P1.7/ADC7 Not used.

    15 RESET Reset for down loading the program.

    16 RXD Data Input/Output of /serial Port. RXD and TXD are used or

    down loading the program.

    17 TXD Clock Output of Serial Port.

    18 P3.2 Not used.

    19 P3.3 Not used.

    20 DVDD Digital power supply.

    21 DGND Digital ground.

    22 P3.4 Not used.

    23 P3.5 Not used.

    24 P3.6 Not used.

    25 P3.7 Not used.

    26 SCLCOK Not used.

    27 SDATA Not used.

    28 P2.0 Port 2.0. It is connected to the enable signal of the display.29 P2.1 Port 2.1. It is connected to the data read/write of the display.

    30 P2.2 Port 2.2. It is connected to the register select signal of the

    display.

    31 P2.3 Not used.

    32 XTAL1 There is a 32.768 kHz crystal connected between XTAL1

    and XTAL2.

    33 XTAL2 See XTAL2.

    34 DVDD Digital power supply.

    35 DGND Digital ground.

    36 P2.4 Not used.37 P2.5 Not used.

    38 P2.6 Not used.

    39 P2.7 Not used.

    40 EA External Access Enable. A 1k resistor is connected between

    this pin and DVDD to enable the compas