tag:blogger.com,1999:blog-4237678261594285909.post8799581456670244109..comments2017-03-21T02:49:52.503-04:00Comments on Sailboat Instruments: Improved magnetometer calibration (Part 2)Merlinnoreply@blogger.comBlogger12125tag:blogger.com,1999:blog-4237678261594285909.post-16173620186751962782014-11-19T01:49:23.199-05:002014-11-19T01:49:23.199-05:00Ignore me. You actually do get (almost) the identi...Ignore me. You actually do get (almost) the identity. Since the data is on a sphere, the orientation for the elipsoid is not well defined. So it appears to be rotated by some (arbitrary?) orientation but still gives you the expected values h_cal for a choice if input h. A further mistake I made was to ignore the variable hm in the code which encodes for the above mentioned 'norm of magnetic or gravitational field'.DrSARnoreply@blogger.comtag:blogger.com,1999:blog-4237678261594285909.post-86420810379986930512014-11-19T01:17:55.642-05:002014-11-19T01:17:55.642-05:00I am messing around with your C-based calibration ...I am messing around with your C-based calibration tool magneto and am trying to feed it some simple data such as <br />1 0 0<br />0 1 0<br />0 0 1<br />-1 0 0<br />0 -1 0<br />0 0 -1<br />.707106781 .707106781 0<br />0 .707106781 .707106781<br />.707106781 0 .707106781<br /><br />I thought these are sampled on a perfect sphere. As expected I get a bias of 0 in all three axis. I would have expected to obtain an A^-1 as the identity. This is not so. What am I doing wrong?DrSARnoreply@blogger.comtag:blogger.com,1999:blog-4237678261594285909.post-34520720271130430922014-11-06T09:50:21.667-05:002014-11-06T09:50:21.667-05:00I am quoting a part of a previous answer as it is ...I am quoting a part of a previous answer as it is directly relevant to your question:<br />"You would then normally choose the maximum positive value as input to the 'Norm of Magnetic or Gravitational field'. <br /><br />But this norm value is not critical if all you want to calculate later on is a heading (if it is a magnetometer) or a tilt angle (if it is an accelerometer). You can input any reasonable value for the norm, the correction matrix will be different by just a scaling factor, but the calculated heading (or tilt angle) will be the same, as it depends only on the relative value of the field components. The bias values will be unchanged, as they do not depend on the norm."<br />In other words, inspect your output values and use the largest, which will likely represents the field magnitude when the sensor is aligned with it.Merlinhttp://www.blogger.com/profile/00901116173524809046noreply@blogger.comtag:blogger.com,1999:blog-4237678261594285909.post-15304383585360019792014-11-06T00:11:29.738-05:002014-11-06T00:11:29.738-05:00Could I ask you to explain how you find the value ...Could I ask you to explain how you find the value "norm of magnetic or gravitational field" please? This has a big effect on the results and I don't know how to find this value for the program. Thank you.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4237678261594285909.post-90742438463290858502012-04-24T10:12:44.536-04:002012-04-24T10:12:44.536-04:00Magneto expects to receive raw data in +- format (...Magneto expects to receive raw data in +- format (a value of zero indicating a null field in the current axis), but not necessarily normalized to +-1.0. <br /><br />If your sensors have SPI or I2C outputs, they will usually directly produce the required format. For example, the MicroMag3 magnetometer directly produces counts from -3411 to +3411, and the the SCA3000 accelerometer directly produces counts from -1333 to 1333, and Magneto can process direcly these values, without the need to normalize them to +- 1.0. I understand that a normalization may be desirable to avoid machine precision problems, but this has not been the case with these sensors.<br /><br />If your sensors produce voltage levels that you have to convert to counts with an ADC, you have indeed to substract a zero field value from the ADC output before using Magneto. You would then normally choose the maximum positive value as input to the 'Norm of Magnetic or Gravitational field'. <br /><br />But this norm value is not critical if all you want to calculate later on is a heading (if it is a magnetometer) or a tilt angle (if it is an accelerometer). You can input any reasonable value for the norm, the correction matrix will be different by just a scaling factor, but the calculated heading (or tilt angle) will be the same, as it depends only on the relative value of the field components. The bias values will be unchanged, as they do not depend on the norm.Merlinhttp://www.blogger.com/profile/00901116173524809046noreply@blogger.comtag:blogger.com,1999:blog-4237678261594285909.post-44412969733544717462012-04-24T03:12:34.471-04:002012-04-24T03:12:34.471-04:00Hi Mr. Merlin
I am a bit confused about the input...Hi Mr. Merlin<br /><br />I am a bit confused about the input data. When you say 'raw data', does it mean the data come from ADC (whose unit is 'counts') ?<br />I've looked into your sample data (sample.txt), and i found the value of all data are less than 1 and greater than -1 . <br />How did you get this 'raw data' ?<br />do we have to calibrate the ADC output first using parameter provided in the datasheet?<br /><br />Thank you for your support.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4237678261594285909.post-39596890813135920512012-04-22T13:01:45.821-04:002012-04-22T13:01:45.821-04:00Very nice work. Helps me a lot to write a calibrat...Very nice work. Helps me a lot to write a calibration routine for my lowcost MEMS-Magnetometer. Thank you for sharing.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4237678261594285909.post-44618236908371324552012-01-25T22:05:40.882-05:002012-01-25T22:05:40.882-05:00I have taken a step further in porting the Magneto...I have taken a step further in porting the Magneto source code to 100% C-language. It is available at:<br /><br />https://sites.google.com/site/sailboatinstruments1/c-language-implementationMerlinhttp://www.blogger.com/profile/00901116173524809046noreply@blogger.comtag:blogger.com,1999:blog-4237678261594285909.post-17220762246983835212012-01-23T09:19:23.333-05:002012-01-23T09:19:23.333-05:00For those who have inquired on the possibility of ...For those who have inquired on the possibility of porting the Magneto source code to an embedded system, here is a site with extensive matrix source code in C language:<br /><br />http://www.mymathlib.com/matrices/<br /><br />Be aware that there is an important difference in the way the matrix elements are stored in memory between Fortran and C. In Fortran, the elements are stored column by column, while in C and C++, they are stored line by line. <br /><br />And the Moore-Penrose pseudo-inverse may also be replaced by the normal matrix inverse, as they are normally the same for a square matrix, unless your data set is bad or incomplete.Merlinhttp://www.blogger.com/profile/00901116173524809046noreply@blogger.comtag:blogger.com,1999:blog-4237678261594285909.post-55141313809741610932012-01-10T09:24:07.096-05:002012-01-10T09:24:07.096-05:00It is certainly possible, if you can find or devel...It is certainly possible, if you can find or develop an alternate math library (instead of Fortran) for matrix calculations. Matrix multiplication and inversion code are readily available, eigenvalues calculations may be harder to come by. I would strongly consider a 32-bit microprocessor for such a task.Merlinhttp://www.blogger.com/profile/00901116173524809046noreply@blogger.comtag:blogger.com,1999:blog-4237678261594285909.post-5987584380806047012012-01-10T04:51:58.558-05:002012-01-10T04:51:58.558-05:00Hello,
Is it possible to modify the source code ? ...Hello,<br />Is it possible to modify the source code ? Because I would like to implement the algorithm in an embedded system.<br />I can't save a lot of data in a file like in a pc, I have to execute the algorithm with only few data.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-4237678261594285909.post-61993159999340163482011-11-21T00:42:17.759-05:002011-11-21T00:42:17.759-05:00Hi there, awesome site. I thought the topics you p...Hi there, awesome site. I thought the topics you posted on were very interesting. I tried to add your RSS to my feed reader and it a few. take a look at it, hopefully I can add you and follow.Calibrationhttp://bestandards.comnoreply@blogger.com