NAVIGATION SYSTEM AND METHOD

Abstract: An electronic compass system and method in which an automatic calibration process is available while the vehicle is in use. The procedure uses a binning process to collect and count data points which automatically triggers the automatic calibration process, and which is also used for manual calibration. Also, there is a procedure for detecting and rejecting anomalous magnetic events outside the vehicle through a jitter phenomenon.

Description: TITLE: NAVIGATION SYSTEM AND METHOD CROSS-NOTING TO PRIOR APPLICATION This application claims the benefit of U.S. Provisional Application 60/037,025 filed on January 31 , 1997, the content of which is incorporated herein by reference. FIELD OF THE INVENTION This invention relates to magnetic and non-magnetic sensors used for determining vehicle direction of travel, measuring vehicle movement, acceleration and deceleration and speed. Specifically this invention could be used to show a driver his direction of travel or it may be used as an aid to other navigational instruments such as, but not limited to the Global Positioning System (GPS). The invention further relates to a multi-sensor integrated vehicle navigation and location system. REFERENCES TO APPENDICES Attached as part of and incorporated into this application/patent are the following APPENDIX "A" The Following Listings Are An Exemplary Software Implementation Of The Foregoing Discussion APPENDIX "B" Hatch U S Patent No 4,797.841 BACKGROUND There is an increasing need in vehicles of all types for electronics which can supply data for use by the driver or some remote location away from the vehicle to determine in one example, in which direction the vehicle is traveling This application is that of a stand-alone compass in which the heading of the vehicle could be 15 displayed on a small electronic display as one of, let ' s say, eight points of the compass, North (N), South (S), East (E) West (W), Northeast (NE), Northwest (NW) Southeast (SE), and Southwest (SW) A more sophist sated ve r sιon of such 2 stand alone compass would be ere which has sufficient perfemance and acci_/a: to display the heading deg r ees cf a compass in 1 or 2 degree increments as a : : numeric value or in an analog form like a needle on a compass rose Vehicle-mounted compasses must be calibrated to account for the magnetic signature of the vehicle If there is a change in the magnetic s gnature of the vehicle a ne.v calibration is necessary However it is often the case that the operator does i : not know the change and therefore the reading will be off Also, in the event of ' ansient magnetic disturbances, prior systems will hold the last heading before the dis 'bance began When the disturbance ceases, a new correct heading is provided Bridges, steel buildings or adjacent roadways built with ferrous material can cause transient magnetic anomalies, s One problem is in the detection of such an anomaly, because it may not be detected as an anomaly, in .vhich case prior compasses will respond with incorrect readings A'so, an anoma',- or recurring anomal.es may be p r esent for an extended length of time, for example on modern highways such as overpasses, ramps and tre :c like built with ferrous mate- als In another example, Navigation systems of various types have been developed which assist the vehicle operator or a passenger to navigate to or away from a particular location Navigation systems generally employ some form of is triangulation of a source of three or more radio signals to determine the position or location of the vehicle Such systems have been created using the technologies of LORAN DECCA GPS FM and AM radics s gna's and other RF radio systems E/ plotting the position chances of the vehicle over t.me on an e'ectronic map such a navigation s/stem is created Such navigation systems work reliably as long as the :: radio signals can be rece . ed wύhout interruption There are serious limitations to such systems because the loss of one or more of the radio signals due to signal blockage can serious reduce the accuracy of the navigation system and often res.l in the failure of the system :s Navigation and location determination systems such as, for example, those employing Global Position, ng System (GPS) technology including Differential GPS (DGPS) technology, often have limitations caused by the temporary unavailability c' the signals they are receiving and using to determ.ne the position of the vehicle. In the GPS and DGPS example, there are times when there are insufficient satellite signals available, such as in areas around tall buildings or other obstructive masses 5 to maintain continuous measurement of the position of the vehicle. Very similar requirements and similar limitations exist in another example, Vehicle Location as distinguished from Vehicle Navigation, that of enabling in the vehicle or at some remote location, the determination of where the particular veh.ce :o is in relationship to a map or any other form of vehicle location determination. Suo- applications range from supplying vehicle location data to occupants of an automobile or any other land, sea. air or space vehicle to a vehicle location determination system in an automobile or any other land, sea, air or space vehicle which enables pinpointing the vehicle's location on some form of electronic map is display or by producing coordinates within various coordinate systems which woukj enable the location of the vehicle on a non-electronic map or grid of some sort In such cases there is a reed for somethurg which can continue to compL.r the location of the vehicle during these times That is to say aiding the navigatio- v : : location system by outputting a continuous series of vehicle positions and maintaining the ability of the system to continue to function during times of signal outage or blockage Using the integration of sensor data frcm various sources, a~: processing those data to compute the change position of the vehicle over time ca- do this Such a technique would process inputs of data such as speed and :s movement from a speed sensor or an accelerometer with the heading of the veh : e measured from that last known position of the vehicle before the signal outage or blockage Such a system may be called a Flywheel and in the case of GPS systems, a GPS Flywheel because metaphorically the system continues to operate even as the primary navigation or location system has been degraded or lost 3 SUMMARY OF THE INVENTION In one aspect the invention is a compass system and method of particular application to vehicular use in which an automatic calibration is performed In one : ; particular the automatic calibration is done by recording sensor data as the vehicle is driven in normal use, until the vehicle has been driven in a complete circle This is detected and recorded by the system by dividing the circle defined by the system into segments or bins and ensuring that there is at least one data point in each bin The means by which it is ensured that a data point is put in each bin if in fact each bin has is been visited by the driving of the vehicle is by the constant adjustment of the offset parameters descnbing the center of the computed ellipse An important feature of this a r d other aspects of the invention is the use of a high ra'e of readings from the magnetic sensor ; : Another aspect of the invention senses the presence of transient magnetic anomalies moving relative to the vehicle and then rejeclng the sensor readings of the anomaly in processing so as to not use those readings as output for heading indication It has been found that transient magnetic bodies such as bridges steel reinforced buildings overpasses and the like have a h.gh frequency signature called : : j .tter, which can be detected and distinguished and therefore can be rejected Consequently, a heading prior to the onset of the jitter can be maintained as the compass system output without any change as long as the transient anomaV is present Then when the jitter ceases, sensor data processing resumes to current headings Consequently, due to the high rate of data readings, even a bnef recess in jitter will allow good readings and therefore the output of a good heading 5 So, while for example passing a re'atively extended anomaly source, good readings may be obtained and an updated heading will be provided Only a brief penod of quality data during the presence of a transient anomaly is enough to provide an update to g ve a good reading output l c Another aspect of the inverlon combines a compass system with a radio navigation system such as GPS, so that when GPS signals are lost, the compass system comes into operation to provide heading data A fully integrated system is also contemplated, in which a precision radio navigation system such as GPS is integrated with alternative sensors such as a suite including a magnetic compass a is cross-track accelerometer, wheel turn sensors, and a speed sensor An angular rate sensor may be used in place of a cross-track accelerometer, or redundantly This mteg'ated system can provide ad .aπtages even in the p'esence of a full set of GPS sa'.e'lites The integrat on w II allo.'. use of the alternative suite as required tc either supplement or substitute for the pn ary navigation system This can be imp erre- ed 2 : us ng add '.Onal senses such as a speed sensor, rate sensor and cross-tracx accelerometer Good GPS navigat on can be obtained w ith reception from as fe.v as four GPS satellites or three if altitude is known The invention considers the oss of data as GPS satellites are lost first to three, then to two then to one, and fina'ly, none 25 The essence of this aspect of the new invention is to tailor the Kal an filter such that it can make optimum use of the associated speed and heading sensors Specifically, the states included in the Kalman filter will include two horizontal position states in which the coordinate system is not critical The third position state will be the vertical position Also included will be the GPS receiver clock time and clock frequency states. The velocity states will include the speed in the vertical s direction, the heading of the vehicle and the along track speed of the vehicle. The specific choice of these states makes it possible to easily re:onfιgure the Kalman filter whenever GPS satellites are lost such that the system accuracy will degrade only slowly Thus, when the number of GPS satellites drops to three, the vertical Velocity State will be slowly changed to zero, i e to a height hold mode When the : : number of satellites drops to two, the absolute readings fro~ the GPS code measurements will be dropped and only the change in the carrier-phase measurements will be used Furthermore, the carrier-phase measurements will not be used to feed the heading state The heading state will be driven by the magnetic heading sensor and cross-track accelerometer. When the number of GPS satellites is drops to one, the GPS measurements will be used only to update the GPS receiver clock Frequency State. Whatever speed sensor is available will be used to drive the aiong-track Speed State The magnetic compass and cross-track acceleromete' will be used to drive the heading state The standard time υpds'e process will obta the position states A rate sensor can be used in which case two or more calibration states rr g t be included, which give a speed scaling to bring speed measurements into agree m ent with the GPS derived speed BRIEF DESCRIPTION OF DRAWINGS FIG. 1 is a diagram showing a potential problem in the prior art. FIG. 2A is a guide to the symbols used in the software flow charts, as shown in Figs. 2B - 2L FIG 2B is a few chart of the start-up portion of the software. FIG. 2C is a ficw chart of the main processing loop portion of the software FIG. 2D is a flow chart of a continuation of the main processing loop portion of the software. s FIG. 2E is a flow chart of a continuation of the main processing loop portion of the software. FIG 2F is a r ow chart of the manual ca' bration portion of the soft.va e : FIG 2G is a f.ow chart of a contmuat en of the manual calibration port on c' r.e software. FIG 2H is a flow chart of a continuation of the manual calibration portion c' t~,e software 5 FIG. 21 is a fiow chart of the Wild Edit portion of the software FIG 2J is a flow chart of a continuation of the Wild Edit portion of the software FIG. 2K is a flow chart of the Check Communications Input portion of the software. 5 FIG. 2L is a flow chart of the Load From EEPROM portion of the software. FIG 3A is a block diagram of the circuitry :: FIG 3B is a continuation detail of the block diagram of the circuitry. FIG 3C is circuitry schematic, including the sensors. FIG. 3D is circuitry schematic, including the microcontroller. FIG. 4A is a block diagram of the circuit of the integrated system using onboard sensors FIG 4B is a further block d agram of the circuit of the .ntegrated system us ng : : on-board sensors DETAILED DESCRIPTION In its preferred implementation, in one aspect the invention consists of an electrical circuit containing magnetoresistive sensors, a microprocessor with memory and input/output devices enabling the receipt of data from other sensors such as a speed sensor or an accelerometer The memory contains software algorithms, which perform the computation of accurate vehicle heading, automatic calibration of the magnetic sensors, and an algorithm, which computes the Flywheel position data from the integration of the various sensor data In this respect, the term Flywheel is used to indicate a system, which operates through other sensors when a primary navigation system is wholly or partially inoperative, such as when GPS reception is blocked Magnetic heading sensors typically have problems associated with the induced and permanent magnetism of the vehicle on which they are contained The magnetic signature of a vehicle will change frequently Changes to the magnetic signature can come from a change in the shape of metal structures of the vehicle introduction of a mass of ferrous material into a vehicle, such as a toolbox or cargc. and interference by magnetic fields such as the operation of electric motors and electric coils of various types Assuming no distortion from the vehicle on which they are mounted two orthogo n al magnetic sensors will trace out a circle centered at the origin as the vehicle turns in a comp'ete circle, where the origin is defined as no magnetic field measured by either sensor Permanent magnetism of the vehicle causes the readings of two orthogonal magnetic sensors to trace out a circular pattern which offset from the center Induced magnetism arising from soft iron or other easily magnetized material will cause the circle to distort into an e'lipse with the long ax s n the direction of the preponderance of the easily magnetized material Several patents have been issued which describe methods to calibrate the offset ellipse, which either dual horizontal-axis flux gates or magnetoresistive sensors trace out as the vehucle on which they are mounted turns a complete circuit Hatch et al U S Patent No 4,611293 and Hatch, U S Patent No 4,797,841 are two examples which are able to calibrate the compass in the presence of permanent magnetism in the s vehicle and soft iron induced magnetism in any direction (i e. the solution for the ellipse is entirely general. Patents have also been issued which accomplish the same effect by using simplifying assumptions about the symmetry of the induced magnetism or about its :: existence One patent, No 4,953 305 van Lente, et al , allows a calibration to be performed in which the soft iron is assumed to be aligned in the direction of the longitudinal axis of the vehicle This means that the semi-major axis of the ellipse is assumed to be aligned with the vehicle axis This is generally not a bad assumption if the magnetic sensors are located near the centerlme of the vehicle. Another is patented technique assumes that the induced soft iron magnetism is negligible and the pattern is constrained to a circular fit, i.e the el pticity is zero This is generally not a very good assumption, but for the accu r acy needed for ca r navigation display only, it is generally good enough : : The parameters which must be determined in order to map the sensor readings to a circle centered at zero are (1 ) the center offset in both the x and y axis, (2) if induced magnetism is allowed, the elhpticity of the sensor readings , and (3) if non-symmetry of induced magnetism is allowed, the angular direction of the semimajor axis of the sensor ellipse. Patents have also been issued, e g Wanous, U.S. Patent No. 5,046.031 , wh i ch allow an automatic update of the calibration method using certain simplifying assumptions For example, if it is assumed that a magnet in the same horizontal plane has disturbed the sensor readings, then the size of the circle to which the ell i pse is mapped will not change and one can move the center offset to restore the 5 same radial reading However, this procedure will induce errors under certa i n cond i tions First , if the disturbing magnet is not in the same horizontal plane as the sensors , the size of the circle as well as its center location may change Second, i f the vehicle location is moved sufficiently in magnetic latitude the hcπzontal component of the earth s fie d either increases or decreases substant i ally and the i c size of the circle will a'so be altered accordingly For these reasons a new automat i c calibration procedure is invented which has the potential to automat i ca ' ly alert the user for the reed to perform a new "assisted " calib r ation if the automat i c calibration procedure indicates the need i s A new precision compass with an improved automatic calibration procedure i s d i sclosed with several advanced features, which make it ideal for those appl i cat i ons which reed high accuracy heading informal on It ca- be used as a stand-alone compass or it can be integrated with other on-t:ard sensors In a rr z-e fully deve'oped navgat.on and location system with a rad o -a / i ca * on system su:h as GPS , the compass and other on-board sensors define a high'/ -tegrated system Th i s device makes a Flywheel due in part to the fact tnat we get mult i ple sensor read i ngs per second Current implementations have used f ve Hz to s i x Hz up to 12 Hz (readings per second) updates The use of th.s instrument w i th a speed sensor input provides an excellent aid to an otherwise GPS only nav i gat i onal solution This instrument makes an excellent low cost sensor because it is accurate, self-tuning, and provides data at a high update rate At the heart of the new compass is a pair of orthogonally placed magneto 5 resist.ve sensors (MR sensors). The output of these sensors is much like that of the flux gate sensors to which Hatch (U. S. Patent No 4,797,841) has provided an algorithm for calibrating the sensor in the presence of local magnetics The MR senscrs are sufficiently sensitive to measure a rotation of the MR sensors within the earth ' s magnetic field to within one degree Via the application of Hatch ' s algorithm : D and through software smoothing of the raw inputs from the two orthogonal sensors we can achieve a highly accurate direction sensor. Automatic Calibration Procedure is In order to make this tool useful in practice there is a need to automatically calibrate the sensor data This is because the changing of the local magnetic fields can a'ter the perceived direction The technique used for automatic calibrat en is described be'ow. 20 Auto calibration occurs in two distinct steps 1 Constantly adjust the offset parameters similar to the manner desc bed in the Wanous U S Patent No 5,046,31 25 2 When enough data is collected, as described below, apply the complete cal'bration algorithm. Constant Adjustment Of The Calibration One step in automatic calibration is to adjust the offset parameters in a manner simi'ar to that described in Wanous, U S Patent No 5,046,031. The constant adjustment to the offset parameters is based upon comparison of the computed radius from current data with the known radius provided from the ca'.bration terms (To reduce the computational requirements the square of the rsd'us can be used rather than the radius ) However, simple application of the techniques described in the Wanous patent allows for errors to be made in the c"set adjustment. Fig 1 will aid in describing the potential p r oblem Consider the circle labeled CO, this represents the unperturbed raw data, as it would look after being re-circularized by applying the fit parameters. The circ'e labeled C1 is how the "after the fit" data may appear if a magnet were placed near the sensors. Now assume the vehicle was pointing SW. This would provide an (x, y) pair at point M. The radius comparison technique would compare a radius of r1 to that of r2 and find (by getting the components of r2) that the data had shifted down and to the left This is quite wrong (in general this error will be wrong by s μ ~ ng the data the wong d rection by 2 * radιus) the data has in fact shi f ted up and to re right as we w ould have correctly computed had the vehicle been pointing NE The problem is that the data is ambiguous, both rl a^ d r3 appear to be points representing NE. Although the present algorithm may make this mistake, it will only be temporary because as more data is collected we will d'sccver the mistake we made and correct it. Every time we collect an additional 25 : : of the data we reexamme the consistency of the data by computing the rad us using the current fit parameters on a previously saved data pair and comparing that to the radius computed using the most recent data If the difference between these two radii exceeds a predetermined selected threshold, the data is thrown away and the automatic calibration is restarted It is desired to examine the data and detect the problem as early as possible Twenty-five percent is selected because it usually wil s sufficiently define the general structure of the ellipse to determine if the data shc d be retained or rejected Less data may suffice, and more data will do the job but wll delay the rate at which calibration parameters are updated The minimum data is that needed to define the general structure of the ellipse This solves the problem just described as well as the problem of mixing data from two different local :: magnetic inputs. The potential for this problem is minimized too because until the offset is greater than the original radius (r2) the problem of ambiguity does not occur. Because we take measurements at approximately 12Hz, and we recompute the is offset with each measurement, the perturbation of greater than 1 radius must occur within approximately 1/12 seconds Otherwise we will keep up with the movement and not ente r into the ambiguous state The computation of an automatic complete calibration is based upon the 2 : following scheme The current data is cata'ogued in order that the software is a.'. = -e when the vehicle has undergone a 360 ; rotation Anytime sufficient new data is available a new calibration will be performed In this patent we propose a new v.a/ to catalog the data, which under normal circumstances prov.des a better way to detect when a full rotation has occurred and that an automatic ca' bration can be 25 performed Data is automatically collected and stored for a new calibration anyt ~~e the automobile ignition is turned on In order to avoid mixing data obtained from different local magnetic environments, the automatic adjustment of the offset parameters is monitored. If the difference in the radius of the circle from the current data exceeds a threshold value, (for example, one-half the value obtained from the last complete cal bration). The automatic calibration procedure is designed such that the operator generally need not perform any special procedures at all. In addition, to a solution of the ellipse parameters, the rms residuals of the fit will be computed. If the rms residuals remain below a selected threshold the parameters of the cal.bration may be assumed correct and could be used to map the sensor readings to the centered circle from which the heading is computed. If the residuals exceed the selected threshold a user message could be transmitted requesting that the vehicle be turned in a complete circle to update the sensor data, Once the turn is completed, the least squares fit to the ellipse will be re-computed and, if the rms residuals are good, the new calibration parameters will be employed Two addιtιona ; techniques are applied to provide more accurate results First applying a moving a.erage to the raw (x. y) pa rs smoothes the raw sensor data The second technique is to provide the ca' bration algorithm v,,th as much data as possible. The calibration applies a least squa'es fit to the data provided Clearly then, the more data that is provided the better the fit One of the keys to the least squares algorithm is the computation of (Ht H) (read H transpose H) which is the product of the transpose of the observation matrix H times the observation matrix H In this application H is an "n x 5" term matrix Where "n ' represents the number of measurements. Traditional techniques would have to store n'5 terms in order to provide the data for the fit. By computing HtH and Hty "on the fly' * we are not required to store the individual data points and may therefce use all the data available, thus providing a better fit. Including Speed Sensor Algorithms A new Kalman filter scheme is proposed for including speed sensor data ;".o the ' GPS Flywheel." Various speed sensors can be included into an automobile navigation system. Of particular interest are these sensors which can aid the navigation while GPS signals are missing for short intervals Such sensors may include, but are not limited to, the odometer speed or other drive shaft sensors, wheel turn rate sensors, Doppler radar speed sensors, or e.en accelerometers which can be integrated to give the vehicle speed. The essence of this aspect of the new invention is to tailor the Kalman filter such that it can make optimum use of the associated speed and heading sensors Specifically the states included m the Kalman filter w:ll inc ' .de two horizontal position states in which the cccdmate system is not cπt.ca The third pos tion sx will be the vertical position. Also included will be the GPS receiver clock tme a~: clock frequency states. The velocity states will include the speed in the vertica! direction, the heading of the vehicle and the along track speed of the vehicle. Tre specific choice of these states makes it possible to easily reconfigure the Kalrr.a- filter whenever GPS satellites are lost such that the system accuracy will degrade only slowly. Thus, when the number of GPS satellites drops to three, the vertica Velocity State will be slowly changed to zero, i e. to a heig h t hold mode. When 're number of satellites drops to two, the absolute readings frcm the GPS code measurements will be dropped and only the change in the carrier-phase measurements will be used Furthermore, the carrier-phase measurements will net be used to feed the heading state The heading state will be driven entirely by the magnetic heading sensor. When the number of GPS satellites drops to one, the GPS measurements will be used only to update the GPS receiver clock Frequency State Whatever speed sensor is available will be used to drive the aiong-track Speed State. The magnetic compass and cross-track accelerometer will be used to drrve the head.ng state. The standard time update process will obtain the position states In addition to the standard eight states of position and velocity described above, calibration states will be added for appropriate calibration of the speed and heading sensors. The magnetic compass will include a state, driven by the GPS measurements, which will determ.ne the magnetic declination, i.e. a calibration value for the magnetic compass. If an odometer or wheel sensor is used, two or more calibration states might be included which give a speed scaling value to bring the speed measurements into ag'eεment with the GPS derived speed. Different scaling values might be needed as a function of the ve 1- :'e speed (i e excessive wheel slippage at high speeds) It is believed that the Kalman filter, with the states designed as described above, represents a unique conf guration especially adapted for use as a "GPS Flywheel" system particularly we! ' adapted to determining an estimated position ιr the absence of sufficient GPS sa.ell.te measurements to obtain a standard GPS position fix. Referr i ng to the above, when GPS reception drops to three satellites , alt i tude hold i s i n place unless , for example, an altimeter is used to subst i tute When GPS recept.on drops to two satellites, the magnetic compass and the cross-track accelerometer operate to provide heading. Also, redundantly , an angular rate sensor could be used. Therefore, including a graduated integration of inputs , as the accuracy of one sensor degrades, other sensors are used. When GPS reception drops to one satellite , only time is obtained and therefore , the other sensors are used for speed , decoding and plctt.ng posit i on Additional Description The magnetoresistive sensors employ a bridge circuit polarized so that i t is direct i onally sensitive to magnetic fields so as to measure the strength of the f.eld. When mounted on a vehicle the sensor measures the Earth's magnetic f.eld and deviation magnetic f i elds caused by local cond i t i ons , which may be from the vehicle or the adjacent area . This resets i n a compass direction from the magnetores i st i ve se-ors The output from the sensors, a voltage, corresponds tc the angle of the - sensor w i th respect to the magnetic field imposed upon it Th s g i ves the d i rect i on Two orthogonally oriented magnetoresistive compasses are needed to resolve d i rect i on of rotat i on . In the system, the output voltage is tra-s ' ated i nto a d i g i tal valve In the system , however , a different type of sensor could be used such as a flux gate compass, or a Hall effect sensor, to give the unique angular pos i t i on so long as the necessary angular discnmination is available, the magnetoresistive type sensor be i ng one desirable type 1 - ch can produce the des red directional s i gnal The employment of magnetores.st:,e sensors is known in the pr i or art In the system, there is a ne.-. way of cataloguing data Each sensor read i ng produces an x , y coordinate which when the vehicle is driven in a circle , will produce a circle or more general!, an ellipse, which will be offset from the center of the coord i nate system due to the l:cal magnetic anomalies As in the past , i t i s an ob j ect of the present system to ad,jst for the magnetic signature of the veh i cle , as well as for any changes in the magnetic signature of the vehicle Also , the present i nvent i on addresses the problem c' transient magnetic anomal i es In part i cular , i n an aspect of the invention, transient magnetic anomalies are detected and rejected so that the system will continue to provide correct headings even dur i ng the presence of the transient anomaly In the prior art , the circle or ellipse is shifted to the center of the coord i nate ε,stem by appl, ng current to a cc ' to change its offset to put i t around the or i g i n l,n the present ιr .ention. the e" pse is circularized rra'nems * :a / so the sensor readings are not adjusted The radius of the circle is p'Oportional to both the sem.-major axis and the seπvm i nor axis of the ellipse Th.s a big ellipse would g .e a i g circle The la-ger the c i rcle , the g-eater resolution v, I be available The limit ng factor of the max i mum s i ze is the dynamic range of the ADC ' s in the m i crocontroller W.th a very small rad i us it is impossible to determine heading due to noise The comprom i se rad i us i s between 100-200 counts to obtain quality headings w.thout approach i ng the limit of the dynamic range of the ADC ' s. As a start-up procedure, the radius is tested to determine if it is within the desired range and the pulse width modulation is adjusted to achieve the desired range. In summary, the calibration process as described herein has the following general steps. 1 Collect data, 2 Run the cal bration algorithm to define the ellipse, and obtain the calibration terms, the parameters for the ellipse This step has two steps which are (a) every data point which is to be used will be processed to update the observation matrix and (b) finish the calculation to obtain the parameters for the least square fit ellipse; 3 To get headings, use the obtained calibration terms found to cι':Jarιze the heading data; and 4 Compute a heading The mathematical process for converting data points on the ellipse to points on a circle is shown in Hatch U S Patent No. 4,747 8 1 , the content of which is incorporated herein and which is attached as Appendix " B," and which is generally re'erred to as circularization by least squares, or more concisely, circularization In an aspect of the present invention, the Hatch circu'arization by least squares is per f ormed by a particular chosen procedure, in short, providing data serially, as can be seen in the software listings, so as to avoid the need to cc"ect and retain all the data With circularization, heading may be measured Data is gathered to use in the calibration process. The data is employed in a procedure referred to as "binning." or the "bin process." In tr. s process, it is necessary that the vehicle be driven in a circle in order to gather data around a complete rotation, which is necessary for calibration In the known systems, compass calibration is performed by the common procedure to simply drive the vehicle in a circle, taking data, and using whatever system is to be employed This is referred to as manual ca'ibration In the present invention a novel procedure for automatic calibration is described. The process of complet.ng calibration as described herein is applicable to both manual and automatic calibration, but is particularly advantageous as applied and making possible fe automatic form of calibration. An important element that makes the procedure pract cable is the frequent acqu ' Sition of readings from the sensors An exemplary da'ϊ r ate is 12 Hz, that is tv.elve readings per second The limit of data rate is const'S ned by the processing power of the assocated computer and thus could be very h en But a very high data rate would not improve results The lower limit will effect the Ineness of accuracy The present method uses a smoothing technique, which w ' adjust for noisy readings It is necessary to co ! 'ect data fast enough to smcc'.h out noisy measurements Also, a lewer limit is driven by the need to 'ecord motion of the vehicle in a timely manner, which is influenced by the spee of vehicle A lower limit cf about 5 Hz is available for good results for general-purpcse land vehicles, such as cars and trucks on typical roads and highways Thus, tc some extent the results 23 PCΪ7US98/02181 will be effected by the speed of the vehicle through turns, which in turn relates to b.n size, as will be seen In the binning process the theoretical circle resulting from the circularization s procedure is divided into segments of equal size which define equal portions of the circle, recalling that every reading (except those rejected for being invalid) is circularized to fall on the circle, and therefor into one of the segments SOFTWARE DESCRIPTION L C In a preferred embodiment the computer is programmed with fifteen subprograms, which are shown in Appendix " B " The functιc ,ng of these programs is explained in the flow diagrams of Figs 2A-2L The softv.a-e is used in conjunction with the electronic circuits of Figs 3A-3D and 4A and 4B. 5 Figure 2A shows symbol definitions to assist in mterp-eting the flow diagrams Figure 2B is the flow diagram for the start-up rout , n e 230 Optionally at 232 a communication mode may be implemented For exanrp'e 'or testing mon toπrg or modifying the program, a communication mode may be cesired At 204 the subroutine Load From EEROM is called to provide calibrat en values stored in the EEROM These are either from prior sensor readings or a ce'ault set At 206, the calibration terms are organized in a structure and stored at 208 There are five calibration terms x offset, y offset, flattening, and sine of the angle of rotation and cosine of the angle of rotation Next, at 210 the smoothers a r e initialized The smoothers is a program to calculate a moving average for t e x and y data readings At 212, the jitter tune values for detecting transient anomalies are the jitter threshold and sequence lengths The jitter aspect of the invention is involved in the detection and rejection of transient anomalies, as will be described in further detail 5 below Jitter threshold and seque n ce length are the selectable variables for the process. These are set to default values, or they can be selected. At 214, the first 20 (or other selected number) read.ngs are discarded to ensure that there is no power-on hysteresis error Then at 216, the smoother array is filled and ready to perform the moving average calc ' ations. Each moving average is used to calcu'ate :: head.ng unless discarded as anomalous as detected by the jitter detection procedure In the exemplary system, six readings are used for the moving average The number of readings for the moving average can be varied, and is selected as a function of the rate at which measurements are being taken In the exemplary case, readings are being taken at the rate of 12 per second. The reading rate in turn is depends on the expected speed of the vehicle For higher speeds, fewer samples would be taken At 218, there is a step to give sufficient resolution to determine readings At 220, there is a step to ensure consistent readings. Figure 2C is the flow diag'am of its Main Processing Loop for performing 2 : calibration. As noted above. the * e is an optional communication link at 230 The variation setting steps 232 allow selection of the magnetic north declination for the geographical area of the current operation At 234, the sensor readings in digital form are received from the subroutine, and the reference voltage is removed. At 236, the readings are loaded into the data structure and the jitter arrays are loaded :5 At 238, the normally automatic calibration will run unless the user selects manual calibration. Figure 2D continues the Main Processing Loop. To effect automatic ca' - ration, the vehicle must be driven in such manner that a full 360° is turned in order to obtain readings to define a full circle (or ellipse) and to provide at least one reading for each bin. But the driver need not be conscious of this requirement, as s the normal driving will collect data for the bins, and the automatic calibration will be effected when there is at least one reading in each bin First, at 242, the Wild Edit subroutine is performed to eliminate spurious data, which is executed below at 232A ic Next, at 244, the matrices and bin counters are cleared Then, at 246, the smoothed data is put into the data structure used for computing headings. Also, the new terms are placed in the data structure for bin recording. In the exemplary case, th rty 12 s bins are used The bin size is related to the anticipated speed of the vehicle in a turn. The exemplary system takes readings at the rate of 12 per is second. This is a good rate for general vehicles on roads and highways. The reading rate may be determined by the circuit, but it must be fast enough to recognize that the vehicle is performing a turn, as this will affect the quality of the r esultmg output to the user The variables are the data-takirg rate the speed of the vehicle and the number of b ns In the present example, there must be at least one 2: cata pomt in each bin to q ^ a' *y the data set for an automatic calibration Thus, a minimum of 30 points will be used, although there will rarely if ever be so few Consequently, if the vehicle turns so fast that the readings skip a bin, then no automatic calibration will occur until that bin has been filled by the vehicle being on me heading for the omitted b,n during driving Even though 12= bins are quite a 25 small angle, readings at 12 per second generally ensure that a vehicle will obtain enough readings during a turn. For example, if a 90° turn takes one second, there w i ll be 12 read i ngs for the 7 or 8 bins It is also appropriate to have a max i mum l i mrt of read i ngs for each bin. 25 having been selected ,n the exemplary system At 248 the c i rcular i zat i on algorithm is applied to get the radius of the c i rcle Th i s prov i des a m.n i mum rate of b.n content of 1 25 in the exemplary system It has been determ i ned that a ratio of over 1 100 can undesirably d i stort the ell i pse The step at 250 determines if the data is inconsistent by a selected amount , 30 be i ng selected If so at 252 the offset is shifted and a new head i ng i s ca'culated The general offset concept is discussed ,n the Wanous Patent , No 5 C46.031. i ts part i cular implementation with modifications i s shown i n the ! st i ngs of Append i x " B " If the delta is acceptable, then the process p r oceeds through 254 to F,g 2E If the 250 delta is not acceptable, then in the steps at 254. a-f. a check i s made to see i f the result is better or worse The restart act on has concluded that there i s a b i g anomaly in the vehicle such as a large new magnet i c event requ i r i ng , re-read i ng of the magnetic signature of the vehicle Otherw,se, the conclus i on at 254e "No" is to continue with Auto Cal (256) Referr i ng to F i gure 2E the automatic calibration p-eCure progresses At 256. each i ncom i ng signal is identified to its bin At 258 t ^ e process of va ' dahng - e usefulness of the data and creating the matrices i s permed It has been selected that a consistency or validity check will be done v en 25% of the b i ns have data i n th i s case , 8 bins A second check ,s done for a-cfer 25% of the data Also a check ,s done to determine ,f the shift ,s too great W,th th i s ver i f i cat i on successfully completed , one of the matrices filled, the Hatch algor i thm ,s appl ed at : 5 260 and at 262 the heading is calculated and stored Referring to Figures 2F, 2Ghth and 2H, manual ca brat on procedure is shown In this case the binning process is not used It is assumed that over the short time needed to drive the vehicle in a circle, magnetic changes will not occur First the original x - y data pair is saved, and the circle-drive s executed until that = pair is reached again. Block 264 sets up the debug message At 266, a check is made that from the data history the smoothed data and the ra data are close If they are not close the process of 268 and thereafter is executed. If the data is good then the process at 270 is performed The data is used either because it is good date, or if it ' s bad but coming in for a long time it is allowed r and used to do the :: smoothing step Although the purpose is to discard bad da'a the high frequency of data readings works favorably For example, in 2 seconds the procedure will look at 24 data points This is done continuously, so if all the past data points are bad the process starts using them is At 272, the process of initializing the calibration gathering terms is started, at 274 the sensor data is obtained, and at 276 the referenced voltage is removed At 278 a verification check is made to ensure that the last twc measurements a'e clcse and if not, the process re-loops at 280 Otherwse the p c:edure continues at 262 2 : At 284, look to see if maximum allowable points h.a.e been gathered (n case a full circle has not been driven) At 286 check to see if the vehicle has moved away from the starting point if so make note of it at 288 E ock 290 asks if the vehicle has returned to the starting point At 292, if the a c e has been driver, a f l circle or the maximum number of points have been gathered then at 294, the 25 calibration algorithm is preformed If "No," at 292 then at 295, use the data point to calculate a heading Figure 21 shows the Wild Edit flow chart which is for the purpose of d i scarding bad data. At 300 , the data has been found to be bad, so it w.il not be used but will st i ll look for j itter . The raw data is too far from the smoothed data, we have detected a jump in the data (more than half the radius is the selected text). Even though it w i ll be disregarded for calibration and heading purposes it v. l be examined to see if there is jitter The blocks 302 are looking for jitter At 304. the data has been accepted and also examined for jitter. Figure 2J shows that the accepted data is smoothed Figure 2K is the process that looks for PC commands and listens for and responds to PC commands. Figure 2L shows the system initialization procedure and loads from the EEROM HARDWARE DESCRIPTION - CIRCUITRY The hardware and circuitry are shown in Figures 3A-3D A small , low-cost magnetic compass implemented wX electronic circuitry is described. This compass is suitable for use in vehicles or o -er applications su i ted to a magnetic compass (e g boats). The compass is operated in alternate set/reset modes The compass is provided with a means, implemented in hardware, of eliminating measurement drift, due to changes in operat.ng temperature, that affects compass accuracy In con j unction with mathematical calcu l ations performed by software , a means is provided for el.m.nating the perturb , ng efects of external magnet i c influences , which degrade the accuracy of standard magnetic compasses when used in proximity to large metal objects. The compass described uses magnetoresistive sensors to measure the alignment of the compass with respect to the Earth ' s magnetc f i eld The sensor is composed of four magnetic sensing e'ements, which change : : the i r res i st i vity upon application of an external magnetic fie l d arranged i n a standard bridge c i rcu i t The arrangement of the sensing elements is such that there is a •sens i t i ve" measurement direction (or orientation), with respect to an applied external magnetic field. The bridge is excited by an external voltage , and with no component of an external magnetic f.eld applied in the sensitive direction, the br i dge i s is balanced and produces no output. Upon application of an external magnetic f i eld in the sensitive direction, the bridge unbalances, producing an output voltage proport i onal to the applied magnetic field As the sensor (a^d thus the sensor ' s sens i t i ve d i rection) is rotated w thm a magnetic field, the o.'put vdtage of the bndge vanes smusoidally with changes in the sensor ' s angu'ar or entat i on w i th respect to 2 : the external magnetic field The sensor is provided with a means of flipping the polarity of the measurement output , allowing the sensor to be used in a " set resef mode That i s to say that the sensitive direction of the sensor bridge can be reversed Th i s polar i ty 2 : reversal prov i des a means of removing biases in the sensor bridge ' s output caused by manufacturing tolerances and other error sources Only the polarity of the output S ' gnal is flipped, and not the error voltages The flipping action has the effect of t r a^sformιng the actual measurement output into an a'ternat.ng current (AC) waveform, while error voltages remain direct current (DC) Standard filtering circuitry can then be used to separate the two signals The sensor's DC error signal can then be re cved from the output by means of negative feedback techniques The fl'pp ng action is caused by pulsing a " flip coil " located with the sensor package A pos '. ve current pulse of very short durat on (on the order of 10uS) causes the sensor ' s sensitive direction to be aligned m the " normal" orientation A negative current pulse causes the output of the sensor to very quickly reverse pc'anty By applying current pulses alternately in each direction at some regular rate (typically frcm 1kHz to 1 MHz), the sensor's measurement output is changed to an alternating ε gnal whose peak-to-peak amplitude is a funclon of the applied magnetic field The sensors may also provide a "compensation coil," although its use may be omited In the preferred embod ment the compensation coil .s not used because the compe^sat en for external perturbing influence is accomp ' shed by the soft.va'e Th ' S is a cαl located within the sensor package in e'ese prox ity to the sensor bridge, which can induce a mag n etic fie ' d measurab'e by the sensor bridge One use for this coil (and the genesis of its customary name) is fc compensation of external perturb. ng influences A current is passed through the compensation co ' in opposition to the perturbing influence, effectively removing it from the measurement output Another use of the compensation coil is to counter changes in the sensor s sensitivity over a range of operating temperatures. The sensor ' s measurement sensitivity typically decreases w.th increasing temperature In some app'ications, particularly automobiles, this can lead to significant measurement inaccuracy, because of the wide range of temperatures experienced in those env Onments. For example, due to solar loading, w.nter operation, and other factors, a compass used in an automobile can experience operating temperatures from -40° C to +120° C Changes in the sensor ' s output over this temperature range can drast cally affect the accuracy of the compass It is thus desirable to provide some mears of compensating for sensor output changes over temperature The sensors have the property that at zero output (i e the brdge is balanced), the sensor is temperature-insensitive It is thus possible to use the compensation coil to induce a f.eld equal, but opposite, to the applied external magnetic field. The sum of these two fields, external and compensation, brings the bridge into balance, operating the sensor at a point where its output is not sensitive to temperature It is then possible to indirectly measure the strength of the external (i e the Earth ' s) magnetic field by measuring the amount of current required by the compensation coil to generate an. equal and opposite field However, this use of the compensation coil obviates its use 'c compensating for perturbing influences These perturbing influences are most certa nly still present, though, and some means for removing them must be prov ded In the compass described, mathematical algorithms are used, in place of e'ectro-magnetic feedback via the compensation coil, to remove the measurement e f crs caused by perturbing external magnetic fields For use as a compass , two magnetoresistive sensors are required. The two S ens=,s are oriented orthogonal (, β. at 90= angles, .o each other. Their sens i t i ve d ,rec,,ons are oriented such that one measures the angle o. the sensor bridge r e,at e to the Earth's magnetic north pole. Because the other sensor ,s rot. ed 90, „ wa actually align ,.s sensitive direction to the Earth ' s magnetic f.e.d when , e corrpass ,s point i ng east The use of the two sensors gives enough i nformat i on to ano* .he ca,cu,a.,on. using trigonometric functions, of the angular orientat i on of the sensor relative lo the Earth ' s magnet i c f i eld Th,s descpt i on refers to the crcu- diagram, ore set of which is in the p ,ov,s,onal appl i cat i on , and another se, wh.ch is Figure. 3A. 3B. 3C and 3D . The specf i c implementat i on described proposes to use an Applica.ion-Speα-c , nl eg,a.ed Crcu,. (ASIC , though this is certa.nly no, the only feasible approach poss i ble There are also some ancillary circuits descr.bed which are app ca„on s ependen, and are not needed by, or suited to. every pos.b.e compass des.gr, The ,e are also some external elements, such as power suppl.es. that are no, shown . ,„ general me compass ,s implemented with r,.= rragnetores i st.ve sensors a .. a ,ged as deserved above some cond.t.cn.ng cc-.tr, and a m i crocomputer „ a compensat i on coil is used , as the current rows ,n .he compensat i on cc , ► . sensor output from the sensor changes Hew much , and ,n what director, th sensor output changes Spends on the magnitude and d„ec„on of the current ,n r. pensaln cc,. wh.ch i s directly contro.led by the PWM value ca'.culate. : 5 by the operating software program. An Intel 89C51 m i crocomputer core used to perform calculat i ons and the var i ous support c i rcuits required to implement a work i ng processor Random- Access-Memory (RAM) is provided for temporary read/wnte storage The Masked ROM (Read-Only-Memory) is used to store the software-operating program An 5 electπcally-Erasable-Read-Only-Memory is used for ncn-volat.le storage of data ( e g cal i brat i on i nformation, variation parameters, etc ) Th i s part i cular .mplementat i on also i ncludes circuitry to provide serial commun i cat i on w i th other computer devices The sensor outputs are flipped via currents prov ded by sw i tches Q1 and Q1 The sw i tch i ng rate and control signals for these switches are generated under software control by the microcontroller. As descr i bed above , two magnetoresistive sensors, one for north and one for ! s east are used to measure the oπentat.on of the compass w i th respect to the Earth ' s magnet i c f.eld The output of each sensor is relatively small voltage summed w i th error voltages caused by non-ideal operation of the sensor The set/reset mode of sensor operat i on separates the error and signal components The AC measurement s i gnal .s separated from the DC error voltage by use of a lew-pass - - Alter The cutoff frequency of the filter ,s set much leer than the fl pp.ng freq u ency so that the DC error i s separated The resulting DC error ,s fed back to an ampler , wh i ch performs the dual function of amplifying the AC measurement s i gnal a d by means of negat i ve feedback removing the DC error bias A second ampl.fler prov i des more s i gnal gain after the sensor error biases have been removed The same ampl i f i er/feedback circuitry is duplicated for each of the two sensors There is also a block used to generate a reference voltage, which is requ'red for use with a unipolar power supply. The conditioned output of the sensors is measured by means of an Analog- to-D:gιtal Converter (ADC) located in the microcontroller. This translates the analog voltage produced by the sensors into a digital value, which can be processed by the operat.ng software There is one ADC channel used for each of the two sensors, with an additional channel required to measure the re'erence voltage (the reference vo'tage is a consequence of practical operating considerations, some imp'ementations may not require its use) As described above, temperature compensation of the sensor output is accomplished by forcing the sensor output to zero, by means of the compensation coil. The microcomputer does this by Digital-to Analog (DAC) conversion of a digital value, computed by software, which is used to generate a current passed through the compensation coil. The circuitry in the provisional application illustrates the method by which this is done The d.gital va'ue determined by the software is input to a Pu'se -Width- Modulator (PWM), which generates a sequential digrtat wave'erm which has a duty cycle that is dependent on the digital input value A digital waveform can have only two states - on or off, the duty cycle is simply the ratO of the amount of time the waveform is switched on to the amount of time that the wave'orm is switched off By integrating the PWM output waveform with a suitable filter it is possible to produce an analog DC output voltage that is proportional to the duty cycle of the digital input signal The analog output voltage produced by the PWM and Alter is then used to generate a current in the compensation coil by means of the circuitry shown in Figure sensor. The PWM value is used as the raw data input to the mathematical 5 algorithms used by the program software to calculate the compass heading The software program, by means of injecting current into the compensation coil and then examining the sensor output via ASDC measurement can, by a process known as successive approximation, force the sensor output to become : : zero The value of the PWM required to achieve this null of the sensor output is then an indirect measure of the external field applied to the sensor. The PWM value is used as the raw data input to the mathematical algorithms used by the program software to calculate the compass heading. is Referring to the figure set of Figures 3A, 3B, 3C and 3D. an improved embodiment is shown In general the description above is applicable to this embodiment, which has differences which will be unde'stood by these skil'ed in the art. 2 : Figures 3A and 3B are a block diagram of the ccuitry Figure 3B be ng detail of the portion enclosed in the dashed lines 302 Referring to Figure 3C, items KMZ51 are the two magnetores stive sensors whose outputs VO- and VO+ are differential voltage output, which corresponds to 2 Ξ the angular position of the sensor within the magnetic field In Figure 3C. the outputs NOUT and EOUT are the north and east components, respectively of the head i ng vector The VREF output is output of the reference voltage for the ampl.f.er circuitry The i nput NPWM is from the microco n troller and is an input of a digital waveform whose duty cycle can be set under software control by the microcontroller The c i rc ui try following NPWM is a low pass f.lter that converts the digital waveform to an a-alog DC voltage, which is proportional to the duty cycle of the input wavefcm In addition the analog DC voltage is divided by two, the resulting voltage being used as a reference voltage The ADREF output goes to the micrccontroller and is used as the reference voltage for the ADC in the microcontroller Also the VREF is generated, which i s the ADREF d i v i ded by two and is used as a refe-ence voltage for all of the analog amplifiers in the circuit. HIDRIVE and LODRIVE are digital signals from the microcontroller to comp'ementary MOSFET switches They f p the polarity of the magnetores i st i ve sensors The flipping increases sensitivity c' the sensor and allows removal of DC biases F i gure 3D shows the microcontroller U 1 , which in this example is an INTEL 8051. where the program is stored It also cc-tains the PWM, the c i rcu i ts for the ser i al port , parallel input output circuits, random access data memory , and processor state clock circuits The microprocessor also provides the HIDRIVE and LODRIVE signals used to control the flipping circuit for the circuits. P1 is the power input and communication input/output connector. The circuitry is a five-volt voltage regu'ator to supply all of the voltage to the circuitry via VCC and VDD. U2 is an RS-485 transceiver to enable serial communication with external devices U3 is an EEROM used to provide non-volatile storage of the s calibration constants and operatirg parameters. There is also a switch (S1) for the operator to set various modes and for other control by the user ; INTEGRATED SYSTEM Figures 4A and 4B show a variation of the system as an integrated dead reckoning sensor system based on multiple sensors including GPS, magnetic compass, cross-track accelerometer, angular rate sensor and speed sensor. 5 Because of obscurations due to buildings or any physical structure, the abrT y to constantly track four or more GPS satellite signals cannot be guaranteed For this reason there is a strong des * e to develop a system that can p r ov de na .igat :- ability during short periods of GPS signal loss The GPS Fl whee! integrated concept and system solves this problem by providing an integrated system of sensors. The judicious choice of an array of low cost sensors provides high reliability at a low cost To this end, in the preferred implementation, three senses and one optional sensor are chesen to aid the GPS in providing a constant and accurate navigation solution. The low cost MR sensor compass described and a cross-track acce'erome'.er may be used to provide heading information A speed sensor is used to prov ' e rate information along the heading An angular rate sensor is a more expens ve but more accurate device that can be used in place of the cross-track accelerometer applications that require the improved accuracy. These sensors compliment each other well. The compass provides heading information but cannot provide any motion information. The speed sensor provides rate information but does not provide direction or heading information The cross-track accelerometer provdes a check to the compass heading as well as providing a second source of head n,g information - however, the accelerometer data must be integrated and applied to an already known heading These sensor inputs can be fed to a Kalman filter. The variances of the various sensors may be calculated and provided to the Kalman f rter in order to use the sensors optimally. Additionally, heuristic steps may be implemented prior to the incorporation of sensor input to the Kalman filter. Specifically, for example, the cross-track accelerometer can be used to detect unreasonable changes in heading provided by the compass in the presence of magnetic anomalies If the comparison of the cross-track accelerometer data and the compass heading information disagree by a selected predetermined threshc ' c the compass reading can be invalidated, rejected and will not influence the Kalm≤n filter output or calibration The system will operate in a calibration mode while the GPS quality is good Then when outages do occur, the calibrated outputs from the other sensors will provide a means for navigation. Calibration of the various sensors may be achieved as follows. • Cross Track Accelerometer Calibration The means of computing highly accurate velocity information from integrated GPS carrier phase cycles is well known A good estimate of acceleration may be accomplished by computing the rate change of this velocity The acceleration can be represented in a locally level - North aligned coordinate system. From the components of this acceleration, the component of acceleration that is not along the direction of travel can be calculated and directly differenced from the acceleration provided by the cross-track accelerometer This calibration term can be stored and used to aid navigation during GPS outages Also the calibrated accelerometer may be used to reject erroneous compass readings. • Speed Sensor Calibration Once again, the reliable GPS velocity information may be used to calibrate the speed sensor input. In this case the magnitude of the horizontal components of the GPS derived velocity is computed and compared to the speed sensor input A speed sensor calibration term may be easily computed as the d fference between the two speeds just mentioned A more precise method would be to store the biases at the various speeds and compute the slope of the bias as a function of speed. • Compass Calibration Again the GPS velocity information when in met on can be used to calibrate the compass heading Some heuristic algorithm and filtering techniques will need to be applied to ensure the calibration terms are generated only when the compass is providing typical heading information. That is, compass calibration should only occur in the absence of temporary magnetic anomalies To obtain the calibration, the locally level North aligned coordinate system should be used to make a direct comparison of the compass heading to the North and East components of the GPS velocity. Further of course, the calibration shou'd only occur when the magnitude of the GPS velocity (speed) is above a specified threshold. • Turn Rate Sensor Ca'ibration Again by the use of the accurate GPS velocity the turn rate sensor may be calibrated. In tms case, the GPS velocity is transformed into a locally level north aligned coordinate syste- The output of the turn rate sensor can be integrated to provide an angu'.a' displacement. The same displacement over the same time period may be calculated by the difference in the GPS velocity. The difference in the hs angular displacements is the calibration term for the rate sensor. One of the sensors, the magnetoresistive compass, has been described above Referring to F.gu'e 4A 402, 404 and 406 are the cress-track acce!erome:e- the angular rate sensor and the speed sensor interface, respectively The cross- track accelerometer is o' e.nted perpendicular to the track of the vehicle and is sensitive to accelerat.on perpendicular to the track of the ve cle It is used to measure acceleration due to centrifugal force as the vehicle turns In that capacc, it is used as a turn senscr to aid the jitter algorithm, which is aided in order to distinguish actual jitter f r om a transient magnetic anomaly frcm any similar effect (measurement vector movement) due to turning of the vehic ' e Since the vector changes due to turning might be otherwise seen as jitter, the accelerometer input will allow that to be disregarded as jitter, so that only jitter due to anomalies will be processed J i tter due to magnetic anomalies can be different i ated from measurement vector changes due to vehicle turn. The angular rate sensor develops a voltage output that is proportional to the rate of turn about its sensitive axis. In this case, the sensit i ve axis is mounted perpend i cular to the plane of travel of the vehicle, vertically. So , this measures how fast the veh i cle is turning , the angular rate of turn The output of the accelerometer is ampl i f i ed by the circuit 308 and its output is at ACCEL to the ADC i n the microcontroller as an analog voltage which is proportional to the cross-track accelerat i on and is then used by the software in the microcontroller. The magnetoresistive compass is north seeking. In the integrated dead reckon i ng solution , the angular rate sensor output will aid or substitute for the compass output when the compass is under the effect of transient anomalies. So when a transient anomaly is detected, such as by jitter detection, the system can we gh more heavily or rely entirely on the angular rate sensor to adjust heading. The a n gular rate sensor is initialized, as is normal in the i r appl i cat i on The output of the angular rate sensor is amplified by the c i rcu i t 410 and its output , RATE , to the ADC of the microcontroller is an analog voltage proport i onal to the angular rate The speed sensor interface takes velocity information from sensors , including but not limited to speed and direction The logic 412 decodes the information to provide the output DIRECTION and SPEED to a parallel I/O and then are made available to the microcontroller bins and used by the microcontroller Not shown on the figures, the GPS receiver is connected to the serial port of the microcontroller As shown in Figure 4B, all of the sensors are mtegrated to use each of them when most advantageous While there have been described above the principles of this invention in connection with specific embodiments, it is to be understood that this is by way of example and not limitation the scope of the invention APPENDIX "A" THE FOLLOWING LISTINGS ARE MPLARY SOFTWARE IMPLEMENTATION OF THE FOREGOING DISCUSSION Pa:i 1 COMPASS. C /• ilfndef HΣΩIUM_MODEL terror TARGET. C MUST BE COyjILED KITH MEDIUM MODEL (Use -Bm optlcr.) tendil */ #defιne GLOEALS_HERE ((include <xath.h> ((include <stdιo.h> ((include <stdlιb.h> ((include "ccnpass.h" •include "fit.h" ((include "params.h" ((include "serial. h" void main ivoid ) ( XDATA int bιn_headιng; XDATA chax bin; XDATA char binCounters [NBINS] ; XDATA int bmHeadmg; /* Test Jitter deJay */ XDATA char nxt; XDATA unsigned c ax i; /* Loop counter */ XDATA double radius; XDATA double mitialRadlus; XDATA double delta; XDATA double savex, savey; XDATA char checkedOffset=0; XDATA char s ip; XDATA int ne P MO; XDATA unsigned int Address; / address in eerom */ XDATA char *cptr; / character pointer for eero- read/writes */ BIT fιrs Acal=YES; /• »»»» P R O G R A M S T A «««« •/ PCON |= CxlO; //Enable watchdog headMsg. d=HEADMSG; headMsg.size = axxeof (DBMsg) ; SetVariation = OFF; Calibration = OFF; FιrstHeaαιng=YES; StartAutoCal=YES; StartedAD * NO; ValidAD = NO; Measuring = OFF; TestMode=CFF; InitI2C() ; EA = OFF; COMPASS. C Page 2 ImtTimerOO ; InitlUART ( ) ; //initpma ; EA » ON; TR3 » ON; T3=0; PCON 1= 0x10; //Keep watchdog alive /* Check to see if the switch was pressed at reset; if so, go to PC Mode */ if (!Plb3) ( while ('Plb3) ( T3=0; PCON 1= 0x10;) //Keep watchdog alive ES = OFF; /* senaJ port interrupt */ TI = SET; /* Transmit interrupt - but we poll so set '/ Plb2 = SET; / ♦ Control for 485 driver to x it - OFF to rx */ TH1 = -3; /* a-jd rate generator */ TL1 = -3; /• ditto ♦ / PCMode = ON; printf , (int ) SW_VER_BUILD, (int ) SW_VER_RΞLEASE1 ; 1 l:adFromEEROM() ; T3=0; PCON 1= 0x10; //Keep watchdog alive / TEST PCMODE ON '/ ES - OFF; /* serial port interrupt */ '/ TI - SET; /* Transmit interrupt - but we poll so set */ // Plb2 - SET; /* Control for 485 driver to xm t - OFF to rx •/ // TH1 - -3; /* baud rate generator */ // 3X1 - -3; /* ditto */ '/ PCMode = ON; ■'/ TestModeON; 'End TEST hd.ad] = adj; td.cal = cp.cal; hmHd.ad] = ad] ; binHd.cal = cp.cal; savex=cp . cal . x_o f set ; ∑avey=cp.cal . y_of fset; * Initialize smoothers '/ εnoothX. points = smoothY. points = XYFILTERPTS ; moothX. count = sirootπY. count = 0; εnoothX. index = smoothY. index = 0; saioothX.sum = smoothY. sum = 0.0; :ιtterPoιnts = ReadEER0M(EEROM_JITTER_POINTSl) ; naxJitter = ReadEEROM(EEROM_MAX_JITTERl) ; if (jitterPomts > MAX JITPOINTS) jltterPoιnts=N0MINA∑_JITPOINTS; /* Start smoothers - t burn 20 measurements to let compass settle after startup. '/ rieadMsg. ιd=DEBUGMSG; //Compute average initial radius mitialRadlus = 0.0; for (ι=0; KlO; ι++) ( T3=0; PCON |= 0x10; //Keep watchdog alive getMeas (imeas) ; meas. north -= meas.vref ; meas.east -= meas.vref; COMPASS. C Page 3 cp.x ■ meas. east; /» East */ cp.y » meas. north; /* North '/ smoothX.nextVal = (int) (cp.x + 0.5); smoothY . nextVal = (int) (cp.y + 0.5); mov mea ( ismoothX) ; mov_mean ( ismoothY) ; xjit(nxt) = cp.x; /* Fill up jitter points so they have »/ yjit[nxt++] = cp.y; /* reasonable start values */ nxt %= uitterPoints; if ( smoothX.nextVal > 128) headMsg.limitVal = 128; •lae if (smoothX.nextVal < -127) headMsg.limitVal = -127; •lie headMsg.limitVal = (char ) smoothX.nextVal ; /* Compute radius */ hd.inputx = smoothX.mean; hd. inpu y = smoothY. mean; headMsg. r.eadmg = get_headmg (Shd) ; headMsg. ghcstHeading = headMsg. heading; radius = sqr (hd.calx*hd.calx + hd.caly*hd.caly) ; mitialRadlus += radius; ) initialRadius /= 10.0; for (i=0; i<10; i++) ( T3=0; PCCN 1= 0x10; //Keep watchdog alive getMeas ( Smeas) ; meas. north -= meas.vref; meas. east -- meas.vref; cp.x = meas. east; /* East •/ cp.y = meas. north; /* North '/ smoothX.r.extVal = (int) (cp.x + 0.5); smoothY. r.extVal = (int) (cp.y + 0.5); mov_mean ( ismoothX) ; mov_roean ( & smoothY) ; xjit(nxt) = cp.x; /* FilJ up jitter points so they have */ yjittnxt-r+J = cp.y; /* reasonable start values */ nxt %= 3itterPomts; if ( smoothX.nextVal > 12B) headMsg. lim tVal = 128; •lae if (smoothX.nextVal < -127) headMsg.limitVal = -127; else headMsg.limitVal = (char ) smoothX.nextVal ; /* Compute S load radii '/ hd.inputx = smoothX.mean; hd.inputy = smoothY. mean; headMsg. heading - get heading I Shd) ; headMsg. ghostHead g = headMsg. heading; radius = sqrt (hd.calx*hd. calx + hd.caly*hd.caly) ; //Make sure radius is in the range 130 - 200 if (radius < 100 II radius > 200) ( /» Compute adjustment to PWM */ newPWMO = 5.0/PWM_STEP - (5.0 - (PWM0*P M_STEP) ) / ( (DESIRED_RADIUS/radιus) * PWM_STΪ?) ; if (radius <= 0) radius = 10; ~ •la* newPWMO = (DESIRED_RADIUS/radιus) * PWM0; if (newPWMO > 200 II headMsg. headmg==-l) PWM0 = 200; else if ( newPWMO == 0 ) PWM0 = 1; •lae PWM0 = (unsigned char ) newPWMO; //Short delay to allow meas to settle if PWM has been changed. for (SerιalTιcks=0; SerialTicks < 5;) i rawScale = radius/initialRadius; COMPASS.C Page 4 i wri te chksum */ i wri te chksum (copy) '/ headMsg. x = (int)cp.x; headMsg. y = (int) cp.y; headMsg. radius - (int) radius ; headMsg. bradius = 10+ (int ) mitialRadlus ; headMsg. dRadius = newPWMO; headMsg. ghostHeading = PWMO; headMsg. pointCc nt =(int) cp. cal . y_o fset; headMsg. heading = (int ) cp.cal .x_offset; // sendMsg l (char*) iheadMsg) ; ) headMsg. ιd=HEADMSG; /* Compute i load radii */ hd.inputx = smoothX.mean; hd. puty = smoothY.mean; headMsg. heading = get_headmg ( Shd) ; headMsg. ghostHeading = headMsg. heading; cp.cal. radius = sqrt (hd.calx'hd. calx + hd. caly*hd.caly) ; hd. cal. radius = cp.cal. radius ; headMsg. radius = (ιnt) (cp.cal. radius) ; binHd. cal. radius = cp.cal. radius; headMsg. bradius = (int ) (cp.cal . radius) ; /• «<«« MAIN Processing Loop >>>>>>>> */ for (;;) I T3=0; PCON 1= jχlO;/ΛKeep u-atchdog alive /* Check for COMM input i f we are m PC Mode */ if (RI SS PCMcde SS ISendData) chkComlnpu (x 3 ιt, y}it) ; /* check for swi tch inputs '/ CheckSwitchO ; if (SetVariation) ( SetVariation = OFF; ad 3 . variation = (float )( (char ) ReadEEROM(EEROM_VARl+Zone) ) ; hd.ad] •» adj; binHd. ad] = ad 3 ; WrιteEEROM(EEROM_ZONEl, Zone); WrιteEEromChkSum(EEROM_STARTl) ; /* Recompute 4 write chJcsum */ /* Make a second copy */ WrιteEEROM!EEROM_ZONE2, Zone); WriteEEromChkSu TEEROM START2); /• Recompute i wri te chksum '/ ) /* Get filtered AD Measurements V headMsg. lιmιtVal=0; / » All clear - debug '/ getMeas ( meas) ; meas . north -= meas . vref ; meas . east -= meas . vref ; /* scale measurements by the difference between the calibration PWM and the current PWM •/ :OMPASS.C Page 5 meas. north *= rawScale; meas. east *= rawScale; cp.x *■ meas. east; cp.y ■ meas. north; xjit(nxt) = cp.x; yjit[nxt++] = cp.y; nxt %= jitterPoints; if (Calibration) ( cp . x /= rawScale; cp . y /= rawScale ; manualCal ( sheadMsg) ; rawScale = 1.0; ) •Is* ( skip = wildEdit d ; /* XicJt out uid da ta */ /* Perform Auto Calibra tion '/ if (StartAutoCal ) /* Starting New auto calibration */ < for ( i=0 ; i<21 ; i++ ) cp . r [ ι ] =0.0 ; cp. pts=0; headMsg .poιntCount=0 ; StartAutoCal=NO; checkedOffset=0; for (ι=0;i<NBINS; i++) binCounters [i]=0; I hd.inputx = smoothX.mean; hd.inputy = smoothY. mean; binHd. mputx = cp.x; binHd. inputy = cp.y; headMsg. heading = get_headιng (Shd) ; bm_headιng = get heading (SbmHd) ; headMsg. ghostHeading = bιn_headιng; if ( !skιp ) ( radius = sqrt (binHd. calx*binHd. calx + binHd. caly*bmHd. caly) ; delta = cp.cal. radius - radius; headMsg. dRadιus= (in ) delta ; headMsg. radιus= (int ) (cp.cal. radius) ; if (fabs(delta) > 0.3*cp. cal .radius TawScale) ( /* shift the offset •/ binHd. cal. _offset -= delta * binHd. calx/radius; binHd. cal .y_offset -= delta * binHd. caly/radius; /* Compute new heading wi th new x i y offset . */ bιn_headιng = get_headιng ( binHd) ; radius = sqrt (binHd. calx*bιnHd. calx + binHd. caly*bιnHd. caly) ; /* sanity check- on newly computed radius */ if ( fabs (radius-cp. cal. radius) > 0.5*cp. cal . radius ) I binHd.cal.x_offset = cp.cal .x_offset; /* Reset x i y offset */ binHd.cal.y_offset = cp.cal .y_o£ set; binHd. cal. radius = cp. cal . radius; headMsg . lιmιtVal+=3 ; StartAutoCal=YES ; ) •Is* I :OMPASS.C Pare 6 binHd. cal. radius = radius ; headMsg.bradius = (int) radius; 1 headMsg.limitVal += 10; if (fabs(delta) > 0.75*cp. cal . radius) ( StartAutoCal=YES; headMsg.limitVal += 9; ) )/* End if delta> 0.4*radιus */ /* Track the regions where we have gotten data. */ /* Use raw (unfiltered) data for this computation */ binHd. mputx = cp.x; b Hd. puty = cp.y; bιnHeadmg= get_headιng (sbinHd) ; bin = (int)( binHeading/BINSIZE) ; if ( bmCounterstbin] < MAX_SAMPLE_COUNT) ( + +bmCounters [bin] ; cp.x /= rawScale; cp.y /= rawScale; addToCal (Scp) ; /* Only allow max_sample_count data points per bm */ 1 if ( binCounters (bin) ■== 1 ) ++headMsg . pointCoun ; )/* End if not skiped */ /* After collecting each additional 25* of the points check the validity */ if ( (headMsg. pomtCount% nt ) (NBINS*0.25)==0) SS checkedO f set '= headMsg. pointCount ) I checkedOf fset=headMsg . pointCount; savex -= binHd.cal.x_offset; savey -= binHd. cal. y_o fset; radius = sqrtt savex'savex + savey*savey) ; if (radius > 0.75*bmHd. cal. radius ) ( StartAutoCal=YES; savex = binHd. cal . x_offset; savey = bmHd. cal . y_offset ; headMsg.limitVal += 30; ) else I savex += binHd. cal . x_off set; savey += b Hd. cal. y_offset; 1 ) if (headMsg.poιntCount>=NBINS) ( T3=0; PCON |= 0x10; //Keep watchdog alive calibrate (Scp) ; rawScale = 1.0; T3=0; PCON |= 0x10; //Keep watchdog alive hd.inputx = smoothX.mean; hd.inputy = smoothY. mean; hd.ad 3 = ad]; hd.cal = cp.cal; b Hd. mputx = smoothX.mean; COMPASS. C Page 7 binHd. inputy = smoothY.mean; binHd. ad] = adj; binHd. cal = cp.cal; headMsg. heading = get_headιng(4hd) ; cp.cal. radius = sqrt (hd.calx*hd. calx + hd.caly*hd.caly) ; hd. cal. radius = cp.cal. radius ; headMsg. radius = (int ) (cp.cal. radius) ; heaαMsg. bradius = (in ) (cp.cal. racius) ; if ( firstAcal ) f fιrstAcal=NO; /* Wri te calibration da ta to EEROM */ cptr = (char *) Sep. cal; Address = EER0M_CAL1; for (l = 0; l < aneof (cp.cal); ++ι , ++Address ) WriteEERO (Address, (unsigned char ) * (cptr+i) ) ; WriteEEROM ( EEROM_CAL_PWM01 , PWMO ) ; WnteEEROM(EEROM_PWM01, PWMO); WrιteEEromChkSum(EEROM_STARTl) ; /• Recompute i wri te chksum '/ /* Make a second copy */ cptr = (char *) ep. cal; Address = EEROM_CAL2; for (l = 0; l < aiϊβof (cp.cal); ++ι, ++Address) WriteEEROM (Address, (unsigned cha ) * (cptr+i) ) ; WriteEEROM (EEROM_CAL_PWM02, PWMO) ; WriteEEROM (EEROM_PWM02, PWMO) ; WrιteEEromChkSum(EEROM_START2) ; /* Recompute i wri te chksum */ ) savex=cp.cal . x_of set; savey=cp.cal.y_offset; StartAutoCal=YES; /* Immediately begin autocal */ ) Heading = lunaigned char ) (headMsg .heading/1.5) ; headMsg. x = (int ) cp.x; headMsg. y = (ιnt)cp.y; headMsg. dRadius = MsgSkipCount; if (PCMode) ( sendMsg ( (char * ) headMsg ) ; //this routine wi ll cl ear MsgSkipCoun t i f requested to out put data if ( ( ++MsgSkιpCount > 250) &S 'TestMode ) //Assume PC is di sconnected and leave PCMo de 1 PCMode=OFF; ImtlUARTO I MsgSkipCount = 0; ) ) ) ) /* End forever loop */ )/* End compass ma n routine */ CHKCOKIN.C ((include "coπpass.h" ((include "serial. h" ((include -fit.h" void chkCc lr.put (int xjitl], int y]it[) ) { unsigned char ch; unsigned char abyte; char r.xt=0; char i; unaigned int Address; /'address m eerom */ char *cptr; /"character pointer for eerom read 'writes '/ ch=getch() ; if (ch=='a") ( if ( B EEROMO ) /' If a write occurred '/ I + Zcne) ) ; cptr = (char *) S (cp.cal); Address = EEROM_CALl; for (ι=0; l < aixeof (cp.cal) ; ++ι, ++Address) *(cptr++) = ReadEERO (Address ) ; WrιteEEromChkSum(EEROM_STARTl) ; /* Put a cή*sum at the end of this block •/ /* Make a copy of the first block '/ for (1=0; KEEROM_ENDl; ι++) I abyte=ReadEEROM(EEROM_STARTl + ι) ; WriteEEROM ( (unsigned char ) (EEROM START2+1 ), abyte ; ) /* Jitter points may have changed. */ for (ι=0; K]itterPoιnts; ι++) I x]it(nxt) = cp.x; /• F ll up jitter poirts so they have •/ y]lt[nxt++) = cp.y; / « reasonable start values */ nxt t= ]itterPoιnts; ) ) I •slae if (ctv^'b 1 ) Calibration = ON; else if (ch=='R') I SendData=YES; ) •lie if (ch=='Q') //Quit PC Mode I ch=bgetch ( ) ; if (ch=='N') //Normal Quit ( :HKCOMIN.C Page 2 PCMode=OFF; TestMode=OFF; InitlUARTO; I else if (ch=='T'l //Go into test mode I bus_xr.it (6) ; TestMcde=ON; EELOAD.C Page 1 ((include "compass.h" -include "fit.h" //void loadFrcmEEROMf MRcal 'cal, Lad *adj ) void loadFromEEROMI ) ( unsigned char 1; /'Loop counter '/ unsigned int Address; /*address m eerom */ «■«» ■ *cptr; /'character pointer for eerom read/writes '/ unsigned char ch ; /• Write m Sotf-are version - If it is different than the previous, this will cause a checksum fail, which is desired. '/ WriteEEROM (EERCM SW_VER1 , SW_VER_BUILD) ; WriteEEROM (EERCM~SW VER_BUILD1, SW_VER_RELEASΞ) ; WriteEEROM (EERCM~SW~VER2, SW VER_BUILD) ; WriteEERO (EERCM~SW~VER_BUI D2, SW_VER_RELEASE) ; /• If EEPOM has been previously written - read out the saved para.-eters */ if ( EEromChkS '_.-.( EEROM START 1) == 0) ( cptr = (char •' S (cp.cal); Address = EE?0M_CAL1; for (1 = 0; l < sneof (cp.cal); ++ι, ++Adαress) *(cptr++) = ReadEEROM (Address) ; ad] .mount bias = (float ) ( (char ) (ReadEERO (EEROM_MBIASl) ) ) ; Zone = ReadEERO ( EEROM_ZONEl ) ; ad]. variation = (float ) ( (char ) ReadEEROM(EEROM_VARl +Zone) ) ; PWMO = ReadEEROM (EEROM_PWM01 ) ; calPWM = ReadEEROM ( EEROM_CAL_PWM01 ) ; 1 /* EErom copy 1 failed try the second copy '/ else if ( EEro:rChkSum(EEROM START2) == 0) { cptr = (char ♦ ) S (cp.cal); Address = EERCM_CA 2; for (1 = 0; l < sizeof (cp.cal); ++ι , ++Address) ♦ (cptr++» = ReadEEROM 'Address) ; ad].mount bias = (float ) ( (char ) (ReadEEROM ΕEROM_MBIAS2) ) ) ; Zone = ReacEEROM (EEROM_ZCNE2) ; ad], vanaticn =ιfloat ) ( (char ) ReadEEROM (EEROM VARl +Zone) ) ; PWMO = ReadEEROM (EEROM_FWM02) ; calPWM = ReadEEROM ( EEROM_CAL_PWM02 ) ; /» Copy 1 rust have failed put this 2nd copy into the first '/ for (ι=0; KEER0M_END1; ι++) ( ch=ReadEΞROM ( EEROM_START2+l) ; WriteEEROM! (unsigned char ) (EEROM STARTl+i) ,ch) ; 1 ! else / » JBoth copies failed use hard coded values '/ ( /* load default values */ cp.cal .x_cf set = 0; cp.cal.y_of fset = 0; cp.cal.omf = 0.9; cp.cal. cost = 0.9; cp.cal.s t = 0.1; cp.cal. radius = 150.0; ad]. mount bias = 0.0; EELOAD.C a- e adj .variation = 0.0; PWMO = 128; /• radius - 150 V calPWM = PWMO; Zone » β; /* Write calibration data to EEROM •/ cptr = (char *) (cp.cal); Address = EEROM_CALl; for (ι = 0; l < aizeof (cp) ; ++ι, ++Address) WriteEEROM (Address, (unsigned char ) * (cptr+i) ) ; /* Write m a default mounting bias of 0 '/ WriteEEROM (EER0M_MBIAS1, 0) ; /» Write default variation values for each of the 15 zones There are actually 16 storage locations - position 0 is not used put a reasonable value there - just cuz. */ for (i=0; ι<16; ι++) WriteEEROM) (unsigned char ) ( EER0M_VAR1 +ι ) , (char ) (32- ( 1 *4) ) ) ; /* Write m Default zone '/ WriteEERO ( EEROM_ZONEl , Zone ) ; /* Write in default jitter values */ WriteEEROM (EEROM_JITTER_POINTΞl, NOMINAL_JITPOINTS) ; WriteEERO (EER0M_MAX_JITTER1, MAX_JITTER) ; /* Write m Software version '/ WriteEERO (EEROM_SW_VERl, SW_VER_BUILD) ; WriteEEROM (EEROM_SW_VER_BUILDl, SW_VER_RELEASE) ; WnteEEromChkSum(EEROM_STARTl) ; /* Put a chksum at the end of this block */ /* Make a copy of the first block * / for(i=0; KEEROM_ENDl; 1++) I ch=ReadEEROM(EEROM_STARTl+l) ; WriteEEROM! (unsigned char ) (EEROM_START2+ι) ,ch) ; ) )/* End else both copies failed '/ )/* End module '/ EEROM. C Page 1 /................................................... EEROM. C Code for m- ircuit programming of the EEROM. ♦.„.,.„»..../ /• #mcJude <stdlib.h> imclυ e <stdια.h> '/ ((include "cc=pass.h" #ιnclude "serial. h" Kdef e DEIAY_VALUE 60 char BιnEERCM(void) I unsigned char command; unsigned char addr; unsigned char Data; char writeOccurred; wrιteOcc-rred=NO; for ( ; ; ) ( /* Read a 3 byte binary message from the serial port Read z-.e first byte of a three byte message to detenτir.e r/w '/ comma.-.d = bgetch ( ) ; /* Read the second byte to get the address */ addr = bgetc () ; /* Read the data byte which may be ignored but will always be sent '/ Data = bgetch () ; if ( ccmmand== ' w ' ) ( WriteEEROM (addr, Data) ; wπteOccurred=YES; bus_xmιt(DELAY_VALUE) ; p ch('d'); /* crude handshake - d for done */ b s_rx ( ) ; I else if (command==' r ' ) ( bLS_xmιt(DELAY_VALUE) ; p'-tch ( ' r ' ) ; p'.tch (addr) ; Data = ReadEEROM ( addr ) ; / ■ report bade the data retrieved '/ putch(Data) ; b.s_rx(); ) /* else if (command" 'q' ) '/ •lee { // PCON I- 0x10; /* Re-enable watchdog '/ return writeOccurred; ) 1 1 void WriteϊEromChkSum (unsigned char copy) I unsigned char Address ; unsigned char *cptr; int Sum; unsigned int i ; IEROM.C P ςe i Address = copy; Sum » 0; for (i=0; ι<ΞEPCM_DATASZ; i++) Sum += ReadEEROM (Address++) ; Sum = -Sum + 1; /* Write in t.-.e negated sum + 1 ==> Valid checksum - -1 - so all zero's won't pass */ cptr = (unsigned char *) SSum; if (copy == ΞEF0M_START1) Address = EER0M_CKSUM1 ; else Address = EER0M_CKSUM2 ; for (1=0; Ksizeof (int ) ; ι++) WnteEE-OMI unsigned char ) (Address+ ) , * (cptr + l) ); ) int EEromChkΞ-—- (unsigned char copy) I unsigned char Address; int Sum; int ChkSu ; unsigned nt i ; char *cptr; Address = copy; Sum » 0; for (i=0; KEEROM_DATASZ; i++) Sum += ?eadEEROM(Address++) ; if (copy = EΞR0M_START1) Address = EER0M_CKSUM1 ; else Aαdress = EEROM_CKSUM2 ; cptr = (char ♦ ) schkSum; for (1=0; Ksueof (int ) ; ι++) *(cptr->— ) = ReadEEROM (Address++ ) ; /* T'e val-e stored n the checksum location is -sum+l so thai Sum+chJSum= Sum » (- S.m) + 1 = 1; Subtract 1 to return zero for a good c.-x≤um. */ return S r + ChkSu - 1; MANCAL.C Page 1 ((include "compass. h" void anualCal (DBMsg *headMsg) ( XDATA int Firstx, Firsty; XDATA unsigned int Address; /* address m eerom */ XDATA char *cptr; /* character pointer for eerom read/writes */ XDATA double savex, savey; XDATA int i; atatio BIT FιrstPass=ON; atatio BIT LookForStartxy=NO; atatio BIT BackToStart=NO; atatio BIT Done«NO; atatio XDATA int count=MAX_SKIP; static XDATA DBMsg calMsg; BIT sk p; calMs . ιd=CALMSG ; calMsg.size = ai2eof (DBMsg); calMsg. l πutVal = 0; /* Ail clear - debug '/ if ( ( fabs (cp.x-smoothX.meanXlOO) SS (fabs (cp.y-smoothY.meanXlOO) I I count > MAX SKIP) I if (count > MAX_SKIP) /• Reset smoothers */ ( smoothX. count = smoothY. count = 0; smoothX. index = smoothY. index = 0; smoothX.sum = smoothY. sum = 0.0; I smoothX.nextVal = (int) (cp.x + 0.5); smoothY. nextVal = (int) (cp.y + 0.5); mov_mean ( ssmoothX) ; mov_mean ( ssmoothY) ; count=0; skιp=NO; ) else ( calMsg. limitVal += 20; /* Units of 20 indicate this occured '/ skιp=YES; ) ++count; if (FirstPass) { Done=NO; calMsg . pointCount=0; calMsg. radιus=0; calMsg.dRadiusO; for (ι=0; i<21; i++) cp.r[ι)=0.0; cp.pts=0; /* Get two measurements in a row which are close together to ensure we don't start with a wild point. Also toss the first 20 points to let the compass settle after pressing the manual cal button. */ 1-0; do ( T3=0; PCON 1= 0x10; //Keep watchdog alive getMeas (Smeas) ; /* Get filtered AD Measurements '/ meas. north -= meas.vref; meas. east -= meas.vref; 'ANCAL.C Pace 2 if (fabs (cp.x-meas. east) <20.0 SS fabs (cp. y-meas.north)<20) Done=YES; cp.x ■ meas. east; cp.y = meas. north; ++i; /* count measurements */ (while (' Done SS ι<20) ; Fιrstx=(int) cp.x; Fιrsty=(int ) cp.y; FιrstPass=NO; LookForStartxy=NO; BackToStart=NO; I if (calMsg. pointCount <= MAXPOINTS) ++calMsg. pointCount; if ( (fabs(cp.x-Fιrstx)>40.0) it (f abs (cp. y-Firsty) >40.0) ) LookForStartxy=YES; if (LookForStartxy) ( if ( (fabs (cp.x-Fιrstx)<30.0) ss ( abs (cp. -Fιrsty)<30.0) ) BackToStart=YES; ) if (BackToStart && (calMsg. poιntCount>SUFFICIENT_POINTS) I I (calMsg. pointCount >= MAXPOINTS) ) ( /* We are done collecting points for calibration - Compute calibration parameters */ T3=0; PCON |= 0x10; //Keep watchdog alive calibrate (Scp) ; T3=0; PCON 1= 0x10; //Keep watchdog alive hd.ad] = ad]; hd.cal = cp.cal; // bmHd. cal = cp.cal; hd.inputx = smoothX.mean; hd.inputy = smoothY. mean; headMsg->headmg = get_headιng ( hd) ; headMsg->ghostHeadιng = headMsg->headmg; cp.cal. radius = sqrt (hd. calx'hd. calx + hd. caly*hd. caly) ; headMsg->radιus = (int ) ( cp.cal. radius) ; calMsg. radius = (int ) (cp.cal. radius ) ; headMsg->bradιus = (int ) (cp.cal. radius ) ; calMsg. radius = (int ) (cp.cal. radius) ; savex=cp . cal . x_of f set ; savey=cp . cal . y_o set; /* Write calibration data to EEROM */ cptr = (char *) Scp. cal; Address = EER0M_CAL1; for (1 = 0; i < sizeof (cp.cal); ++ι, ++Address) WriteEEROM (Address, (unsigned char ) * (cptr+i) ) ; WriteEEROM (EEROM_CAL_PWM01, PWMO) ; WriteEEROM (EEROM_PWM01, PWMO) ; WrιteEEromChkSum(EEROM_STARTl) ; /* Recompute i write chksum '/ /* Make a second copy */ cptr = (char *) Scp. cal; Address = EEROM_CAL2; for (l » 0; i < sizeof (cp.cal); ++ι, ++Address ) WriteEEROM (Address, (unsigned char ) * (cptr+i) ) ; ANCAL.C Page 3 WrιteEEROM(EEROM_CAL PWM02, PWMO) ; WriteEEROM (EEROM_PWM02, PWMO); WrιteEEromChkSum(EEROM_START2) ; /* Recompute t write chksum '/ Calibration = OFF; calMsg.pointCount « 0; FιrstPass=YES; FιrstHeadιng=YES; StartAutoCal=YES; ) else I /* Add every other point to the calibra tion matrix '/ if ( (calMsg. pointCount *2 == 0) ss 'skip) addToCal (Scp! ; if ( fabslcp.yXEPSILON ) ( if ( cp.x>0 ) calMsg. heading = 90; else calMsg. heading = 270; ) else calMsg. heading = (int ) (k]atan2 (cp. x, cp. y) *R2DG) ; if (calMsg. head g<0) calMsg. heading += 360; calMsg. ghostHeading = calMsg. heading; /* Set the global "Heading" so it is available to the display during cal */ Heading = (unsigned char) (calMsg. heading/1.5) ; calMsg. x = (int) cp.x; calMsg. y = (int) cp.y; if (PCMode) sendMsg ( (char * ) ScalMsg ); )/* End else we are still collecting points */ ATHCCMP.C Page ((include <math.h> ((include "fit.h" /* // void solve ( float r[] , float xll, short n, short npts ); // // r IS THE INPUT SRIF VECTOR STORED MATRIX // THE VECTOR STORE IS BY ROW RATHER THAN BIERMAN COLVMN // THE R MATRIX IS LEFT UNDISTURBED. // n IS THE TOTAL NUMBER OF PARAMETERS WHICH CAN BE SOLVED // X IS THE SOLUTION VECTOR -- NUMBERED TOP DOWN (i LEFT TO RIGHT) // npts IS THE NUMBER OF MEASUREMENTS -- USED IN COMPUTING A^S // */ void solve! float r[], float x[), short n, ahort npts) ( float temp, f; char n ; char ]t, ]i, ]c, ]m, ]v, kc; char j,k; nt=n+l; jt=n* (nt+2)/2; ]i-]t; f = npts; if (npts>l) f = 1.0/sqrt(f) ; x[nt-l) = r[]t-l]*f; for (]=1; ]<=n; j++) ( ]c = nt-]; ]m = j-1; ]v = ]i-]* (]m+2)/2; temp = r (]v+l-l] ; if ( ]m >= 1) { for (k=l; k<=]m; k++) I kc = nt-k; temp = temp-r[]v-l)*x[kc-l) ; — ]v; ) ) x[jc-l] = 0.0; if ( (j>0) ss (r[]v-l] '= 0.0) ) x[jc-l] = temp/r(]v-l); ) /* // void thhrl (float r[l, float al], short n) // 1 2 3 4 // 28 OCT 1985 - FILED AS THHR1 5 6 7 // 8 9 // 10 // THIS SUBROUTINE COMBINES A MEASUREMENT VECTOR INTO A TRIANGULAR // VECTOR STORED MATRIX BY USING A HOUSEHOLDER TRJKNS FORMATION. // // R((N+1)' (N+2)/2) VECTOR STORED SQUARE ROOT INFORMATION MATRIX // LAST LOCATION IS THE RSS OF THE RESIDUALS. THE // N LOCATIONS PRECEEDING THE RSS CONTAIN THE REDUCED 01 MATHCOMP.C Pace 2 // MEASUREMENTS. // N NUMBER OF PARAMETERS // LN LAST PARAMETER OF MEAS. TO BE PROCESSED. (N USUAL) // M NUMBER OF SOLUTION VECTORS // IM LAST SOLUTION VECTOR TO BE PROCESSED (M USUAL) // A(N*M) MEASUREMENT VECTOR // // ON ENTRY R CONTAINS A PRIORI SQUARE ROOT INFORMATION FILTER (SRIF) // ARRAY, AND ON EXIT IT CONTAINS THE A POSTERIORI ARRAY. // ON ENTRY A CONTAINS AN OBSERVATION. PORTION PROCESSED IS ZERO // ON EXIT EXCEPT THE LAST ELEMENT RETAINS THE RESIDUAL. // // ROUTINE IS FROM BZERMAN PUBLICATIONS - MODIFIED BY HATCH // FOR A SINGLE MEASUREMENT VECTOR. COMPARE WITH THH. // STORAGE MODIFIED TO STORE BY ROW RATHER THAN COLUMN. // Modified by K. Judge to assume N=LN, and M=LM=1, thus eliminating // parameters LN, M and LM; // '/ void thhrl( float *r, float *a, short n) { char ]], lend; char ]p; char ] , k ; float gl, g2, r], rk; 31 - l; lend = n+1; for (]=1; ]<=lend; ]++> I if (a[]-l) '=0.0) ( DP = 3 + l; if (r[]j-l) '= 0.0) ( n = r[]j-U ; r(]j-l) = sqrt! a[]-lj*a[ j-1) + rj*r] ) ; if (]<=n) I gl = r]/r(]]-l); g2 = a[j-l)/r[]j-l] ; a(j-l) = O.O; for (k=]p; k<=n+l; k++) ( rk = gl*r[jj-l) + g2*a[k-l) ; a[k-l] = g2*r[jj-l] - gl*a(k-l) ; rtjj-1] ■ rk; 1 ) )/• end if r[jj] .'- 0.0 */ ( rtjj-1) = a[j-l]; i <3<=n) I a[ -l] = 0.0; for (k=]p; k<=n+l; k++) I ++jj; rk = a|k-l]; atk-1] = r[]j-l); r[jj-l)= rk; VΓHCOMP.C Page 3 ) ) I/* End else rljjl—0.0 */ )/* End if a I j] 1-0.0 '/ •la* jj += n+1 - j; )/* end j loop */ I WILDEDIT.C Page 1 ((include <stdlib.h> •include "compass.h" BIT xRailed; BIT yRailed; char wildEdit(void) ( static int count=MAX_SKIP; X3ATA char 1; XΞATA char s ip; X3ATA char accept; XCATA int diffx; X2ATA int diffy; if ( (fabs (cp.x-smoothX. mean) <0.5*cp. cal . radius) ss (fabs(cp.y-smoothY.mean)<0.5*cp. cal. radius) II count > MAX_SKIP) I /» Don't accept Jittery or railed data Test for these conditions. '/ accept=YES; /* accept by default '/ if (]itterPoιnts>3) xRaιled=YES; /* Railed by default f >3 points required in '/ yRaιled=YES; /• the jitter test. */ •lae xRaιled=NO; /* Cannot conduct a railed test if 3 or '/ yRaιled=NO; /* fewer points required for itter test '/ for (ι=l; K]itterPoιnts ss accept; ι++) diffx = x]it[ι)-xjιt[ι-l] ; diffy = y]it[ι]-y]it[i-l]; if ( (abs (diffx) >maxJltter) I I (abs (diffy) >maxJιtter) ) accept=NO; /* Too much itter - don't accept '/ /* See if the x or y inputs are railed '/ if ( abs(X ] it[ι] )>400 ) ( if (x]it[ι)-x]it[ι-l) '= 0 ) xRaιled=NO; /* Wot railed if there is movement '/ ) •lae xRaιled=NO; /* Wot large enough to be considered railed */ if ( abs(y3it[i))>400 ) ( if (y3it[ι]-yjιt[ι-l] '- 0 ) yRaιled=NO; /* Wot railed if there is movement '/ ) •lae yRaιled=NO; /* Wot large enough to be considered railed */ ) if (xRailed | | yRailed) { skιp=YES; /' X or Y input is railed - skip the data '/ headMsg.limitVal +=7; /* Indicate railed data m msg. '/ ) •la* skip-NO; /* Not railed - don't skip it */ if ( (accept==YES) S (skιp==NO) ) WILDEDIT.C Page 2 ( if (count > MAX_SKIP) / » Reset smoothers */ I smoothX. count = smoothY. count = 0; smoothX. index = smoothY. index •» 0; smoothX. sum = smoothY. sum = 0.0; I smoothX.nextVal = (int) (cp.x + 0.5); smoothY.nextVal = (int) (cp.y + 0.5); mov_mean( smoothX) ; mov_mean ( smoothY) ; count=0; ) •lae headMsg.limitVal +=5; /* Data not accepted (or skipped) */ ) •la* /* new point is way outside of mean '/ ( headMsg.limitVal += 20; /* Units of 20 indicate this */ if (]itterPoιnts>3) /* point is way outside of the mean '/ xRaιled=YES; yRaιled=YES; •la* xRaιled=NO; yRaιled=NO; for (ι=l; K]itterPoιnts; i++) /* See if the x or y inputs are railed '/ if( abs(x]it[ι])>400 ) I if (xjιt[ι]-x]it[ι-l] '= 0 ) xRaιled=NO; I •lae xRaιled=NO; if( abs(y]it(ι] )>400 ) ( if (y]it[ι]-y3it(ι-l) '= 0 ) yRaιled=NO; ) •lae yRaιled=NO; )/* End for each jitter point */ if (xRailed I I yRailed) ( skip=YES; headMsg.limitVal +=7; ) •lae skip«NO; )/* End f point s way outside of the mean */ ++count; return skip; IADING.C Page 1 ((include <math.h> ((include "fit.h" ((include "params.h" float k ] atan2 (float x, float y) ; int get heading ( HeadPararas *hd ) I float xrot, yrot; /* x and y bias removed and rotated */ float heading; /* return value '/ /* Remove x and y bias '/ hd->calx = hd->ιnputx - hd->cal.x_of fset; hd->caly = hd->mputy - hd->cal . y_of fset; /* rotate so that y points at semi minor and amplify '/ xrot = hd->cal.ccst * hd->calx - hd->cal.sιnt * hd->caly; yrot = (hd->cal.smt * hd->calx + hd->cal.cost * hd->caly)/ hd->cal.omf ; /* rotate back to tne original direction '/ hd->calx = hd->cal.cost * xrot + hd->cal.sιnt * yrot; hd->caly = hd->cal.cost * yrot - hd->cal.s nt * xrot; /* Jf y s close to zero assign heading appropriately. '/ if ( fabs(hd->caly)<EPSILON ) ( if ( hd->calx>0 ) /* North ( zero degrees + biases ) '/ heading = 90- (hd->ad] .mount bias + hd->ad] .variation) ; •la* /• South ( 180 degrees + biases ) '/ heading = 270 - (hd->ad] .mount_bιas + hd->ad] .variation) ; ) •lae heading = k]atan2 (hd->calx, hd->caly) *R2DG + (hd->ad] .mount_bιas + hd->ad] .variation) if (headιng<0) heading += 360; return (int ) heading; CALIBRAT.C ((include <math.h> ((include <stdlιb.h> ((include <stdιo.h> ((include "typedefs.h" ((include "fit.h" ((include "params.h" /* Prototypes */ void thhrl (float r[J, float a[], ahort n) ; void solve! float r[], float x[), ahort n, short npts); void addToCal! CalParams *cp ) I XDATA float am [6] ; am(0) = l; am[l] = cp->y * cp->y; am[2) = cp->x * cp->y; am[3] = cp->x; am[ 4] = cp->y; am[5] = cp->x * cp->x thhrl (cp->r, am, 5) ; if ( cp->pts < MAX_SAMPLE_COUNT ) ++cp->pts; void calibrate (CalParams *cp) ( XDATA float tl, t2, t3; /* Temporary values XDATA float e2; /' Eccentricity sqυa: XDATA float cos2t, sιn2t; /' Cosine and Sine ot solve (cp->r, cp->xm, 5, cp->pts); /• Compute Calibration parameters '/ tl = 1.0 - cp->xra(l] ; t2 = cp->xm[2] *cp->xm(2] ; t3 = 4.0 * tl - t2; cp->cal.x offset = (2.0* l*cp->xm( 3] + cp->xm[ 2) *cp->xm[ • cp->cai.y~offset = (2.0*cp->xm[ 4 ) + cp->xm[2] *cp->xm[3) ) tl = sqrt (cp->xm[l) *cp->xm[l) + t2 ) ; e2 = 1.0/(1.0 + 0.5* ( tl-cp->xm( 1] ) ); e2 = e 2 * tl; cp->cal.omf = sqrt (1.0 - e2); cos2t = -cp->xm[l]/tl; sιn2t = -cp->xm[2]/tl; cp->cal.cost = sqrt(0.S + 0.5*cos2t); cp->cal.sιnt = 0.5 * sιn2t/cp->cal . cost; /* void lnitcal ( CalParams 'cp ) I mt I; for (ι=0;ι<21;ι + + ) cp->r[ι) » 0.0; cp->ptsO; o/ ETMEAS.C Page 1 ((include "compass. h" void getMeasl MeasParams *mp) I unsigned int Result; StartedAD = NO; ValidAD = NO; Measuring = ON; /* wait for a valid measurement '/ while ( ! ValidAD) ; /* All three measurements are now available pick 'em off one at a time '/ Result = (unsigned int)ADRSL0; Result 1= ((unsigned int)(ADRSH) « 8); Result S= 0x3FF; mp->vref = (int) esult; Result = (unsigned int)ADRSLl; Result 1= ((unsigned intl (ADRSH) « 8); Result S= 0x3FF; mp->east = (int (Result; Result = (unsigned int)ADRSL2; Result |= ((unsigned ιnt) (ADRSH) « 8); Result s= 0x3FF; mp->north = (int) Result; ( ,1 SQ_STAT.C Page 1 ((include <math.h> ((include "parents. h" int mov mea (MeanParams *mp) ( if (rp->count==mp->points) mp->sum -= (float ) ι-p->input [mp->index] ; •lae ++mp->count; mp->sum += mp->nextVal; mp->ιnput (mp->index++) =mp->nextVal ; πtp->ιndex ϊ= mp->points ; mp->π-.ean = mp->sum/ (float ) mp->count; return (int ) mp->mean; ATAH2.C Page 1 ((include <math.h> float kjatan2 (float x, float y) ( float v; if ( fabs (y) >= fabs(x)) ( v = atan(x/y) ; if ( y < 0.0) if (x >= 0.0) v += 3.14159265358979; •la* v -= 3.14159265358979; return v; I v = -atan(y/x) ; if (x < 0.) v -= 1.57079632679489 ; •la* v += 1 . 57079632679489 ; return v; 7Q ■ :SGS . C Page 1 ((include "compass . h" •include "fit.h" •include "serial . h" /* Se.-.d msg outputs a preeamble followed by the msg contents followed by a one byte chksum. The receiving routine then shculd look for the two preamble bytes followed by the si ze byte Then si ze more bytes should be fetched the last byte being the chksum. The chksum includes all data excluding the two sych bytes '/ void sendMsg l char * msg) ( char i ; char size ; unsigned char chksum=0 ; unsigned char *cptr = (unsigned char * ; msg; if ( PCMode S S ( SendData I I TestMode ) ) f MsgSkipCount = 0; //Reset global counter checking for PC Connection /* Turn bus around to be a transmi tter '/ bus_xmιt(6); //used to be 4 putch(OxFβ); /* Preamble '/ putch(0xF8); /* Preamble •/ size = * (msg) ; /* size is the 1st byte of all msgs */ for(i=0; i<size; i++) ( putch (*cptr) ; chksum += *(cptr++); ) putch (chksum) ; SendData=NO; //Turn bus around to be a receiver bus rx 0 ; ) return ; '.SERIAL. C Page 1 XSERTAL.C There are two code bases included m this module. One is to support the SCC2692 UART on the Hi-Tech SBC552 development board. The other is to support the real hardware which uses the internal UART for external interface. This code (both versions) implements the communic tion with the Ford display processor. '"" .....*#.*...♦**»*•»*»*»*..»*. .*... ...........♦.../ ((include "compass. h" ((define EnableRXInt (unsigned char) 0x02 /t .................................................................... ^ -.... Ford display protocol definitions. ...„...........,,.„,,.„..,.,.............................................♦./ /* PC-Mode request '/ ((define PCModeRequest 0x10 /• Direction Request */ •define DirRequest Oxll /* Response: If not calibration or zone mode, the response is the filtered heading m 1.5-degree increments from 0 to 360 (240 steps from 0x00 to OxEF) . This dodge allows the heading to be expressed m an 8-bit byte value. If in calibration mode, the response is OxFO. In zone mode, the response is 0xF2. '/ /' Direction Request during calibration '/ •define CalDirRequest 0x13 /' Response: the unfiltered heading, m 1.5-degree increments (0x00 to OxEF) . '/ /' Calibration Request '/ •define CalRequest 0x22 /* Response: OxFO. Set calibration mode as long as the background software requires t. Direction Request polls are answered with OxFO for as long as calibration mode is active. */ /' Current Zone Setting Request */ •define CurrentZone 0x40 /* Response: Current zone setting (0x00 to OxOF) . '/ /' Self Test '/ •define SelfTest 0x60 /* Response: OxAA if passed, OxFF is failed */ /* Command values from 0x31 to 0x3F are used to set the Current Zone. */ nt /' Response: 0xP2. */ XSERIAL.C Page 2 / •..«***»•* I.-itiaJize the internal 8051 UART. This is interrupt driven. void InιtΙUART(void) I /• Set up a pointer at the appropriate interrupt vector address. '/ /' ROM_VECTOR(SINT,ISerιalInt) ; '/ /' set the RS-485 bus to receive */ Plb2 = OFF; SCON = 0x52; /* mode 1, receiver enable '/ /' set baud rate generator */ 7MOD 4= OxOF; TMOD 1= 0x20; /* timer 1 auto-reload mode */ TL1 = 244; TH1 = 244; /* about 2400 baud at 11.1MHz '/ TR1 = 1; /* enable timer 1 '/ ?S ■ 0; /* serial port runs at low priority '/ TI = CLR; /* clear anything pending '/ RI = CLR; ES = ON; /* enable the interrupt */ ^......................................................................... Internal UART interrupt handler. Receive interrupt runs the state machine to interface with the Ford display. The transmit interrupt just turns the RS-485 bus around after a character is gone. ...............,..,...................................................... / /* interrupt (SINT) void ISeπallnt (void) • / void ISeriallnt (void ) interrupt SINT setting 2 ( unsigned char c, Output; /* transmit interrupt; just turn the RS-485 bus around */ if (TI) I TI = CLR; Plb2 = OFF; ) /* process receive interrupt */ if (RI) ( RI = CLR; Output = OxFl; /* this value isn't normally used and serves as a flag '/ c = SBUF; switch (c) ( case PCModeRequest: ES = OFF; /* serial port interrupt off '/ TI = SET; /* Transmit interrupt - but we poll so set */ Plb2 = SET; /* Control for 485 driver to xmit - OFF to rx */ TH1 - -3; /* baud rate generator 9600'/ TL1 = -3; /* ditto */ •1RIAL.C Page PCMode = ON; SendData=YES; break ; case DirRequest: /* Direction Request */ if (SetVariation) Output = 0xF2; elae Output = (Calibration) ? OxFO : Heading; break ; caae CurrentZone: /* Current Zone Request */ Output = Zone; break ; caae CalDirRequest : /' Calibration Direction Request '/ Output = Heading; break ; case CalRequest: /* Calibration Request */ Calibration = ON; Output = OxFO; break ; caae SelfTest: /* Self Test; hard-wired to pass */ Output = OxAA; break ; default : /* check for Zone Variation; ignore anything else '/ if (c < 0x31 I I c > 0x3F) break ; /* set the current zone to the new value */ c -= 0x30; /* remove the offset */ Zone = c; SetVariation = ON; Output = 0xF2; break ; ) //End Case /* send a response, if required */ if (Output '= OxFl) I /* wait for the bus to clear */ for (SerialTicks = 0; SerialTicks < BusDelay; ) ; Plb2 = ON; /* turn the RS-485 bus around '/ SBUF = Output; /* send the response, TX int will switch bus '/ ) ) //End if receive interrupt void bus_xmιt (char extra_delay) I for (SerialTicks = 0; SerialTicks < BusDelay+extra_delay; ) ; Plb2 - ON; void bus rx ( ) ( while ( ! I ) Plb2=OFF; LOWLEVEL.C Page 1 /""**"" LOWLEVEL.C L w-level interrupt handlers and hardware control code. •include "compass. h" /• Timer 0 constants for the various timing values. The timer interrupt triggers en overflows so we need to negate and split into high and low bytes. At ll.lMHz (32KHz PLL oscillator) each timer tick is l.OSluS. At 11.0592MHz (external crystal, as used on the development board, each tiaer tier is 1.085uS. These differ by about 0.3i, which shouldn't matter. */ * SOOuS interrupt s -461. */ ♦define TDIVLOSOOuS .unsigned char) (0x33) / • 500uS low byte '/ ♦define TDIVHISOOuS (unsigned char) (OxFE) /' SΩOuS high byte '/ /' 300uS interrupt is -277. V ♦define TDIVLO300uS (unsigned char) (OxEB) /' JOOuS low byte '/ ♦define TDIVHI300uS (unsigned char) (OxFE) /* 300uS high byte •/ '* 200uS interrupt is -185. */ ♦define TDIVLO200uS (unsigned char) (0x47) /• 200uS low byte • ' ♦define TDIVHI200uS (unsigned char) (OxFF) /* 200uS h gh byte '/ /' state variables for the interrupt processor */ static DATA unsigned char MRState; / ♦ state definitions for the Ti erO interrupt '/ ♦define DoSetPulse 0 ♦define StartSensorAD 1 •define DoResetPulse 2 ♦define StartRefAD 3 •define EndResetPulse 4 TimerO interrupt handler. Timer 0 is used to generate a O.SmS interrupt used for inverting the MR sensor output. This interrupt also schedules A/D conversiors coherant to the sensor flips, which avoids sampling noise spikes generated by the set/reset of the sensor polarity. The O.SzS interrupt also provides some timing counters used by background processing. Mostly, this does the pulsing required to set/reset the MR sensors at a ImS rate. The pulses for the sensor must be a minimum of 5uS. On entry, set the appropriate output b t, and then do something useful during the pulse active time. The pulse width is determined by how much software business occurs between the edges of the pulse. Generate an assembly file and check the timings to mare sure that the pulse width is su ficient; verify with a scope. It the background processor needs A/D measurements, they are scheduled 200uS after each pulse. The two sensor outputs are done in the positive half of the sensor flip and the reference voltage is done m the /iy negative half of the sensor flip. When no measurements are needed, * th k -e f A/D is not sceduled, which reduces software overhead. OWLEVEL.C Page 2 The Timer 0 interrupt flag (TFO) is cleared by hardware and requires no software intervention. ....*..**..##♦»******»*•»♦♦•»»**•*****»******♦*' ♦ ♦*»•*.♦»»*♦•»•»**♦*»♦»#♦/ /• interrupt [TIMAZRO] void TimerOInt (void) */ void TimerOInt (void ) interrupt TIMERO setting 1 { switch (MRState) ( /* Do the reset pulse for the MR sensors '/ case DoSetPulse : PlbO = CLR; /* start the pulse */ Plb7 = SET; /* Scope trigger */ /* do some useful housekeeping '/ TRO = OFF; if (Measuring) ( THO = TDIVHI200uS; TLO = TDIVLO200uS; StartedAD = YES; MRState = StartSensorAD; ) else ( THO = TDIVHI500uS; TLO = TDIVLOSOOuS; MRState = DoResetPulse; If (StartedAD) ( StartedAD = NO; ValidAD = YES; ) ) TRO = ON; ++SerιalTιcks; ++MsTlcks; PlbO = SET; /* finish the pulse '/ Plb7 = CLR; /* Scope trigger */ break ; caae DoResetPulse: Plbl = SET; /* start the pulse •/ /' do some useful housexeepmg */ TRO = OFF; if (Measuring ti StartedAD) ( THO = TDIVHI200US; TLO = TDIVLO200uS; MRState = StartRefAD; 1 •la* ( THO = TDIVHI300US; TLO = TDIVLO300US; MRState = EndResetPulse; ) TRO = ON; break ; /* reset pulse is longer than set pulse to ensure cap discharge '/ cas* EndResetPulse: TRO = OFF; THO = TDIVHI200US; TLO = TDIVLO200uS; TRO = ON; MRState = DoSetPulse; Plbl = CLR; /• finish the reset pulse */ break ; WLEVEL.C Page 3 caa* StartSensorAD: TRO = OFF; THO = TDIVHI300uS; TLO = TDIVLO300uS; TRO ■ ON; /» one-time scan of the sensor A/D channels '/ ADPSS = 0x06; ADCON = OxCB; MRState = DoResetPulse; break ; case StartRefAD: TRO = OFF; THO = TDIVHI300US; TLO = TDIVLO300uS; TRO = ON; /* one-time scan of the Reference A/D channel */ ADPSS = 0x01; ADCON = 0xC8; MRState = DoSetPulse; Measuring = OFF; Plbl = CLR; /* finish the reset pulse '/ break ; ! ) .......................................................,................. Ini tialize TimerO and the I/O for the sensor flipping switch . This timer is used for the sensor set/reset interrupt and to schedule A/D conversions . Pl . O is normally h gh and pulses low to set the sensors . Pl . l is normally low and pulses h gh to reset the sensors . ...... / void InitTi erO (void ) ( /* Ini tiali ze the parall el I/O '/ •lf ef HT P10BITS . S0 = SET; / • do this fi rst to shut off the VCC swi tch '/ P10BITS.31 = CLR; •else PlbO = SET; /* do thi s first to shut off the VCC swi tch '/ Plbl = CLR; •endlf /* Set '.-p a pointer at the appropriate interrupt vector address. */ /' ROM ECTOR (TIMERO, TimerOInt) ; '/ /* timer off, interrupt cleared '/ TRO = OFF; TFO = CLR; /* run this interrupt at high priori ty '/ PTO = SET; /* Mode 1, 16 bit timer, software-only control */ TMOD 4= OxFO; TMOD 1= 0x01; /* preset the timer modulus */ THO = TDIVHISOOuS; TLO = TDIVLO500uS; OWLEVEL. C Page 4 /* Enable the timer interrupt, but don ' t start the timer. ETO = ON; /» set up the state variable */ MRState = DoSetPulse ; / ......,...„............. * .............. ............. Initialize The Pulse-Width Modulators to be used as DAC 's . void ImtPWM(void ) /* Im ti tialize the pre-scaler '/ PWM? = 0 ; /* Ini tiali ze each DAC output to half-scal e '/ /'PKMO = 0x80; '/ /' PWM1 = 0x80; • / /' PWMO » 0; - This is now read from EEROM '/ PWM1 = 0 ; /* Unused */ 1 Roll the momentary switch to see if we need to enter alibra tion or zone setting mode . On a detected make, debounce the swi tch for a few ms. After debounce, if the swi tch is closed for less than a full second before a valid break, then enter calibration mode. If the swi tch is pressed for >1 second, enter zone setting mode . Once in zone mode, wai t for about 1 second and display the current zone. If the swi tch breaks before the lsec, then leave the current zone as-is . If the but ton remains pressed, cycle through the zones. The swi tch is a NO momentary which takes PI . 3 low. ......................................................... ................ / void CheckSwitch (void ) ( static BIT state=OFF; char pollCount; /* ChecJc for swi tch pressed */ if ('Plb3 SS 'Calibration) I / » debounce for a few mS */ for (M≤Ticks = 0; MsTicks < 20;) if (!Plb3) /'if swi tch still pressed '/ ( for (pollCount=0; pollCount<50; pollCount++) ( T3=0; PCON |= 0x10; //Keep wa tchdog alive for (MsTιcks=0; MsTιcks<20;) ; /* Wait 20ms '/ if (Plb3) return; /* swi tched off before entering zone '/ ) SetVarιatιon=ON; /* Swi tch been pressed for 1 second show zone '/ for (pollCount=0; pollCount<55 ; pollCount++) ( T3=0; PCON 1= 0xl0;//Keep watchdog alive for (MsTιcks=0; MsTιcks<20;) ;/ » Wait 20ms '/ if (Plb3) /* release swi tch ? '/ I state=OFF; for (pollCount=0 ; pollCount<100 ; pollCount++) ( OWLEVET..C Page 5 T3=0; PCON 1= 0x10; //Keep watchdog alive for (MsTιcks=0; MsTιcks<20;) ;/* Wait 20ms */ if (!Plb3) ( if (state==OFF) ( state=ON; Zone = (Zone==0x0F) ? 1 : Zone+1; pollCount=0; ) pollCount=0; /* Stay in this loop until the switch is released '/ )/* End if switch on */ else I if (state==ON) I state=OFF; pollCount=0; ! ) )/* End if its been 2 seconds since state changed '/ return ; ) /* End if switcn released */ )/' End if switch held on for an additional second (total 2 seconds) (pollCount>SO) '/ Calιbratιon=ON; return ; ) /* End if switch still on after debounce check '/ ]/* End if switch pressed '/ )/' End Module */ Delay m 200mS increments. void Delay (unsigned char Length) ( unsigned char Ticks; T3=0; PCON 1= 0x10; //Keep watchdog alive for (Ticks = MsTicks = 0; Ticks < Length; if (MsTicks == 200) ( ++Tιcks; MsTicks = 0; ) ) T3=0; PCON 1= 0xl0;//Keep watchdog alive I I2C.C Page 1 I2C.C Communication to/from devices on the I2C bus. This is the EEROM, and possibly a static RAM. The uC is always used in Master mode, for both transmit and receive. This simplifies the I2C state logic and control. The SBC552 development board has a 512x8 device that's organized as 2 256-byte pages. We'll just use the lower page, as that emulates the 128-byte part that will be used on the real compass. The EEROM is located at I2C address 0xA8, and NOT at 0xA4, as the SBC552 documentation claims. ................................A.................................. „. •include "compass. h" •define EEBASE 0κA8 /* EEROM base address */ •define EERead 0x01 /* Read bit */ atatic BIT EEStop; static unsigned char ΞlStatus; /* *** " * "» ** ............... * Initialize. void ImtI2C(void) ( /* set up the clocJc rate for 100kHz '/ CRO = 0; CR1 = 1; CR2 = 1; AA = OFF; /* stay in master mode */ SI = OFF; /* clear the interrupt flag */ ENS1 = ON; /' enable the I2C bus '/ ) /** * .............. Read a byte from the EEROM. For the EEROM, this first requires a dummy write to set the random read address, then a switch to a master read. a....*,..,..,.*,..,...........,*............................................../ unaigned char ReadEERO (unaigned char Address) ( unaigned char Data ; /* flag to signal end of loop */ EEStop = NO; /* START */ STA = ON; /* now process through the state machine '/ for (;!EEStop;) { while (!SI) SIStatus = S1STA; /* printf ("\02X\n", SIStatus) ; */ switch (SIStatus) ( case 0x08: /* START has been transmitted */ I2C.C Page 2 /• load SLΛ+W '/ S1DAT = EEBASE; STO « OFF; SI = OFF; break ; eas« Oxlβ: /* SLA+W transmitted; ACK received '/ /• send the word address for the EAZROM */ S1DAT = Address; STA « OFF; STO = OFF; SI = OFF; break ; case 0x28: /* Address sent; ACK received */ /• send repea ted START condi tion to do read '/ STO = OFF; ' STA = ON; SI = OFF; break ; caae 0x10: /* repea t START has been sent '/ /' load SLA+R '/ S1DAT = EEBASE I EERead; STO = OFF; SI - OFF; break ; case 0x40: /* SLA+R se .t; ACK received '/ /' ask for the byte wi th no ACK '/ STA = OFF; STO = OFF; AA = OFF; SI ■ OFF; break ; case 0x58: /• Got byte; no ACK */ EEStop = YES; /* read the byte; send STOP '/ Data = S1DAT; STA = OFF; STO = ON; SI = OFF; break ; def ult : /' printf ( "Unknown state : t02X\n ", SIStatus) ; '/ break ; ) I return (Data) ; /*********•* Write EEROM. static BIT DataWritten; void WriteEEROM (unaigned char Address, unsigned char Data) EEStop « NO; SI ■ OFF; STO » OFF; AA = OFF; DataWritten = NO; /* send START */ STA ■ ON; for (; !EEStop;) ( I2C.C Page 3 whi * (!SI) SIStatus = S1STA; /• print ("*02X\n", SIStatus) ; */ switch (SIStatus) ( caa* 0x08: /* START sent */ /* Load SLA+W '/ S1DAT = EEBASE; STO = OFF; SI = OFF; break ; case 0x18: /* SLA+W sent; ACX received '/ /* load word address */ S1DAT = Address; STA = OFF; STO = OFF; SI = OFF; break ; case 0x28: /* Data sent; ACK received • / if ( 'DataWritten) 1 DataWritten = YES; /• load write data • / S1DAT = Data; STA = OFF; STO = OFF; SI = OFF; ] else { EEStop = YES; /* send STOP '/ STA = OFF; STO = ON; SI = OFF; ) break ; def ult : /' printf ( "Unknown : i02X\n ", SISta tus) ; • / break ; J ) /* Now wai t for tr.e wri te to finish . Try to write again. No ACK means it 's busy. '/ STA = OFF; STO = OFF; AA « OFF; SI - OFF; STA ■ ON; for (EEStop = NO; 'EEStop;) ( while ( ! SI ) SIStatus = S1STA; /* printf ( "%02X\n ", SIStatus) ; */ awitch (SIStatus) 1 caae 0x08: / » STPKRT sent */ /' Load SLA+W '/ S1DAT = EEBASE; STO = OFF; SI = OFF; break ; caae 0x20: /* no ACK; must be busy */ /* send STOP, then START '/ STA = ON; STO = ON; Page 4 I2C.C SI = OFF; break ; caae 0x18: /* ACK must be done */ /' send STOP '/ STA = OFF; STO - ON; SI = OFF; /* top EEStop = YES; break ; default : /* printf ("Unknown: \n") break ; ) DOCKET NO.98/101 APPENDIX "B" HATCH U.S. PATENT NO. 4,797,841 98/48292 84 United States Patent [i j (n) Patent Number: 4,797,841 Hatch [45] Date of Patent: Jan. 10, 1989 (54) METHOD AND APPARATUS FOR 4.327.498 5/1982 Seller ei al. ._ _ 33/356 X AUTOMATIC CALIBRATION OF 4.336.596 6/1982 Martin 33/571 X MAGNETIC COMPASS 4.380.735 4/1983 Bell 324/244 4.399.615 8/1983 Mauumoto «ι al 324/144 X (751 Inventor. Roaald R. Hatch, Wilmington. Calif. 4.414,753 11/1983 Moulin el al ._ 33/356 4.414.067 11/1983 Scherer cl al 364/571 X (73) Assignee: Maasavox Government and Industrial 4.443.279 5/1984 Tsushima el al 364/571 X Electronics Company, Fort Wayne, 4.622.843 11/1986 Hoπnel — 364/371 X Ind. 4.672.563 3/1987 Kuno et al .-. - 33/336 X (21) Λppl. No.: 881,441 Primary Examiner— Felix O. Gruber Attorney. Agent, or Fir — Thomas A. Bnody; Roger Λ. (22) Filed. Jul. 2, 1986 Rickert; Richard T. Seeger Related U.S. Application Data (57) ABSTRACT (63) ConunuiQon-in-piπ of S t. No. 355.885. Nov. 28, A three winding induction compass mounted in a host 1983. Pat. No 4,611.293 vehicle has each winding output coupled to an analog to digital converter. Each winding output is weighted (51) Int. Cl/ G06F 15/31; QOIC 17/38 and accumulated by a push down suck circuit to obtain [521 VS. Cl. 384/571.04; 33/355 R; a time filtered output; the fύtered outputs are mapped 33/356; 324/245; 364/559 into equivalent two winding outputs as the vehicle is (58) Field of Search 364/5 1. 556. 559; turned in a 360 * circle to form sensitivity values from 124/244. 245; 33/355 R, 356. 357 the windings readings and using these values to obtain [56] References Cited measurement parameters which are mcorporaied into a least squares matrix which is solved for calibration coef¬ U.S. PATENT DOCUMENTS ficients to obtain the calibration parameters represent¬ 2.492.970 10/1934 Tolles _. 33/336 X ing the distortions due to the permanent and inducted 2,802.933 8/1957 Tollβ 33/3J7 X magnetism of the host vehicle and due lo winding im¬ 2.134.939 5/1958 Tollβ 324/244 balance between the three windings and misonemaαon 3.952.420 4/1976 Benjumn cl tl 33/361 X of the three windings. The calibration parameters are 3.991.361 11/1976 Manem et il 33/356 X applied to the outputs of the three windings to obtain an 4.091.543 5/1978 peyre 364/S71 X 4.124.897 11/ 1978 amβ .- - 364/571 equivalent two winding output which is normalized for 4.163.326 8/1979 Edwards — - 33/361 determining the corrected compass heading. 4.179.741 12/1979 Rossuu — 33/356 X 4.262.427 4/1981 Lynch et al 33/361 21 Claims, 6 Drawing Sheets tent Jan. lO, 1989 Sheet 1 of 6 4,797,841 " &= ■ 3 US. Patent Jan. lO, 1989 Sheet 2 of 6 4,797,841 VS. Patent Jan. 10, ι sheet 3 of 6 4,797,841 VS. Patent Jan. 10, 1989 Sheet 4 of 6 4,797,841 US. Patent Jan. lO, 1989 Sheet 6 of 6 4,797,841 4,797,841 1 2 crease will be observed at an opposite vehicle oπenta- METHOD AND APPARATUS FOR AUTOMATIC tion as well. The net result of the horizontal component CALIBRATION OF MAGNETIC COMPASS of induced magnetism is to cause the perfect circle net .^ ^ r , , „ » ,. lτιnM described above to become an ellipse. This ellipse is RELATED APPLICA TI O N s aligned with the semimajor axis in the direc t ion at This is a continuation in pan application of copending which the host vehicle induces a maximum in the mag- applicauon entitled "Method and Apparatus for Auto- nettc flux density as seen by the compass This elliptic roaiic Calibration of Magnetic Compass", Ser. No effect can be defined by three terms- 06/555,385, filed Nov. 28. 1933 by Ronald R. Hatch and (1) a— scaling along the semimajor axis. Richard G. Kecgan and now U.S. Pat. No. 4,611,293 10 (2) b— scaling along the semiminor axis. granted Sept. 9. 1986. (3) β — the angle between North and the semimajor BACKGROUND OF THE INVENTION - inft-^e to t ta.li A d » is.t~o-rtion r fr.om permanent and ind ..uced J I Field of the invention magnetism can then be described by five parameters. This invention is in the field of automatic calibration ls B„ B„ a. b. and β. This inven t ion provides for deteπ t un- of magnetic compasses, such as induction and Hall ef- ing these parameters. feet compasses, and more particularly to the calibration A flux gate sensor is a type of two axis magnetometer of compasses mounted in a host vehicle that has perma- which measures the complex amplitude of the earth's nent and i nduced magnetic fields. magnetic field in the plane of the sensor. In this descnp- 2. Description of the Prior Art , "on, "two axis" or "two winding" compass mean a Various sources distort the earth s magnetic field as magnetometer having a winding along each of two seen by a magnetic compass mounted i n a host veh i cle. muma lly orthogonal axes in a two dimensional plane. A The purpose of ci.br.nng a magnetic compass u to . hreβ wnduf . or ,. three „ 7 m determine the amount of distortion and a prov.de a , ome|er „, d ^ h " ^, correspond i ng correct i on. The two bas i c sources of U spaced axe, m a two dimensional plane. Since the *nsor distortion are the permanent and induced magnetism of meMufe$ , he , , mtΛmΛ(i ζ [ , hβ fιeld . maϋ i emat. the host vehicle. In addition, the non-ideal nature of the .„.. _„__._." „ .7 TL . ""= ■« " »• ™ ««««u " magnetic sensor itself contributes effects which reomre ° m Ca ° ϊp f ed ,0 ,he »∞ ureme »" eotrecnon. Numerous effoπs have been made w pro- ™° £ e """"^ ° f P∞nanen and mduced vide these corrections. These include various methods 30 "» β ~ttsm. Flux gate sensors are typically consuiicled of establishing or esumaαng a correction signal and m «*" wo or «* ■ • *"««»» configurat i ons. The two applying a feedback signal to bucking coϋs coupled to wln '? « *">*>' »«»»"<» •»« complex amputude i n the compass windings, the use of a gyrocompass t n a.ωawtu" whereas the three winding sensor measures con j unc t ion with the compass windings, and applying we complex amplitude on a three vector basis, the estimated compensation values to the signals from the 35 w uigs ^""β "cuately separated from one another compass windings. These efforts have been largely un- " I20 • Tbe calibration disclosed herein is imple- sausfactory since, while perhaps recognizing the com- "en e with the three winding sensor , plexity of the problem, they are only partial and made- ° ,her distortion effects that are corrected by this quate solutions or are misdirected and no solution. invention are those due to any gam imbalance and angu- 40 lax separation error between the three windings of the SUMMARY OF THE INVENTION senjor. Manufacturing imperfections result in sensors Magnetic field distortions to be removed mclude which are not ideal. Two types of imperfections cause those due to permanent and mduced magnetism of the errors ui the beading that are produced from these sen- host vehicle. The distortions are to the earth's magnetic sors. The two types are gam errors and angular separa- fieid vector, t.e. a signal having both amplitude and 45 tion errors. Each winding should have the same ampli- direcnon, to be measured by the compass. Without the lude response from an external field and should be sepa- distortions, the vectors measured by the compass as the rated by 120 * . The inherent imbalance of the three host vehicle is turned in a complete circle define a per* winding compass can be removed by making use of the feet circle centered at the origin of a given coordinate fact that the three winding outputs, U, V, W, rcspec- syaiem. 50 lively, sum to zero. By combining the readings from the Permanent magnetism and the vertical component of three windings in a particular way a new set of readings induced magnetism of the host vehicle cause an increase which is equivalent but much less sensitive to these or decrease in the magnetic flux density seen by the error sources u created. compass depending on the onenuπon of the vehicle in la the calibration of the magnetic compass the opera- the earth's magnetic field. The net result is a translation 5) tor manually switches to a calibration mode and turns of the perfect circle away from the origin to a new the host vehicle at least 360*. By taking a sequential center having coordinates B,, By. The horizontal com- sampling of U, V, , from the three windings, u, v, w, ponent of the induced magnetism may result in a more respectively, of the compass, a new set of readings is complicated distortion pattern. Depending on the non- calculated. The U, V, readings are tune filtered and symmetncal nature of the mduced field from the soft 60 become U', V, W readings respectively. The time iron in the host vehicle and the vehicle orientation, the filtering is accomplished by using the previous seven compass may see either an increased or a decreased readings of each of the winding outputs using the set: magnetic flux density as a function of the particular orientation. However, the magnitude of the mduced f- -*»-ift+«"'4-W)-Λι+Λ magnetism is independent of the polarity of the roagne- 65 tiling field. If an increased flux density is observed at a where F=lhe filtered reading at tune (t) and P1-P7 particular nost vehicle orienta t ion d ue to the horizontal represent me winning outputs or u, v, sequentially component of induced magnetism then an equal in- at tunes (t) to (1—6) respectively, as will be more fully 4,797,841 3 4 described. For example, to obtain a new reading U', the An object of this invention is to provide calibrations above »t becomes: in the previous object for distortions due to permanent and mduced magnetism of the host vehicle. «>-Mι ) -«'-i ) -ιWι-!>- it is a further object of this invention to provide cali- +4 t .- l »- 2 Mι- 4) _ιm- j) *M«-« j orations m ,he previous ob j ects tor compass winding unbalance and winding separation irregularity where t«now A fuπher objecI , $ , 0 llme f ύter , πe reac |mgs of each The new set of readings are obtained using a "push of the windings of t he compass, down stack" of the previous set of seven samples. The Another object is to achieve the previous ob j ects by new output would be a U sample if the most recent to taking the maximum and minimum readings of each stack entry was a U sample, it would be a V" sample if winding during a 360" turn of the host vehicle to obtain the most rrcent slack entry was a V sample, and it calibration parameters would be a sample if the most recent stac entry was Another object is to achieve the previous objects by a W sample. During the 360' turn of the host vehicle the forming sensitivity values from the windings readings maximum and minimum values of each of the three 15 during a 360' turn of the host vehicle and using these output readings U', V, are stored. values to obtain measurement parameters which are As stated previously, the effect of permanent magne- mcorporaied mto a least squares matrix which is solved turn and the vertical component of mduced magnetism for calibration coefficients to obtain the calibration is to create an origin offset in the perfect circle or el- parameters pse. This origin offset can be determined by finding 0 Tixe abovβ mentioned and other features and objects the bias associated with each of the windings The bi- of ,nB ""ventton and the manner of obtaining them wdl ases are the average of the minimum and maximum ""come more apparent and the invention itself will be value for each of the winding readings U\ V, V be * understood by reference to the following descπp- The« biases are then sub t racted from all subsequent ,. uon of " «*«•««« of the lnv «»ιon t aken i n con- readings made on the particular wm d ing including " '^ uon w i th the accompany i ng draw i ngs , those used for mduced magnetism calibration. BRIEF DESCRIPTION OF THE DRAWINGS In another embodiment, during the 360 * turn of the na t „ , , ot ^ of , dutorted field c0 host vehicle sensitivity values for measurement parame- mά , uperpose(i „ und i storted field compass read- ten are determined. The sensitivity values are variables 30 „,.. in a generalized equation for a "flattened circle", or jo. 2 is a flow chart diagram of an embodiment of elhpse. having offset axes. The degree of flattening and t hιs invention; the amount of offset of the axes are measurements of the FIG.3 is a push down stack schematic block diagram distortions for which this invention provides calibra- for obtaining the tune fϋtered readings of the compass αona. The measurement parameters representing the 3 winding outputs; sensitivity values are placed mto a least squares matrix FIG.4 is a block diagram of the embodiment of FIG. with five calibration coefficients which is solved for the 2, five calibration coefficients which are used to obtain X FIGS. SA and 5B considered together are a flow Y biases, representing the offset, which in nun are chart diagram of an embodiment using a least squares mapped into U, V, W biases, and to obtain calibration 40 matrix solunon to obtain the calibration coefficients, parameters for getting the corrected heading Thus, in where terminals A, B of FIG. SA are connected to this embodiment, it is unnecessary to obtain the mini- terminals A, B of FIG. 5B; and mum and maximum values of the three winding read- F 10 - * "*• * hardware-software function block dia- ings which tend to be noise sensitive. P™ of thβ embodiment of FIGS. SA and 5B. The horizontal component of mduced magnetism has * " DESCRIPTION OF PREFERRED the effect of distorting the "perfect" circle mto an el- EMBODIMENTS pse, with its semimajor axis aligned with the direction , . . .. ... L L . L L . 1. 1 j . Calibration parameters are determined from the max- a __t which t n he ho . st vehic ^ l.e indu ,c.es a minimum . in th. e im "um" and ^ ι*nτnπv |τ n raw re „ajdin _g„s - o„b.ta,i.n—ed ^ ft fro, ™ m — eac~ t i,t magnetic flux density. The calibration Procedure de- £^ ^ m „ , he fines tins elliptic shape by calculatmg ito above men- ^^ ^^ ^ , ■ ιe mcis . ,„ thβ den . tuned three terms. (1 a-^g along the semimajor VJ(0on for detennlιuιl ώe pmmclm , first equations axis, (2) b— scaling along the semimmor axis, or f. a for a bβJl<J (wo vnBάmβ ,„,„ „„ eompast am coned- factor representωg the flattening of the ellipse and (3) fnd Neχ , ώe tWQ lχu „,,„,„„-, ,„ re ted to a three β — the angle between North and the semimajor axis, or „ wuu three axis compass and the calibration parame- equivalenϋy a. b. f. SIN (28) and COS (29). xa% ue computed. The winding unbalance and wmding By making use of the mathematical equations which separation irregularity scale factors are determined, define an elhpse and the linear mappmgs which distort That parameters and scale factors are then used in the a perfect circle mto an elhpse, mverse mappmgs are desired hnear mappmg of the .raw readings from the developed making use of the maximum values of the eo three winding compau mto the cosme and sine of the samples acquired during the 360 * turn of the host vehi- vehicle heading cle. These mverse mappmgs are used to reverse the Referring to FIG. 1. a two axis compass mounted in distortion caused by mduced magnetism and to rccon- a host vehicle, not shown, has y axis 20 aligned to the struct the actual perfect circle. North and the x axis 22 aligned to the East, and if the It is therefore an object of this invention to provide a a earth's magnetic field is "perfect" then the compass method and apparatus for calibrating a magnetic field readings will define circle 24 as the host vehicle is compass mounted in a host vehicle to correct for distor- turned 360 * . It is understood that initially the y axis may tion* to the ear t h's magne t ic field. havejuiy alignment providing the vehicle is turned in a O 98/48292 93 4,797,841 6 360* circle, the alignment shown being for purposes of -continued explanation. The perfect readings are distorted by the effect of measurement distortions due to the mduced and permanent magnetism effects of the host vehicle so that the readings will define an ellipse 26. (tl Assuming the compass readings are scaled to read y • - <ι - Λr" — I and all angles are positive clockwise, then: Or in terms of x and y: (»<" l-βJ|l-Λiι+C ) 2 | where H= heading angle measured clockwise from Next the coordinate axes are routed back to their the y axis. original positions using the following equations These perfect field readings are distorted to reflect the effect of field distortions due to the mduced and <»> permanent magnetism of the host vehicle. These distor- 20 lions are mathematically applied to the perfect readings in an order opposite to their removal from the measured readings expressing in terms of x and y to obtain X. Y. and R Fust the readings are scaled as follows: gives: 25 Next flattening of the circle defined by the last equaThe next step is to add oo bias values B„ By, the tion above is allowed to occur along any axis in space center coordinates of the transformed or displaced el- Mathematically this effect can be accomplished by ro j j hpse, such that the ellipse is moved off of the coordinate tating the coordinate axes so that the y axis is routed center to obtain X', Y'- clockwise an angle β and aligned along axis 28, the axis to be flattened. The flattening, or scaling, of the y mear-«(<ι- «-/cs»+*i surement is then applied. The coordinate axes are then (10) rotated back to their original posinon with y axis 0 r-α(- CSϋi+(l->C 1 ),|+Λ, aligned to the North and the x axis aligned to the East. x", y" are obtained in the following equations where Equation (10) shows that the X'. Y measurements of C=Cos β and S=Sιn β- a practical two axis compass are a complex function of the desued values of x, y from a perfect field two axis (3) 45 compass. However, as shown below, if the parameters B*. By, a, f, C, S can be determined then the reverse mappmg can be constructed by reversing the distortion steps Express xe and y" mx t'er)ms of the perfect field readabove: ings using the equations: 50 ΛT- <r - B.) -β(( i - » - csr] (II) r-<r -Λ,)-o(-/cs»+(i -/C*)ri <4> 55 Rotate coordinates as follows: (12) The y axis reading is scaled by (1—0 where f vanes from zero (circle) to 1 (straight line). The parameter "f ' 60 is called the flattening factor and is related to "e" the CK e -.Xϊ) eccentricity factor, "a" the semimajor axis of ellipse 26, and * * b" the semiminαr axis of ellipse 26 by the following equations: r- CX-SΪ-atCΛ-S)i) 65 (13) » - <l -Λ» <J) ti - (I _ -i > r ' -sx + γ~Mi- / (Sjn.Cy) 98/48292 94 4,797,841 8 Now the Y" reading is amplified by dividing by the Forming the least squares solution to equation (20) factor (1 — 0 to give g livveesi:: 10 r--cx-sr~a( -asr (»> Equation (21) simply relates the two axis and three axis coordinates and therefore can be used to map either raw readmgs or corrected readings from the three axis to the equivalent two axis values. Route back to oπgmal coordinates as follows Calibration parameters B„ B« a, f, and θ or their equivalent are needed in order to correct the raw com¬ (16) pass readmgs. c The six readmgs corresponding to the maximum and minimum readmgs on each of the three axes of the three (;> -s y) 20 winding compass are sufficient to compute the equivalent parameter set B„, B„ B«, a. f. C and S, where which gives C —Cos ti and S=Sιn 9 Though there are seven parameters in this set only five are independent and ix measurements are available. The six measurements are des¬ ■ 1(1 - /C ! ir + JCSΪ] m ax (17) (I - /) 25 ignated by: D, U, V, V, W. and W (I -Λ ■ υcsx + i - n - «/ where the bar designates the maximum if above and minimum if below. U, V, W are raw readings from the Next, dividmg by "a" and using equation (5) gives: windings on the u, v, w axes respectively. 30 The first three calibration parameters B u . B„ B„ are obtained by: ' - 4- 1(1 - 'VC + fCSY) (II) «„.<£y.J/>/2 , - ■ - i/ctr + (i -/5'>*1 «,-<»'+ H/2 33 (22) where in terms of biased measurements is: B. (W+ιt?)n - 4- id - c'xj* - B. + /ctti* _ β,)i ( 19 ) The maximum readmgs are now corrected by remov- 40 m the biases B„, B„ B„ for use in later equations: , - ■ - Ucs/r _ β,» + (i - s»χr - *,)] V-U-Bu-(U-U> 2 Equations (19) show how to correct the measure- menu actually obtained from a two axis compass if the ' parameters describing the sue, oπenUπon, and coordiw-w-t—itv-iryi nate center offset are available. In a three axis (three winding) flux gate compass if Since the u axis of the three axis compass u aligned in the three axes are labeled as u, v, and w, respectively, 30 the same direction as the y axis of the two axis compass and the u axu is aligned to North as was the y axis of the then from equanon (9) the measurement U sfter correctwo axis compass then the following relationship betion for bias is: tween the readings of the two axis and three axis compasses is obtained: (24) 55 The ■"■— value of the U measurement can be (20) found by taking the derivative with respect to the heading H which from equations (1) and (24) is. ) ■ - _ <> - .(-. », - O - JC * >»1 <"> Simplifying and squaring equation (25) gives: Thus if readmgs U, V, W are obtained from the windϋcs>y-<l-/cW <"> ings on the three axes u. v, w, respectively, the equiva- 65 lent values of readmgs x. y of a two axis comnasa can be uauiø sum on (1) to iluauutlt κl giwM determined from equations (20) when considered as three equations in two unknowns. [(l_/C')'+VCS)V-(l-/C 2 r * W 98/48292 95 4,797,841 10 on or solving for y 2 when U = U' (U is maximum) (17) '-/ * '. (II) f - * A * - Cm 1* (I - C'l' * (CS) 1 Equation (25) can be used in equation (24) to elimi- The value Q is formed as follows: (II ) o - un' - if) 1 !/ T - j ώ 9u> u The value R is formed as follows: Squaring equation (29). (19) I /* ■!.<?> (30) L (i-yc'r 1 / Then: 20 Substituting the equation (28) value of y ϊ in equauon (40) (30) gives: (41) (42) (41) #-•-120' *l — /SiU r -#>+ no- ( 1 +/C] 45 *> -Λ + /Cl - "V Equations (32) and (33) can be written in terms of β by expanding the cosine and the sum of two angles: The procedure to remove mduced and permanent magnetism effects of the host vehicle will now be dis- (ir≠ - «>tι - (14> so cussed. The fewest operaαons for mappmg the raw U. V, W compass readmgs to the desired x, y, and cosine f v— i Yl ""* lακ ° tne he <xl u ' values is first to use the derived -- - SaKm β + — sιa'»JJ 55 ( ryi.j 'iI i1.-f * i-j >-C -o|- 2 >«-+- • <>-Sιa#Co«* + * --S--B|2»»-J iJ' r-r-M, Taking the average of the equations above and defin(30) ing the value as Z obtains the following: 60 These bias free values can then be mapped usmg 2-t(t '+-(n 2 +("*) J ι/ j -β l (i-« 1 /J) equanon (21) to bias free x, y equivalent readmgs which can then turn be mapped usmg equation (19) to the The value P is formed as follows: desired biased x, y readmgs. 65 If equanon (19) is converted usmg half angle formulas (W) . z - itni •ad K. I , K„ and K, from cautions (47), (48) and (49) substituted, the following equauon results: 4,797,841 11 12 The U", V". and W" readmgs will always sum to 3 D zero, the mappmg is simple, i e. does not involve irratio¬ 'u - * • „ nal numbers, and is svmmetncal in U", V", and ". C)-( ;:) ) v. a, Λ disadvantage s that the raw readings should be made sunultaneously to avoid introducing errors caused w - A. , by the rate of change of heading. The use of three A to D converters in parallel could be used to remove this Simplifying- disadvantage. Another way of at least reducing the effects of rate of change of heading is to combine raw (52) readmgs such that their average age is identical betαre c> implementing the mappmg of equation (55). This is the approach of this invention which also has the effect of averaging the readmgs which is an advantage if the readings are obtained rapidly but a disadvantage if they are obtained at only a slow rate. This mapping is: (») The elements of this matrix can be precomputed and 20 used until the compass u recalibrated ι, i, and K.) have by equations (47), (48) and (49), respectively, a common divisor of 2b. If this divisor is not used no adverse effects are encountered since the radius of the mapped circle is supply larger and the 25 scale is removed m the arc tangent computation of the w, heading. The normalizing, later described, makes unnecessary the divisor lb and the } factor of equation 1 - 1 -2 4 -2 - 1 I 0 fl (52). 0 | _ | _2 4 -2 - 1 I V This calibration procedure also removes any wmding 3° 0 0 1 - 1 -2 4 -1 - 1 misoπentanon effects. This is due to the fact that any Vt wmding misonenunon effects can be completely accounted for as wmding unbalance effects. If the winding n defined as having the correct scale and orientation, the scales of the v and w windings are defined as 33 Kv and Kw, respectively, and the αusoπentauons of the where Ui, Vj, | represent readings at tune l=now; v and w windings are defined as 0v and βw, respecU2, }, W 2 represent readmgs at rune t— 1; tively. U], Vj, Wj represent readmgs at tune t— 2; Further, define: K«(iC»4.ΛX 2 40 This equauon because it is symmetncal in U", V", and W" can be implemented to act on a push down 4K.-(„r»-it„l /2 stack of the last seven raw readmgs. By taking a sequential sampling of U, V, W the new set of readmgs can be β=i»,*#») l calculated in the following manner: "new" or filtered 4 5 readmgs of U, V, W are calculated to obtain U", V", a«-(»»-»») j (51) " readings, respectively, usmg the previous seven readings of each of the winding outputs comprising the With these definitions it can be shown that the misoπ- set: enution effects can be mapped mto winding unbalance effects by: J0 f-Λ- -2 +'Λ-lP5-(S4.Λ 8/48292 97 4,797,841 13 14 Referring now to FIGS.2-4 and in particular to FIG. series U, V, W. Thus, the aged output would be a V" 2 a flow chart diagram of an embodiment of this invensample if the most recent stack entry was a U sample, it tion is shown. In the diagram of FIG. 2 the logic "deciwould be a V" sample if the most recent entry was a V, sion make" functions are represented in diamonds, and it would be a W" sample if the most recent entry "compute" functions are represented in blocks and was a W. hardware is represented in blocks defined below as The generation of this aged set of samples U", V", circuits. Flux Gate Sensor block 36 is a three winding W" is done pπor to any calibration including the acquiflux gate compass, or other magnetometer, and contains sition of the maximum and minimum values of the outinterface circuitry to the compass windings, the interpuu of each of the three windings. face circuitry being any appropriate circuitry known to to the art for the purpose ot quantizing the compass signals The aged or tune filtered outpuu U". V", W" from for processing. The winding analog outputs are conblock 72 are directed via path 96 to In Calibrate Mode verted to digital signals in block 36 and are fed on path decision make 98. If the operator has switched the sys38 to Read Raw Dau block 40 where the readmgs are tem to the calibrate mode, then the outputs on path 96 outputted on path 42 to Reading Exceed Sensor Scale are fed via "yes" path 100 to Automatic Mode decision decision make 44 where the amplitude of the block 40 make 102. If the operator has switched the system to outpuu are compared to the present upper amplitude of automatic mode, the outpuu on path 100 are fed via the block 36 sensor scale. If the readmgs from block 40 "yes" path 104 to Store Maximum; Mimmums & Scale exceed the sensor scale, this decision is fed on "yes" circuit 106 where they are stored and scaled. Scaling in path 46 to Increase Sensor Scale block 48 and Decrease circuit 106 is performed from mput via pains 114, 116 20 Stored Values block SO. Block 48 feeds increase scale from blocks 50, 60. respectively. information via path 52 to block 36 to increase the senThe scaled maximum and minimum values from cirsor scale to mclude the present upper amplitude. If the cuit 106 are fed via path 118 to (s Table Full decision present readings do not exceed the sensor scale, this make 120 whereat it u decided whether the table of decision is indicated on "no" path 52 to Readmg Below ^ values in circuit 106 is full. If the decision is yes, then an Sensor Scale decision make 54. If the reading is below enable signal is fed via "yes" path 122 to Compute Bithe present scale lower limit, this decision is fed on the ases block 124 where biases B u . B„ B» are computed "yes" path 56 to Decrease Sensor Scale block 58 and according to equations (22). If the decision is no. then a Increase Stored Values block 60, block 58 feeding dedisable signal is fed via "no" path 126 to exit 128. crease sensor scale information to block 36 via path 59. 30 The bias outpuu B», B„ B.from block 124 are used in If the amplitude readmg is not below the present scale block 138 as described below and are fed via path 130 to lower limit, this decision is fed on the "no" path 62 to Compute Values block 132 where the values of equa- push down stack block 64, later described. Block 64 is nons (23), (35). (38H44n). and (47M49) are computed. indicated by the double line on the top and left side It is noted that the equations in block 132 for computing indicating it is a uble stored in memory. Also, blocks Kι, K. 2 , and i do not correspond exactly to equattons 50, 60 feed decrease and increase information, respec(47X49) since they do not have the divisor lb. As mentively, via paths 66, 68, respectively, to block 64 in tioned, if this divisor is not used no adverse effects are order to maintain the incoming and stored dau on the encountered since the radius of the mapped circle is same amplitude scale. simply larger and the scale is removed in the arc tangent One method of increasing or decreasing the sensor computation of the heading. The normalizing, later scales is integrating means for integrating the wmding 40 described, makes unnecessary the divisor 26 and the j incremental outpuu and increasing the number of windfactor of equation (52). Additionally, the following ing incremental outpuu integrated when the winding values are computed in block 132: outpuu fall below the sensor scale and decreasing the number of winding incremental outpuu integrated when the winding outpuu are above the sensor scale, as 45 (57) "21 » 2A) is known in the art. The output of block 64 on path 70 is shown in block 72 and has the form: • l » » Yl K \ - * 2 Referring to FIG.3 block 64 will be described. IπpuU of raw readings U, V, W are sequentially made to termi, . - 7 Kx - fi nals 74-86 with an U reading being shown at terminal 74 in the ume period shown m FIG.3 to obtain U". The 55 readings at terminals 74-86 are multiplied by multipliers •n m — 1 JC t — Λi 74o-86a respectively, having multiplying factors 1, — 1, - 1, , — I, — I. and 1 respecnvely. The outpuu of The computed values from block 132 are fed via path multipliers 78α 80 82a are summed in adder 88 and 134 to exit 128 and are used in block 138 to determine X. multiplied by a factor of 2 in multiplier 90. The outpuu 60 Y as described below. of multipliers 74a. 76a. 90, 84a 86a are summed in adder Thus, when the system is switched by the operator to 92 to obtam "aged" readmg U". It is understood that to the calibrate mode the outpuu on path 96 are collected obtain aged reading V", a V reading u applied to termiduring the 360 * turn of the vehicle. After the turn, the nal 74 and the readmgs in each of the lower terminals operator switches from the calibrate mode to the auto76-86 are "pushed down" one letter in the seπes U. V. 65 matic mode and the collected outpuu are appUed to W. To obtain aged readmg W", a W readmg is applied determine the calibration parameters. to terminal 74 and the readings in «*ch of th* lo er When tk« «y«am u not in caiibraM mode but in ttuto- terminals 76-86 are "pushed down" one lener in the. mauc mode, the system is enabled to compute and apply 4,797,841 15 16 the dau collected when in the calibrate mode. In the function block 171 wherein the product values aιι(U"- automatic mode, X and Y are determined from the -B u ), ai2(V"-B,), ai3(W"-B„), ajι(U"-B.), information obtamed from blocks 72, 124. 132 in Apply a«(V"-B v ), aufW' -B.) are obtamed. an(U"-B„), Calibration Parameters to Form X. Y, from U", V", W" ai2(V"-B v ), aπfW'- B.) are supplied from mulnpty block 138 by the following equations: function circles 180. 186, 192 respectively to add funcjr-«,,(t/'-β » )4..ι,(i--fl.> + .,,(κv--4.) tion block 196 to obtam the X value on path 198 according to X=aιι(U"-B„)-+-ai2(V"-B,)fai)(W"_B.) r—„(U" -Bj÷i- v -BΛ~*niw~- a.) (3D which is supplied to each of normalize function blocks 200, 202. In like manner, aιι(U" — B « ), aj:(V"-B,), X.Y values are fed via path 140 to Normalize block 142. ajjfW"— B«.) are supplied from multiply function cirNormalized values X', Y' are computed in the following cles 182, 188. 194 respectively to add function block 204 manner to obtam the Y value on path 206 according to Y— n. (U"-B u )-t-a 2 2fV"-B,)-ι-a»(W"-B.) which is supplied to each of normalize function blocks 200, 202 where and r - Y VX' + Y' Equations (59) are similar to equanons (52) except the 20 are obtamed respectively and supplied to arc tan funcs factor is deleted as a result of the normalization. tion block 208 from which the calibrated compass head¬ After normalizing. X', Y' are fed via path 144 to ing is provided on line 210. Thus the circuitry between Compute Heading block 146 where arc tangent (X*. V) line 172 and lines 198. 206 correspond to that provided is computed and fed via path 148 to Exit 128. From Exit in block 138, m FIG. 2, blocks 200. 202. correspond to 128 the calibrated heading may be fed to an heading 25 block 142 m FIG.2, and block 208 corresponds to block indicator, position plotter, dead reckoning system or 146 in FIG. 2. other use which are not shown. The previously described embodiment utilizes maxi¬ Referring to FIG. 4, a simplified block d agram mum and minimum raw readmgs obtained from each showing both hardware and software controUed dau ' compass winding, which typicaUy are readmgs sensiuve processing system funcαon blocks or circles is shown. 30 to noise. Also, when the number of kinds of measure- the hardware blocks being m dashed section 152. Commenu only slightly exceeds the number of the obtained pass drive circuit 154 is coupled to compass demodulacalibration parameters, the soluuon u addiuonaliy sensition cucuit 156, drive wmding d providing the drive uve to noise. signal for compass windings u. v, w in conventional A second embodiment that is less sensitive to noise manner to cucuit 154. Cucuit 156 feeds analog signals 35 and is designated as the "least squares fit" approach, is U, V, W from windings u. v, w respectively to sample described below This approach uses linear equations and holds 3 cucuit 158 which samples and holds each of and hence the raw readmgs from the compass windings the U, V, W signals and feeds these signals to multineed not be stored if the readings are mcorporaied into plexor cucuit 160. Cucuit 160 supplies the U, V, W a least squares matru as they are received as the host signals serially to analog/digital A/D converter circuit 40 vehicle is turned in a 360* circle and a relatively large 162 where the analog signals are converted to digital number, in the order of 60. readings are taken during the signals. Timing circuit 164 supplies tuning signals to turn. The number of readings should be chosen as a circuits 158, 160. 162. The hardware thus described function of the quantization noise and the desued accucorresponds to cucuiu 36. 40, 48, 58 in FIG. racy of the compass. More frequent readings are desued The output of converter cucuit 162 is supplied to 45 if they are mcorporaied mto the matrix as they are push down suck 165 which time filters the U, V, W signals to provide U", V", W" signals in the manner received. This approach substitutes the foUowtng equadescribed for block 64, FIG. 3. The U", V", W" signals nons (61) to (89) for equauons (22) to (43) above, it from stack 16S are provided to register file 166, minibeing understood that equanons (1) to (21) and (44) to (59) apply in the second embodiment as previously mum-maximum block 168 and subtracter 170. File 166 SO also receives a tuning signal from cucuit 164. Block 168 described herein for the previously described embodidetermines the wyfi»n*"iy and p* -rc mιlm values of each ment in the manner described herembelow. of U", V", W" signals for each 360' rum of thβ host The pairs of X, Y readings are fit in a least square vehicle and supplies these values to file 166. File 166 sense to the eUipucal equauon derived below. The stansupplies the U", V, W" signals and the minimum and 55 dard elhpse equauon with center at the coordinate center and semimajor axis a m the x direction (seminunor maiimnm values on a timed basts to compensation process function block 171 which performs the funcnoαs of axis b in the y direction), FIG. 1, is given by: blocks 124. 132. 138 in FIG. 2 and which computes and * _-ι /α ι + ϊ ι m , (61) furnishes the biases B„, Bo B„ on bias line 172 to subtracter 170 where they are subtracted from U", V", W" 60 Muluplymg through by b 2 and subsututmg m the respectively. The output of subtracter 170 is suppbed on definition of eccentricity, e path 174 to register suck 176 which supplies (U"—B u ) on path 178 to each of multiply funcαon cuclea 180, (42) 182; (V"— £,) on path 184 to each of mulnply funcoon circles 186. 188, and W~B W ) on path 190 to each of 65 gives: multiply function cuclea 192, 194. Values an, an, an, *l l . » M» » 1 ». *r« provided to multiply function βifβl«s 180, 186, 192, 182, 188. 194 respectively from process 4,797,841 17 18 Usmg the definition of horizontal radius give: bi, bi, bj ba. bs. Since it is a hnear equation it need not < * ) be iterated. To generalize this equauon to allow any coordinate Subsututmg the sensitivity values r-w, mi, mi, raj, n . frame orientation. X must be replaced by a rotated tns m equation (72) for the terms x 2 -t-y 2 , 1. x 1 —y 1 , value of X — 2xy, 2x and 2y, respectively, gives: XmCX-sr (63) «ι.— i>i|»| 4.mi4i4.«il i .*i «<4.Ms4j (71) row mat u with elements (n « mi, mi, let B be the column matrix with coeffi¬ (72) becomes a,m(MKS> (74) Sunpluying and dropping the prunes: Each tune new measuremenu of readmgs x and y are obtamed new values of m»and M are obtained. The least - l -* 2 + K 2 -2» 2 /n-- 2 )4-* J Cι (2-c 2 H* , -l' 2 l- squares matru equauon which uses all of the measure- 4-« 2 Jι/H-r ! M-«n (61) menu is given by: 30 Equanon (68) is a valid equanon for an ellipse in any W4 τ m,) ϊ{MTm.m (75) oπenutoo, and it is linear in the unknown coefficient values; substituting coefficienu at, ai, ai for the coefficiWhere the summanon is across all measuremenu and enu in equauon (68). the superscript T designates the transpose of the matrix. When written out in terms of the elements equauon -χi+ y 2 ., l4 .βj(Λr 2 - r')*βji-vn, (69) (75) becomes: The definition of coefficienu aι, a], ai u obvious from comparison of the forms of equanons (68) and (69); (74) It is still necessary to make an adjustment so that an 4 0 Xrnomt Xffiimi Xmiflη lm\m\ ∑Λtt-H Imtrnt offset from the x, y center of the ellipse to an offset Xmomi £mιm] imimj imjmt Xrninu X jmi center having coordinates x-, y„ is provided for. This Xai-mj Xmiffi] Xntj i Imjmy Xmymt Xjnjtts can be done by substituting m equauon (68) as foUows: i*0»4 £nt|fl lrnι- 4 2mjmχ Xm4fH4 Imtm} *-<*-*.) ua ϊm(,-y,) (70) i i OfliJ feni-if imjms Xmjπ s βumt ∑mjmj ((I 4- *it . 4- evtJKM 5 ) If all the elemenu of the matrices in equanon (76) Substituting calibrauon coefficienu bi, bi, bi bs, bj which contam the summanon of productt of the values for the coefficienu equauon (71) gives a hnear equaof "m" are set to zero before the calibration process is uon of the form: begun then the elemenu of these matrices can be < i -I i ' -*l .»!(- J -y 1 > -*l<-Jj,. 60 formed sequentially by forming each of the products y)*tH( i* U» (72) (mtatj) for the current measurement and adding it to the cumulated values of the appropriate element ("t" in the The definition of coefficienu bi, b], bjba. bs is obviabove product vanes from 0 to 5. while "j" vanes from ous from comparison of the forms of equations (71) and I to 3) my. 5 When all of the measuremenu have been mcluded Pairs of x, y measureroenu are inserted mto equanon mto equation (76) then the equanon is solved for the (72) and it is solved for the entire set of measuremenu in values of calibration coefficients bi to bj, as follows: a standard least squares sense for the set of coefficients In matnx form. 4,797,841 19 20 (85) solve for the cosine and sine of *HX< 4t r »f)r 'lϊMf ".-! f 7* t of the semimajor axis: The matru (∑IMTM))-' is the mverse of the matru (M'M) and can be found in standard methods, de- scribed for example m Suusucs in Physical Science, by (•4) N I - Cι 2 Walter Clark Hamilton. Ronald Press. New York. N.Y. ( 1964) and the resultant values of b|, bi, bj. ba. bs obSl ilO tamed directly from equation (77) by standard methods such as Gauss elumnation defined n Compuutional 10 Else Methods of Linear Algebra, author V. N. Faddeeva, Dover Publications. New York. N Y. (1959) (17) The coefficients bi, bj, bi b . bs are processed further. ■ Cι/2 First it is noted that: U i < O lben J - -5 (II) «ι-*ι C - Sl/iiS) «J«6| (71) The outpuu from equations (86) and (87) are then used to obtam; The values of baand bs are used to solve for x«and y», the offset center coordmates of the ellipse, by using the 20 β-ARCTAN (S. O (19) values of bi and bj (at and aj. respecnvely) This completes the solution for all parameters of an <l -*?)ι.4.»lr,-6» arbitrary ellipse in the horizontal plane. »J».4-(l 4.4ι) -4j (TV) 25 The values obtamed from equations (80), (83) and (84) completely define the ellipse and the values ι, Ki. from equations (68), (69) and (78): and K) of equations (47), (48) and (49) above. The solution from equation (49) proceeds as previously described. (•0) c»/(2 - r 1 ) . \*ι» + ej 2 30 Referring now to FIGS.5A.5B and 6, and in particular FIGS. 5A and SB. a flow chart diagram of the sec¬ Let ond embodiment of this invention is shown. The symbolism described for FIG. 2 applies to FIGS. 5A, SB. Further, common reference numerals m the diagrams of 35 FIGS.2 and 5A, 5B pertain to common functions in the respective flow charts and descriptions of the common fuπcuons are not repeated in the following description solving for , and y σ : of FIGS. 5A, SB. Let D-l-t ) 2 -**,) 2 Readings from block 40 provide on path 220 a sensor (II) 40 scale input to Scale Readmgs by the Current Sensor From equation (80) Scale block 222 and to Scale B«, B* B» by the Current Sensor Scale block 224. Block 222 receives on path 226 D-1-* 1 rune filtered outpuu from block 72 which are scaled according to the mpuu from path 222 and the scaled Let 45 outpuu from block 222 are fed to In Calibrate Mode j,-β,-|t l .*ι)-6]»ιl/i decision make 98. If the operator has switched the system to the calibrate mode, then the outpuu on path 96 ,,-*,-(»)< I -*l)-*4*l|/β («) are fed via "YES" path 100 to Automatic Mode decision make 102. If the operator has switched the system The offset biases B», y are by definition, equauon to automatic mode, the outpuu on path 100 are fed via (S3), the values - , y Λ respecuvely. 50 "YES" path 104 to Form Sensinvity Values for MeaFrom equauon (5) the flattening factor f is: surement Parameters circuit 22&>The X and Y values in <» /. ι - >l7T7 (M) (! -/> . \ l - r 2 - l _ 2JT/0 4- K) \ ( I _ A0/(1 4- X) I 4- a cucuit 228 are expressed in U, V and W values from Usmg equauon (80): straightforward trigonometric relations and coefficienu bt-bj are provided. The mo-ms values are as defined Cj-»j/Jt 65 from equanon (73). The measurement values values and coefficienu from cucuit 228 are fed on path 230 to s,- /K <«3 ) Incorporate Measurement Parameters and Coefficienu mto the Least Squares Matru cucuit 232 wherein val- 4,797,841 21 22 ues mo-mi are matπxed with the coefficienu b|-bj as Block 272 performs the functions of circuits 228 and defined in equations (72M76) above 232 m the flow diagram of FIGS 5A, 5B and block 274 The output of cucuit 232 is fed on path 234 to performs the functions of circuits 244. 248 256 in the Enough Measurements decision make 236 wherein it is diagram of FIGS. 5A. 5B The values an, an, an, aji. determined if there are enough measuremenu to proaji, an are provided from Junction block 274 to multivide a least square fit to continue the process A test for ply function blocks 180, 186, 192. 182. 188. 194. respecthis determination is if the host vehicle has made a comtively, and bias values B», B,. B» are provided from plete 360' turn When there are not enough measurefuncnon block 274 in path 172 to subtracter 170 and menu. a signal is provided on "NO" path 238 to Exit from there the circuit descπption and function are sum240 and the process restarts When there are enough lar in the diagrams of FIGS 4 and 6 measurements the process continues on "YES" path Whereas in most cases the two dimensional horizon242 with the matru cucuit 232 resul being supplied to tal embodiment described above is sufficient, an extenInvert Matrix Equation circuit 244 where the values of sion mto three dimensions if required is straightforward coefficienu bi, b], bj, ba. bi are obtamed as explained A three dimensional embodiment would be important for equauon (77) above From there coefficienu bι-bs when either pitch and roU are constant for long periods are fed on path 246 to Computer Ellipse Parameters of tune and then change abruptly, or the magnetic laticircuit 248 where the values in equations (80). (82), (83), tude and hence the magnetic field "dip" angle changes (84) and (85), above, are computed and the values Cj, appreciably. Since both of these situauons can signifiSi are fed on path 250 to Compute β for Manual Reencantly change the earth's magnetic field strength and/or try cucuit 252 where equations (86), (87), (88), (89) 20 the vertical component of the earth's field, a change in above are computed and 0 and the ellipse parameters either the size or bias offset of the ellipse tn the horizonare fed on path 254 to Compute Calibration Parameters tal plane can occur cucuit 256 The three dimensional model is an ellipsoid formed If the operator has set the system for manual operaby routing an eUipse about its semimajor axis allowing tion, an enable signal is sent from Automatic Mode 25 the equivalent rotated semunmor axis vector to trace an decision make 102 on "NO" path 108 to Manual Entry ellipse, defined as the manor elhpse The semimajor axis circuit 260 where manual entry of the B„ By, 0, and b would again be aligned with the direction at which the values, determined from previous calibration cycles, host vehicle induces a maximum m the magneuc flux may be made as are manual entries to circuit 110 in the -- density. This ellipsoid effect can be described by su FIG.2 embodiment Cucuit 260 entered values are then terms: fed on path 262 to Compute Ci and Sj cucuit 264 and (1) a— scaling along the semimajor axis of the ellipthen passed on path 266 to circuit 256. The indicated soid. values in cucuit block 256 that are common to those in (2) b— caling along the semimajor axis of the minor block 132. FIG 2, are similarly computed as previously 35 ellipse. described for block 132. (3) c— scaling along the semunmor axis of the minor The "f" and "g" values are from equation (84). The ellipse, values Kι, Ki, Kj, an, n, an, au. an, n are deter- (4) 0— the angle between North and the semimajor mined as for the embodiment of FIG. 2. The B u , B„ B. axis of the ellipsoid m the horizontal plane of the host values defined in terms B„ B. as shown in circuit block 0 vehicle. 256 are straightforward trigonometric conversions of (5) φ— the angle between the horizontal plane of the Bi, By. After all calibranon parameters indicated in host vehicle and the semimajor axis of the ellipsoid block 2S6 are performed tor a 360 * turn of the host (6) β— the angle of rouuon of the minor eUipse with vehicle, or from manual entry m block 260. the com- respect to the semimajor axis of the ellipsoid The ellip- puted calibration parameters are fed on path 268 to Exit 5 uc model for the two dimensional embodiment de- 270 and from there are applied to path 96. If the opera- scribed earlier is an horizontal "slice" through this ellip- tor has switched the system out of calibrate mode, then sold. The effect of pitch and roU on a suspended flux the calibrauon parameters are fed on "NO" path 136 to gate sensor where a certain oπenuuon is maintained for circuit 224 and path 276 to cucuit 138 where the cab- a long ume and then abruptly changed is to change the bratjon parameters are processed as previously de- 50 horizontal slice through the ellipsoid By changing thu scribed for the embodiment of FIGS. 2 and 4 to obtam slice the parameters describing the ellipse could change, the heading The effect of changing the magneuc field dip angle Referring to FIG.6. a block diagram similar to that of would be to change Φ, the angle between the horizontal FIG. 4 is shown and has the same dehneatton between plane of the host vehicle and the eUip oid's semimajor hardware and software controlled dau processmg sys- 53 axis, and translate the three dimensional center of the terns as described for those of FIG 4 The FIG. 4 du- ellipsoid. The net effect on the horizontal shce of the gram tmpletnenu the flow diagram of FIG. 2 while the ellipsoid received by the sensor u to translate the ongtn FIG.6 diagram implements the flow dug am of FIGS but maintain the shape of the ellipse with the possible SA. SB. Componenu with common reference numerals excepuon of overall scale. The net effect to the horizon- perform similar functions and have sumlar outpuu in 60 tal calibration u a change in the bus values. Also, this the diagrams of FIGS 4 and 6. The essential differences invention can be used with a speed log mput, or other between the dugrams of FIGS.4 and 6 are that funcnon speed mput, of the host vehicle to obtam a navigational block 168 in FIG 4 is replaced by Form Least Squares system for the host vehicle Further, in a two winding Matrix function block 272 m FIG.6 and Compensation magnetometer, the computation is simplified since eon- Process function block 171 in FIG 4 ts replaced with 65 version mappmg between the two wmding and three Matrix inversion and Compensation Process function winding models u unnecessary block 274. but otherwise the diagram blocks and func- While there have been described above the principles lions in FIGS 4 and 6 are similar of this invention in connection with specific embodi- 98/48292 102 4,797,841 25 26 -continued P 3 -U(t-2), P -V(t-3). P 5 -W(t-4). -i - Ai » 4-/C l P6»U(t-S), P 7 »V(t-6); where for the W read- g F=W"(ι), Pι »W(t), PjβUd- l). an - JJti «ιι ■ 2JTι p,_V(t-2). P4-W(t-3), P,*U(t-4). P»«.V(t-5), Pτ-W(t-6) and where t=pι«sent - M7 3 * Ai, -- Kι . VT Kt - K, ume and (t— n) is the tune equal to the present tune t minus the next previous n ume units •II - - V7 AT, - A-i an - - NT ΛTt - K) 11. The apparatus of claim 10 wherein said filtered outpuu from said three windings are U", V", " respectively and said two winding outpuu are X, Y rea, a, B. . ( T a, - Λ,)/I spectively, and said fifth means converts to the said two winding outpuu by obtaining: *. - <- V7 a, - a r vi. Jf-«| 1 (ϋ"-*„)4.«| ""-Λ)4-«|j(»"-*.) 6. The apparatus of claim S wherein the number of windings m the compass is three and the three windings r—.,(U -β.)4.«jj(r--Λ)4.0i3(H"-2l.) are arcuately spaced 120" from one another and the outpuu from the three windings are U, V, W respec12. The apparatus of claim 11 wherein said fifth tively, said first means cαmpnses push down suck means is for normalizing the X, Y outpuu to obtain X', 20 means for obtauung tune filtered outpuu U". V", W" Y , respectively, as follows. having the form: F_ F, - />, - IP] 4 Λ - U>] - f, 4. * X jr/VTTT" " 98/48292 104 4,797,841 27 28 16. The method of claim 14 including a seventh step of normalizing said two windings outputs by dividing •continued B m [X(Λ* 2 Λf)|- '(X(.H-r«ι«>| each of said two windings outpuu by the square root of the sum of the squares of each of said two windings where the matnx ((M 'M)] - ' is the inverse of the matnx outpuu 2(M*M) 17. The method of claim 14 including an eighth step said calibration parameters comprise: of sensing the amplitude of the wmdmg outpuu and increasing or decreasmg the amplitudes of the wmdmg outpuu to fit within a predetermined sensor scale of A-d - r 2 ) - 4; 2 4- 4ι 2 amplitudes. 10 18. The method of claim 17 wherein said eighth step ln l 4- 4) 2 D m I - AT 1 comprises integrating the wmdmg incremental outputs and increasing the number of winding incremental outi |4 4 (l 4- In) - 4j»ι|/X> B y - [Ml - 4ι> - ttt, D puu integrated when the wmdmg outpuu fall below the sensor scale and decreasmg the number of wmdmg 15 I (I *)/<! Cl » 4J/A- incremental outpuu integrated when the wmdmg outpuu are above the sensor scale, to fit the outpuu within S\ « ty/K a predetermined sensor scale of amplitudes. 19. The method of claim 14 wherein said geometrical I 4- * *| - I - fCx figure for the distorted vector outpuu is in the shape of 20 - I 4- fCx an ellipse and the geometric figure for the undistorted *! K) vector outpuu is in the shape of a circle; "11 » 1*1 said generalized equauon being; x 2 +r l -4|4i(s 1 -r')4.4)(-lr,>4-44<W4.4j(2» ■ NT AT| - κ -NT Xi - K, • - NT *| - ATj βjj - - N7 κ t - κ, , 30 i a, a. - (NT B t - B,yι , - (- NT ι • ByVl. 35 20. The method of claim 14 wherein said first step comprises compensating for the on gin offset due to the permanent magneuc distortion effect of the vehicle on the compass vector outpuu, said offset being the difference between the vector origin location of the distorted 40 vector outpuu for all headings of the compass and the vector origin locauon of the undistorted vector outpuu for all headings of the compass; t - (a 2 - a 2 )/. 2 said first step further comprising compensating for the difference in configurauon of geometric figures defined by the distorted vector outpuu and the undistorted vector outpuu due to the mduced magnetic distortion effects of the vehicle on the compass vector outpuu for all headings of the compass. 21. Apparatus for calibrating the distortions in the readmgs of a magneuc compass havmg a plurality of windings m a two dimensional plane and mounted in a Xm\mt lm\mt Xs»l«*l Xeitaw X«ιa»s vehicle comprising: J first means coupled to the compass windings ' for ob¬ X"β"j %m\mt l fiti i iβ tauung the outpuu from each of the windings; iMim) impnt 1mm i*n»tj 55 second means coupled to said first means to form Xmgau Xstl-U X"V"U 1-V imtm* Imt-n) from said windings outpuu measurement paramem)jns iojrn, ters havmg sensitivity values; said sensutvity values X*t*»l stsms being variables in a generalized equanon that repre- sen the configurauon and location of a geometri¬ 60 cal figure defined by the locus of coordinates of said outputs, said outpuu havmg distortions due to permanent and mduced magnetism of the vehicle and distortions due to winding unbalance between and misorientanon of the magnetic compass wind¬ 65 ings; said second means for defining calibrauon coefficienu of said measurement parameters said equauon; 98/48292 105 4,797,841 29 30 third means coupled to said second means to incorpomeans for applying said calibration parameters to rate said measurement parameters and said calibrasaid outpuu from said first means to form an output tion coefficienu mto a least squares matnx and to from each of two windings; said two windings solve for said calibrauon coefficienu; being Orthogonally related to one another: fourth means coupled to said third means for computsixth means coupled to said fifth means for obtaining ing calibrauon parameters from said calibration the calibrated compass heading from said two coefficienu that are to be applied to said outpuu; windings outputs. fifth means coupled to said first means and said fourth 15 20 25 30 35 40 45 50 53 60 65

Claims: What is claimed is: 1. Apparatus for calibrating the distortions in the readings of a magnetic compass having a plurality of magnetic field sensors comprising: first means coupled to the compass sensors for obtaining the outputs from each of the sensors as a function of time by weighting and combining the outputs from each of the sensors at a first time and for a predetermined number of the next previous times to said first time to obtain a time filtered output for each of the sensors; second means coupled to said first means to form from said sensors outputs measurement parameters having sensitivity values; said sensitivity values being variables in a generalized equation that represents the configuration and location of a geometrical figure defined by the focus of coordinates of said outputs, said outputs having distortions due to permanent and induced magnetism of the vehicle and distortions due to sensor imbalance between the misorientatioπ of the magnetic compass sensors: said second means for defining calibration coefficients of said measurement parameters in said equation; third means coupled to said second means to incorporate said measurement parameters and said calibration coefficients into a least squares matrix and to solve for said calibration coefficients; fourth means coupled to said third means for computing calibration parameters from said calibration coefficients that are to be applied to said outputs; fifth means coupled to said first means and said fourth means for applying said calibration parameters to said outputs from said first means to form an output from each of two sensors; said two sensors being orthogonally related to one another; sixth means coupled to said fifth means for obtaining the calibrated compass heading from said two sensors outputs; and further comprising means for obtaining said outputs at a selected rate sufficient to characterize the high frequency signature of transient magnetic disturbances; and means for rejecting those sensor outputs obtained which exhibit said characterized signature to not us? those outputs. 2. The apparatus of claim 1 including seventh means coupled between said fifth means and said sixth means for normalizing said two sensors outputs by dividing each of said two sensors outputs by dividing each of said two sensors outputs by the square root of the sum of the squares of each of said two sensors outputs. 3. The apparatus of claim 1 including eighth means coupled between each of said compass sensors and each of said first means and said second means for sensing the amplitude of the sensors outputs and increasing or decreasing the amplitudes of the sensors outputs to fit within a predetermined sensor scale of amplitudes. 4. The apparatus of claim 3 wherein said eighth means comprises integrating means for integrating the sensors incremental outputs and increasing the number of sensors incremental outputs integrated when the sensors outputs fall below the sensor scale and decreasing the number of sensors incremental outputs integrated when the sensors outputs are above the sensor scale. 5. The apparatus of claim 1 wherein said geometrical figure for the distorted vector outputs is in the shape of an ellipse and the geometric figure for the undistorted vector outputs is in the shape of a circle; said generalized equation in said second means being: x 2 +y 2 =b 1 +b 2 (x 2 -y 2 )+b 3 (-2xy)+b 4 (2x)+b s (2y) in said second means said measurement parameters being m 0 , m„ m 2 , m 3 , m 4 , m 5 and having the sensitivity values ^+y 2 , 1, x 2 - , -2xy,2x and 2y, respectively; in said second means said calibration coefficients comprise: b, = [a 1 -(1-a s )x 0 2 -(1+a 2 )y 0 2 -2a,x 0 y 0 ] b 2 β a 2 b 4 = Kl-a j jxo+aay,,] b s = [(1+a 2 )y 0 +a,Xo] where a, = 2b /(2-e 2 ) a 2 = e 2 (C 2 /(2-e 2 ) a, = e 2 S 2 /(2-e 2 ) a ■ semimajor axis of ellipse b = semiminor axis of ellipse c - a 2 - b ia 2 C 2 = cosine (20) and S 2 ■ sine (2θ) θ m rotation angle of ellipse x,y = coordinates of center of ellipse prior to offset x ϋ ,y 0 - coordinates of offset center of ellipse said least squares matrix in said third means comprises: where the matrix [Σ( T M)] '1 is the inverse of the matrix Σ(M 7 M) said calibration parameters in said fourth means comprise; K -JbfTbl 1 - K B, = [& 4 (1 + D j ) - b^ D B y - [&,(1 - b 2 ) - b.bJID h = V(1 - )/(1 * ) C a - bJK S 2 = bJK f = 1 - h - 1 + n , - g - J c 2 K j - J S, K 3 - g + ( a„ - 2K, a = 2 , a 42 = ^3~ K, - /C, β„ - fl y fl v - (>/3 β χ - β y )/2 6. The apparatus of claim 5 wherein the number of sensors in the compass is three and the three sensors are arcuately spaced 120° from one another and the outputs from the three sensors are U, V, W respectively, said first means comprises push down stack means for obtaining time filtered outputs U", V", W" having the form: F = P^-P^-lP^P^iP.-P^P, where for the U reading F=U"(t), P,=U(t), P 2 = V(t-1), P, = W(t-2), P 4 = U(t-3), P 5 = V(t-4), P„ = W(t-5), P 7 - U(t-6); where for the V reading F = V'(t), P, - V(t), P 2 - W(t-1), P 3 = U(t-2), P 4 = V(t-3), P 5 - W(t-4), P 6 = U(t-5), P 7 = V(t-6); where for the W reading F-W"(t). P,= W(t), P 2 = U(t-1), P 3 - V(t-2), P 4 ■ W(t-3), P 5 = U(t-4), P, = V(t-5), P 7 = W(t-6) and where t= present time and (t-π) is the time equal to the present time t minus the next previous n times units. 7. The apparatus of claim 6 wherein said filtered outputs from said three sensors are U", V", W" respectively and said two sensor outputs are X, Y respectively, and said fifth means converts to the said two sensor outputs by obtaining: X - a ,ψ" - B u )+a, 7 (V» - B v )+a, 3 (W» - B w ) X - a^l/" - B u )+a V» - BJ+a„{W« - B 8. The apparatus of claim 7 wherein said fifth means is for normalizing the X, Y outputs to obtain X', Y', respectively, as follows: X' - Xlj 1 + Y 2 V = Y/ 2 + Y 2 9. The apparatus of claim 8 wherein said sixth means is for obtaining the heading arc tangent from X', Y\ 10. The apparatus of claim 1 wherein the number of sensors in the compass is three and the three sensors are arcuately spaced 120° from one another and the outputs from the three sensors are U, V, W respectively, said first means comprises push down stack means for obtaining time filtered outputs U", V", W" having the form: F - P 1 -P 2 -2P 3 44P 4 -2P J -P β - > 7 where for the U reading F=U"(t), P 1 = U(t), P 2 = V(t-1), P 3 = W(t-2), P 4 = U(t-3), P 5 * V(t-4), P β = W(t-5), P 7 = U(t-β); where for the V reading F = V"(t), P, = V(t), P 2 = W(t-1), P 3 - U(t-2), P 4 = V(t-3), P 5 - W(t-4), P 6 = U(t-5), P 7 = V(t-6); where for the W reading F = W(t), P, = W(t), P 2 = U(t-1), P 3 = V(t-2), P 4 = W(t-3). P 5 = U(t-4), P 6 = V(t-5), P 7 = W(t-β) and where t = present time and (t-n) is the time equal to the present time t minus the next previous n time units. 11. The apparatus of claim 10 wherein said filtered outputs from said three sensors are U'\ V", W" respectively and said two sensor outputs are X, Y respectively, and said fifth means converts to the said two sensor outputs by obtaining: X = a„(U« - B u )+a (V» - BJ+a^W" - BJ Y = a v {U" - B a 22 (V" - BJ+a^W ' - B w ) 12. The apparatus of claim 11 wherein said fifth means is for normalizing the X.Y outputs to obtain X', Y\ respectively, as follows: X' - Xi θTψ~ y - Y/fi W 13. The apparatus of claim 12 wherein said sixth means is for obtaining the heading arc tangent from X * , Y\ 14. A method for calibrating the distortions in the readings of a magnetic compass having a plurality of magnetic field sensors comprising the steps of: a first step of obtaining the outputs from each of the sensors; a second step of forming from said sensors outputs measurement parametershaving sensitivity values; said sensitivity values being variables in a generalized equation that represents the configuration and location of a geometrical figure defined by the locus of coordinates of said outputs, said outputs having distortions due to permanent and induced magnetism of the vehicle and distortions due to sensor imbalance between and misorientation of the magnetic compass sensors; said second step defining calibration coefficients of said measurement parameters in said equation; a third step of incorporating said measurement parameters and said calibration coefficients into a least squares matrix and solving for said calibration coefficients; a fourth step of computing calibration parameters from said calibration coefficients that are to be applied to said outputs; a fifth step of applying said calibration parameters to said outputs from said first step to form an output from each of two sensors; said two sensors being orthogonally related to one another; a s dh step of obtaining the calibrated compass heading from said two sensors outputs; and further comprising the step of obtaining said outputs at a selected rate sufficient to characterize the high frequency signature of transient magnetic disturbances; and the step of rejecting those sensor outputs obtained which exhibit said characterized signature to not use those outputs. 15. The method of claim 4 wherein said first step compπses obtaining the outputs from each of the sensors as a function of time by weighting and combining the outputs from each of the sensors at a first time and for a predetermined number of the next previous times to said first time to obtain a time filtered output for each of the sensors; 16. The method of claim 14 including a seventh step of normalizing said two sensors outputs by dividing each of said two sensors outputs by the square root of the sum of the squares of each of said two sensors outputs. 17. The method of claim 14 including an eighth step of sensing the amplitude of the sensor outputs and increasing or decreasing the amplitudes of the sensor outputs to fit within a predetermined sensor scale of amplitudes. 18. The method of claim 17 wherein said eighth step comprises integrating the sensor incremental outputs and increasing the number of sensor incremental outputs integrated when the sensor outputs fall below the sensor scale and decreasing the number of sensor incremental outputs integrated when the sensor outputs are above thβ sensor scale to fit the outputs within a predetermined sensor scale of amplitudes. 19. The method of claim 14 wherein said geometrical figure for the distorted vector outputs is in the shape of an ellipse and the geometric figure for the undistorted vector outputs is in the shape of a circle; said generalized equation being; x 2 +y 2 =b 1 b 2 (x 2 -y 2 )-rb,(-2xy)+b 4 (2x)+b s (2y) said measurement parameters being m 0 , m„ m 2 , m 3 , m 4 , m 5 and having the sensitivity values χ2 +y 2 . 1. x 2 V- -2xy, 2x and 2y, respectively; said calibration coefficients comprise: b, = [a 1 -(1-a 2 )x 0 2 -(1+a 2 )y 0 2 -2a 3 x 0 y 0 ] b 2 = a 2 b, ■ a a where a, = 2b 2 /(2-e 2 ) a 2 = e*<tV(2V> a ■ semimajor axis of ellipεe b = semiminor axis of ellipse C 2 = cosine (20) and S 2 = sine (219) θ = rotation angle of ellipse x,y = coordinates of center of ellipse prior to offset x o ,y 0 • » coordinates of offset center of ellipse said least squares matrix in said third means comprises: ∑m 1 m 2 ∑m,m 3 ∑m 1 m 4 ∑m,m 5 ∑m 2 m 2 ∑m 2 m 3 ∑m 2 m 4 ∑m 2 m 9 ∑m 2 m 3 ∑m 3 m 3 ∑m 3 m 4 ∑m 3 m £ ∑m 2 m 4 ∑m 3 m 4 ∑m 4 m 4 ∑m 4 m 5 ∑rryn, ∑m 3 m s ∑m 4 m 9 ∑m s m s b, b, b s b. B = [Σ(M τ M)]- 1 [Σ(M τ m c )j where the matrix [Σ(M T M)] "1 is the inverse of the matrix Σ( T ) said calibration parameters comprise: K - Jbξ bT D - 1 - K β y = [ώ (1 + b 2 ) - β 3 6J/D β y - [& S (1 - b 2 ) - b A bJ/D h - V(1 - K)/(1 + K) C 2 = D j /K S 2 - b 3 /K f - 1 - n g . -l + n K, = g - J C 2 K 2 - J 5 2 K 3 - g * J C 2 a„ - fiκ. - /ς a^ — >β K 2 - K^ B u - B y S V - ( ^ B, - S y V2 β w - (- /§ " β, - β y )/2. 20. The method of claim 14 wherein said first step comprises compensating for the origin offset due to the permanent magnetic distortion effect of the vehicle on the compass vector outputs, said offset being the difference between the vector origin location of the distorted vector outputs for all headings of the compass and the vector origin location of the undistorted vector outputs for all headings of the compass; said first step further comprising compensating for the difference in configuration of geometric figures defined by the distorted vector outputs and the undistorted vector outputs due to the induced magnetic distortion effects of the vehicle on the compass vector outputs for all headings of the compass 21. Apparatus for calibrating the distortions in the readings of a magnetic compass having a plurality of magnetic field sensors comprising: first means coupled to the compass sensors for obtaining the outputs from each of the sensors; second means coupled to said first means to form from said sensors outputs measurement parameters having sensitivity values; said sensitivity values being variables in a generalized equation that represents the configuration and location of a geometrical figure defined by the locus of coordinates of said outputs, said outputs having distortions due to permanent and induced magnetism of the vehicle and distortions due to sensor imbalance between and misorientation of the magnetic compass sensors: said second means for defining calibration coefficients of said measurement parameters in said equation; third means coupled to said second means to incorporate said measurement parameters and said calibration coefficients into a least squares matrix and to solve for said calibration coefficients; fourth means coupled to said third means for computing calibration parameters from said calibration coefficients that are to be applied to said outputs; fifth means coupled to said first means and said fourth means for applying said calibration parameters to said outputs from said first means to form an output from each of the two sensors; said two sensors being orthogonally related to one another. sixth means coupled to said fifth means for obtaining the calibrated compass heading from said two sensors outputs;and further comprising means for obtaining said outputs at a selected rate sufficient to characterize the high frequency signature of transient magnetic disturbances; and means for rejecting those sensor outputs obtained which exhibit said characterized signature to not use those outputs. 1 Claim 22. An apparatus for automatically calibrating a mobile compass 2 having a combination of a compass for providing heading outputs, electronic 3 circuitry and a programmed computer for calibration of the compass comprising; 4 an electronic compass having sensor elements which respond to magnetic 5 fields and provide output signals related to the earth's magnetic field and distortions 6 sensed by the sensor element; 7 means to translate the sensor output signals into digital values; β a computer portion programmed to receive the digital values of the sensor 9 output signals and to perform an ellipse fit and circularization of the ellipse defined o by the output signals to define a circle and to determine heading readings; i a computer portion programmed to define a selected number of angular 2 segments of the circle as bins and to store the heading readings as data points 3 according to the bin in which they fall; 4 a computer portion programmed to offset the ellipse as data points are s acquired; 6 a computer portion programmed to perform calibration of said program being 7 executed upon the appearance of a selected number of one or more data points in s every bin. 1 Claim 23. The apparatus of ciaim 22 wherein said computer is 2 programmed to process incoming data from the compass at a rate at least about 5 3 per second. ι Claim 24. The apparatus of Claim 23 wherein said rate is about 12 per 2 second. l Claim 25. A method of automatically calibrating a mobile compass system /48292 n7 2 mounted in a vehicle, the system having a compass for providing heading outputs, 3 electronic circuitry and a programmed computer comprising; 4 providing output signals from an electronic compass having sensor elements; s translating the output signals into digital data values for use by the computer; 6 allowing the vehicle to be driven without any regulation of its path; 7 performing an ellipse fit and circularization procedure on the output data to s define a circle for the data points; 9 selecting a number of angular segments of the circle to define bins; o identifying data points to a bin according to its position on the circle; offsetting the ellipse as data points are acquired; 2 calibrating the compass when each bin has at least one data point. 1 Claim 26. The method of claim 25 wherein said computer is programmed to 2 process incoming date from the compass at a rate at least about 5 per second, 3 Claim 27. The method of claim 26 wherein said rate is about 12 per 4 second. 1 Claim 28. A system for detection and rejection of transient magnetic 2 anomalies in a mobile compass system having a programmed computer comprising; 3 a computer portion programmed to receive readings from a compass and to 4 characterize from said readings the magnetic signature of the anomaly and to reject 5 use of readings that fall within said characterization.. ι Claim 29. The system of claim 28 wherein said computer is programmed to 2 process incoming data from the compass at a rate of at least about 5 per second. 1 Claim 30. The system of claim 29 wherein said rate is about 12 per second. 2 Claim 31. A method for detection and rejection of transient magnetic 3 anomalies in a mobile electronic compass system comprising; 4 in a programmed computer, receiving readings from a compass and 5 characterizing from said readings, the high frequency signature of the anomaly; and; 6 rejecting use of compass readings that fall within said characterization. ι Claim 32. The method of claim 31 wherein said computer is programmed to 2 process incoming data from the compass at a rate of at least about 5 per second. ι Claim 33. The system of claim 32 wherein said rate is about 12 per second. 2 Claim 34. An integrated location system for mobile use comprising; 3 a primary radionavigation system; a magnetic compass; 5 other sensors selected from the group consisting of; 6 a. a cross-track accelerometer; 7 b. a cross-track accelerometer and a speed sensor; 8 c. an angular rate sensor; 9 d. an angular rate sensor and a speed sensor; lo means for using selected sensor data to determine heading and position. ιι Claim 35. The system of claim 34 wherein said primary 12 radionavigation system is GPS and said means for using selected sensor data to i3 determine heading and position, selects the use of the compass and one or more of 14 the other sensors as the number of GPS satellites providing signals reduces from at is least four to none.

Inventors: HATCH RONALD A, JUDGE KEVIN S, HATCH, RONALD, A., JUDGE, KEVIN, S.
Applicants: GREENFIELD ENTERPRISES INC, HATCH RONALD A, JUDGE KEVIN S, GREENFIELD ENTERPRISES, INC., HATCH, RONALD, A., JUDGE, KEVIN, S.
Application year: 1998
Main classification: G01S
IPC codes: G01C17