Background technology
In recent years, along with semiconductor technology, the development and the microelectromechanical systems of sensor technology are write a Chinese character in simplified form MEMS, and the application that in the sensing scheme, reaches its maturity has obtained increasingly extensive use based on the electronic compass scheme of miniature earth magnetism sensing chip.The earth magnetism sensing chip can be selected through some kinds of sensing principles according to the difference of its design proposal, writes a Chinese character in simplified form AMR comprising anisotropic magnetic resistance principle; Hall principle writes a Chinese character in simplified form Ha1l or the fluxgate principle is write a Chinese character in simplified form the variation that Fluxgate etc. senses the terrestrial magnetic field.Because geomagnetic field intensity is a trivector, so the earth magnetism sensing chip has three inductive axis X axles, Y axle and Z axles usually.Attitude when the earth magnetism sensing chip comprises the position angle, the roll angle and the angle of pitch, and when changing, the output valve on three axles of earth magnetism sensing chip produces corresponding the variation.These change, through the geomagnetic sensor inside modules integrated proprietary circuit ASIC be converted into digital signal, this digital signal can be through various bus communication agreements, like I 2C; SPI etc. input to miniature central processing unit and write a Chinese character in simplified form MCU.Embedded signal calibration and deflection computing formula in the miniature central processing unit according to the variation of different passage input values, according to corresponding software algorithm, can be calibrated for the first time, computer azimuth angle at any time during also can be after calibration normal use.As shown in Figure 1, device 11 is the geomagnetic sensor module, and wherein inner packet contains the earth magnetism sensing chip 12 and the proprietary circuit chip 13 of CASI based on the AMR principle.Earth magnetism sensing chip 12 has three axle X axles, and Y axle and Z axle are mutually 90 degree omnidirectional distribution.Attitude when chip comprises the position angle, the roll angle and the angle of pitch or unspecified angle wherein, and when changing, the projection of geomagnetic fieldvector on three axles changes.Special, when chip rotates a circle, the projection value on three axles also periodically changes once.Based on 12 outputs of the earth magnetism sensing chip of AMR principle be analog quantity, for the ease of signal Processing, proprietary circuit chip 13 converts three simulation output into numeral output, and passes through I
2The C bus mode sends to host computer with the data of three axles.
Miniature central processor MCU 14, it passes through I
2The C bus receives earth magnetism sensing module data sent.When compass used for the first time, the user need turn around the earth magnetism sensing chip at least in 360 degree space inward turnings.Miniature central processing unit 14 calls the inner calibration procedure that embeds in advance according to one group of data of adopting during this period, and electronic compass is calibrated for the first time and demarcated, be exactly to confirm positive north orientation in other words.This process is by shown in Figure 2.After calibration finished, along with the continuous input of sensing data, miniature central processing unit 14 can call the inner position angle that embeds in advance and calculate program, calculates the position angle in real time.This process is by shown in Figure 3.
Yet; One of defective of above-mentioned electronic compass scheme is: if in calibration process, occur owing to various outside causes cause indivedual abnormal datas suddenly; Calibration algorithm self can't be differentiated; So abnormal data gets into the calibration algorithm flow process, become the part of its data that adopt, cause calibration result to depart from.So when the calibration end, extraneous transient interference is eliminated simultaneously, after external magnetic field recovered normally, azimuthal calculating will produce deviation owing to the benchmark mistake of calibration.
Simultaneously, two of the defective of above-mentioned electronic compass scheme is: even calibration process is normally errorless, and in use occur suddenly because the magnetic field that various outside causes cause is disorderly.Disturbance although it is so is very of short duration, but algorithm itself also can't judge that this belongs to of short duration external disturbance unusually, should ignore, to such an extent as to the position angle that draws according to algorithm also of short duration data deviation can occur.
Be based on the deficiency on a kind of algorithm principle on above-mentioned two kinds of defect theories; Be that algorithm itself does not have the abnormal data that ability differentiates that the disturbance of transient state brings and it is rejected in calibration process or position angle calculating process; In other words, algorithm does not have dynamically extracted valid data.
Summary of the invention
Technical matters to be solved by this invention is the present situation to prior art, provides that a kind of data acquisition ability is strong, data can be judged automatically, the magnetic interference ability strong and the computing method of the correct a kind of electronic compass dynamically extracted valid data of data outbound course.
The present invention solves the problems of the technologies described above the technical scheme that is adopted: a kind of computing method of electronic compass dynamically extracted valid data, this electronic compass includes geomagnetic sensor, it is characterized in that: this method includes the sensor step that powers on: through I
2The C bus is waken geomagnetic sensor up, as the geomagnetic sensor power-up state, gets into the dynamic data extraction step then; This dynamic data extraction step also includes following steps:
Data acquisition step: the geomagnetic sensor after powering on, can gather the t at a time of electronic compass.Dynamic data, and resulting dynamic data passed through I
2The C bus outwards spreads out of; Dynamic data comprises X axis data, Y axis data and Z axis data;
Vector calculation procedure: comprise that the synthetic all synthetic vector meter of peace that calculates of vector calculates, and the synthetic all synthetic vector meter of peace that calculates of vector is calculated and carried out synchronously; Vector is synthetic to be calculated: respectively X axis data, Y axis data and Z axis data are carried out square value and calculate; And the square value with three data being calculated carries out additive operation again; At last the total value after the additive operation is carried out the computing of secondary radical sign, the numerical value that this secondary radical sign computing is obtained is as three resultant vector values of X axle, Y axle and Z axle; Average resultant vector calculates: choose t at a time.Time period Δ t before, and in this time period Δ t, calculate the mean value of resultant vector value; Promptly, calculate n a certain moment t respectively according to the synthetic computing method of vector
1, t
2... t
nSingle resultant vector value, and to after these n the resultant vector value additions divided by n, obtain average resultant vector value;
Vector is judged comparison step: choose a standard variance; Average resultant vector value and resultant vector value are carried out subtraction, and form the vector absolute value; Three times of values with vector absolute value and standard variance compare again, judge whether three times of values of overgauge variance of vector absolute value;
Vector ratio is than result step: when three times of values of vector absolute value overgauge variance, get into acquisition step again; When the vector absolute value does not have three times of values of overgauge variance, get into data and adopted step, and can get into next step program;
Again acquisition step: data are deleted, and these data include the dynamic data in the data acquisition step at least, i.e. X axis data, Y axis data and Z axis data; After being deleted, data are back to data acquisition step.
The measure of taking also comprises:
In the above-mentioned acquisition step again, the data of being deleted also comprise the resultant vector value that calculates to some extent, average resultant vector value, vector absolute value.
The above-mentioned sensor step that powers on is connected with the beginning calibration steps.
Above-mentioned beginning calibration steps and sensor power on to have additional between the step and begin calibration affirmation step.
Above-mentioned begin to calibrate confirm information that step obtains being after, get into the sensor step that powers on; When above-mentioned beginning calibrate confirm that step obtains information not after, be back to above-mentioned beginning calibration steps.
It is whether data travel through the All Quardrants step that above-mentioned data are adopted next step program that is got into after the step; After whether above-mentioned data travel through the information that does not obtain in the All Quardrants step not, be back to the above-mentioned sensor step that powers on; After whether above-mentioned data travel through the information that obtains being in the All Quardrants step, get into miniature central processing unit operation calibration steps.
Get into storage calibration parameter step after the above-mentioned miniature central processing unit operation calibration steps, get into after this storage calibration parameter step and finish calibration steps.
The above-mentioned sensor step that powers on can also be connected with beginning calculated direction angle step; Above-mentioned data are adopted next step program that is got into after the step also can be miniature central processing unit traffic direction angle calculation procedure step, and this miniature central processing unit traffic direction angle calculation procedure step also is connected with above-mentioned storage calibration parameter step.
Get into outbound course angle step after the above-mentioned miniature central processing unit traffic direction angle calculation procedure step; Get into after this outbound course angle step and whether continue calculation procedure.
After the above-mentioned information that whether continues to obtain in the calculation procedure being, whether this continues calculation procedure is back to described beginning calculated direction angle step; After whether this continued to obtain information not in the calculation procedure, whether this continues calculation procedure got into end deflection calculation procedure.
Compared with prior art; The geomagnetic sensor that the present invention adopts has the dynamically extracted valid data calculation procedure, and this dynamically extracted valid data calculation procedure includes power on step, data acquisition step, vector calculation procedure, vector of sensor and judges that comparison step, vector ratio are than result step and acquisition step again.The invention has the advantages that: the data to coming from geomagnetic sensor are screened dynamically, have guaranteed that the output of electronic compass is relatively stable, and the deviation of corresponding transient state can not take place owing to the external disturbance of transient state yet.
Embodiment
Embodiment describes in further detail the present invention below in conjunction with accompanying drawing.
Also the embodiment of the invention includes geomagnetic sensor to shown in Figure 6 like Fig. 4, and geomagnetic sensor has the dynamically extracted valid data calculation procedure, and this dynamically extracted valid data calculation procedure includes the sensor step S42 that powers on: through I
2The C bus is waken geomagnetic sensor up, as the geomagnetic sensor power-up state, gets into dynamic data extraction procedure S40;
This dynamic data extraction procedure S40 also includes following steps:
Data acquisition step S31: the geomagnetic sensor after powering on, can gather the t at a time of electronic compass.Dynamic data, and resulting dynamic data passed through I
2The C bus outwards spreads out of; Dynamic data comprises X axis data S32, Y axis data S33 and Z axis data S34;
Vector calculation procedure: comprise that all synthetic vector meter of the synthetic S35 of calculating of vector peace calculates S36, and all synthetic vector meter of the synthetic S35 of calculating of vector peace is calculated S36 and carried out synchronously;
In step S37, carrying out one judges: if t
0External magnetic field constantly is owing to the interference that receives a variety of causes changes, and so according to theoretical analysis, the resultant vector that these three resolutes are constantly tried to achieve also must be undergone mutation.In other words, inevitable the saying from the statistical significance of this M value constantly belongs to unusual.According to Principle of Statistics, we utilize criterion:
whether make the selection that keeps or reject greater than 3 times standard variance M.
If t
0Data constantly are disallowable, and it can not get into any calculation procedure so, and sensor is waken up to obtain next data constantly again, gets into step S38; If t
0Data constantly are used, and it will get into normal calibration procedure so, if occur in calibration phase unusually; Or position angle calculating program, if occur in the electronic compass operational phase unusually; Get into step S39.
The synthetic S35 of calculating of vector: respectively X axis data S32, Y axis data S33 and Z axis data S34 are carried out square value and calculate, X axis data S32 formula code name is MX (t), and Y axis data S33 formula code name is that MY (t) and Z axis data S34 formula code name are MZ (t); And the square value with three data being calculated carries out additive operation again; At last the total value after the additive operation is carried out the computing of secondary radical sign, its computing formula is:
numerical value obtained of this secondary radical sign computing as three resultant vector values of X axle, Y axle and Z axle;
Average resultant vector calculates S36: choose t at a time.Time period Δ t before, and in this time period Δ t, calculate the mean value of resultant vector value
Promptly, calculate n a certain moment t respectively according to the synthetic computing method of vector
1, t
2... t
nSingle resultant vector value, and to after these n the resultant vector value additions divided by n, obtain average resultant vector value
Vector is judged comparison step S37: choose a standard variance σ M; Average resultant vector value and resultant vector value are carried out subtraction; And form vector absolute value
and again the three times values of vector absolute value
with standard variance σ M are compared, judge whether three times of values of overgauge variances sigma M of vector absolute value
;
Vector ratio is than result step S38: when three times of values of vector absolute value
overgauge variances sigma M, get into acquisition step again; When vector absolute value
does not have three times of values of overgauge variances sigma M; Get into data and adopted step, and can get into next step program;
Again acquisition step S39: data are deleted, and these data include the dynamic data in the data acquisition step at least, i.e. X axis data, Y axis data and Z axis data; After being deleted, data are back to data acquisition step.
Present embodiment is achieved in that in acquisition step S39 again the data of being deleted also comprise the resultant vector value M (t) that calculates to some extent, average resultant vector value
vector absolute value
The sensor step S42 that powers on is connected with beginning calibration steps S30.
Beginning calibration steps S30 and sensor power on to have additional between the step S42 and begin calibration affirmation step S41.
Begin to calibrate confirm information that step S41 obtains being after, get into the sensor step S42 that powers on; When begin to calibrate confirm that step S41 obtains information not after, be back to beginning calibration steps S30.
It is whether data travel through All Quardrants step S43 that data are adopted next step program that is got into behind the step S39; After whether data travel through the information that does not obtain among the All Quardrants step S43 not, be back to the sensor step S42 that powers on; After whether data travel through the information that obtains being among the All Quardrants step S43, get into miniature central processing unit operation calibration steps S44.
Get into storage calibration parameter step S45 after the miniature central processing unit operation calibration steps S44, get into after the storage calibration parameter step S45 and finish calibration steps S50.
The sensor step S42 that powers on can also be connected with beginning calculated direction angle step S51; Data are adopted next step program that is got into behind the step S39 also can be miniature central processing unit traffic direction angle calculation procedure step S47, and this miniature central processing unit traffic direction angle calculation procedure step S47 also is connected with storage calibration parameter step S45.
Get into outbound course angle step S48 after the calculation procedure step S47 of miniature central processing unit traffic direction angle; Get into after the step S48 of outbound course angle and whether continue calculation procedure S49.
After the information that whether continues to obtain being among the calculation procedure S49, whether this continues calculation procedure S49 is back to beginning calculated direction angle step S51; Whether after when continuing to obtain information not among the calculation procedure S49, whether this continues calculation procedure S49 gets into end deflection calculation procedure S52.
The specifying as follows of calibration operation in this practical embodiment:
Beginning calibration steps S30: begin calibration;
Begin calibration and confirm step S41: begin to calibrate confirm information that step S41 obtains being after, get into the sensor step S42 that powers on; When begin to calibrate confirm that step S41 obtains information not after, be back to beginning calibration steps S30;
The sensor step S42 that powers on: through I
2The C bus is waken geomagnetic sensor up, obtain data after this geomagnetic sensor powers on, and resulting data is passed through I
2The C bus spreads out of; Get into dynamic data extraction procedure S40 subsequently; The final section step of this dynamic data extraction procedure S40 is acquisition step S39 again;
Whether data travel through All Quardrants step S43: it is whether data travel through All Quardrants step S43 that data are adopted next step program that is got into behind the step S39; After whether data travel through the information that does not obtain among the All Quardrants step S43 not, be back to the sensor step S42 that powers on; After whether data travel through the information that obtains being among the All Quardrants step S43, get into miniature central processing unit operation calibration steps S44;
Miniature central processing unit operation calibration steps S44; Get into storage calibration parameter step S45 after the miniature central processing unit operation calibration steps S44;
Storage calibration parameter step S45: get into after the storage calibration parameter step S45 and finish calibration steps S50.
The specifying as follows of deflection calculating operation in this practical embodiment:
Beginning calculated direction angle step S51: be connected with the sensor step S42 that powers on;
The sensor step S42 that powers on: through I
2The C bus is waken geomagnetic sensor up, obtain data after this geomagnetic sensor powers on, and resulting data is passed through I
2The C bus spreads out of; Get into dynamic data extraction procedure S40 subsequently; The final section step of this dynamic data extraction procedure S40 is acquisition step S39 again;
Miniature central processing unit traffic direction angle calculation procedure step S47: data are adopted next step program that is got into behind the step S39 also can be miniature central processing unit traffic direction angle calculation procedure step S47, and this miniature central processing unit traffic direction angle calculation procedure step S47 also is connected with storage calibration parameter step S45;
Outbound course angle step S48: get into outbound course angle step S48 after the calculation procedure step S47 of miniature central processing unit traffic direction angle;
Whether continue calculation procedure S49: get into after the step S48 of outbound course angle and whether continue calculation procedure S49; After the information that whether continues to obtain being among the calculation procedure S49, whether this continues calculation procedure S49 is back to beginning calculated direction angle step S51; Whether after when continuing to obtain information not among the calculation procedure S49, whether this continues calculation procedure S49 gets into end deflection calculation procedure S52;
Finish deflection calculation procedure S52.
The invention has the advantages that: the data to coming from geomagnetic sensor are screened dynamically, have guaranteed that the output of electronic compass is relatively stable, and the deviation of corresponding transient state can not take place owing to the external disturbance of transient state yet.
Most preferred embodiment of the present invention is illustrated, and various variations or the remodeling made by those of ordinary skills can not depart from the scope of the present invention.