Jump to content
Sign in to follow this  
drumanart

Math Question

Recommended Posts

Hello,

I made a small PCB for the LSM303 electronic compass. The unit communicates with a I2C protocol and I made my one software functions to communicate with the unit what works great.

Now, to get something useful out of the row data I have to use some math.

Following the app notes of the LSM303 I have to calculate:

 

Heading = arctan (Yh/Xh)

 

Is there a mathematic library in SourceBoost. I work with a licend 6,95 Version.

 

The other thing is that my browser (Chromium with Linux) want show the special signes from other threads correctly.

My browser shows: ( for ( // ( for ) // &#41 for "; and so on ..

 

It is difficult to read the code.

 

Thanks Martin

 

 

 

 

 

 

 

 

 

 

(

Share this post


Link to post
Share on other sites

Martin,

...

Heading = arctan (Yh/Xh)

 

Is there a mathematic library in SourceBoost. I work with a licend 6,95 Version.

No this function is not in the library.

 

Regards

Dave

Share this post


Link to post
Share on other sites

Hi

 

I don't know what specific PIC you are using, but that kind of maths is too heavy for any 8 bit PIC.

A quite common solution for complex mathematical expressions is to solve them by using tables of pre-computed values.

 

As we are talking electronic compass, and the ATAN function, you can create the tables only for the first quadrant (0º to 90º) that has both coordinates (x and y) positive.

You use the absolute values to access the tables and then compute the quadrant from their positive/negative signs.

You must also decide what kind of resolution you intend to have versus available memory for the tables.

 

If you need high resolution and don't have room for the tables, you can also use a two step process. You compute a first approach with a 1º resolution table and then use a second set of tables for refining it to a fraction of a degree.

 

This will require a lot of simulation and error analisys to get the values for the final tabes, but that is easily done with a spreadsheet.

 

 

Just my 2 cents...

 

 

Best regards

Jorge

Edited by JorgeF

Share this post


Link to post
Share on other sites

Thanks for the LUT solution.

As the compass works with 16bit resolution and I have to calculate, beside the heading, also pitch and roll (with an incorporated accelerometer) I thinks the easiest way is to send all raw data (6 bytes for the magnetometer and 6 bytes for the accelerometer) to the computer and solve the "big" calculation with the PC.

I can do this quite straight forward with SuperCollider.

The other thing is, as I mentioned above, that my browser shows rare signs if I lock at other threads:

so, for example: ( for ( // ( for ) // &#41 for ";

Any succestion

Thanks Martin

Share this post


Link to post
Share on other sites

Hi

 

The other thing is, as I mentioned above, that my browser shows rare signs if I lock at other threads:

so, for example: ( for ( // ( for ) // &#41 for ";

Any succestion

Thanks Martin

 

OFF TOPIC

 

Those "&...;" string are html entities. When the content betwen '&' and ';' starts with '#' the digits are the ASCII character code in decimal format.

The html entities are commonly used to code characters, like '<' and '>' as they are reserved HTML characters. The html entities are also widely used to code special localized characters in a localization independent form, like 'á' coded as "& a acute ;" (without spaces), that should render correctly whatever localization / language or char set is declared in the HTML header.

 

It looks like your browser is not interpreting some html entities what is a bit odd.

Or the html parser off your browser is getting out of synch due to some odditie in the page code.

You can do a quick test, open the attached sample file with the browser and you will see a few lines with one character each, if you see the html entities strings then something is wrong with your browser.

 

 

Best regards

Jorge

html_entities.html

Edited by JorgeF

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×