HMC5883L Magnetometer chip Possibilities.


Closed Thread
Results 1 to 40 of 58

Hybrid View

  1. #1
    Join Date
    May 2013
    Location
    australia
    Posts
    2,682


    Did you find this post helpful? Yes | No

    Default Re: HMC5883L Magnetometer chip Possibilities.

    it works on paper , i'm curious to compile it and see what happens , i'm feeling a cast from word to byte and only a 4 bit r-shift might allow the loss of the sign bit to be ignorable . if it works it saves a lot of steps
    I would christen it as quick and dirty code

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,623


    Did you find this post helpful? Yes | No

    Default Re: HMC5883L Magnetometer chip Possibilities.

    Hi,
    You're quite right Richard!
    It works provided that x in this case IS declared as a byte (which it was in your code of course)
    Code:
    x = Reading >> 4
    HSEROUT["Reading: ", SDEC Reading, "   X: ", SDEC x,10,13]
    Code:
    Reading: -2048   X: -128
    Reading: 2047   X: 127
    Reading: -100   X: -7
    Reading: 100   X: 6
    If x is declared as a WORD then it fails:
    Code:
    Reading: -2048   X: 3968
    Reading: 2047   X: 127
    Reading: -100   X: 4089
    Reading: 100   X: 6
    /Henrik.

  3. #3
    Join Date
    May 2013
    Location
    australia
    Posts
    2,682


    Did you find this post helpful? Yes | No

    Default Re: HMC5883L Magnetometer chip Possibilities.

    thanks for confirming that henrik ,saves me the trouble .
    I worked that out with the windows7 calculator (in programmer mode) it makes it easy to visualise some solutions , another feature sadly lacking in windoze 8.1
    correction
    not lacking in wdoze8 just hard to find like most of anything that's useful
    Last edited by richard; - 30th December 2014 at 12:38.

  4. #4
    Join Date
    May 2013
    Location
    australia
    Posts
    2,682


    Did you find this post helpful? Yes | No

    Default Re: HMC5883L Magnetometer chip Possibilities.

    maybe this will help

    http://www.starlino.com/imu_guide.html
    Attached Images Attached Images  

  5. #5
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103


    Did you find this post helpful? Yes | No

    Default Re: HMC5883L Magnetometer chip Possibilities.

    I still can't understand which vector shows me the magnetic north in this picture ... But as far as I read the datasheet of this IC , it mentions about a term called Hnorth which is the resultant force of X and Y vectors ... so which one is it then ? Is it XY calculation that shows me the north ?

  6. #6
    Join Date
    May 2013
    Location
    australia
    Posts
    2,682


    Did you find this post helpful? Yes | No

    Default Re: HMC5883L Magnetometer chip Possibilities.

    if the device is held so that the xy plane is perfectly!!!! level then the xy angle is magnetic north (sort of). if the device is tilted then the xy angle needs to compensated for that tilt . the device alone cannot really be used as a compass . the device output is a 3d vector as drawn by the black line in my previous post, as you can see the result is relative to the devices orientation , if that is unknown (and it is without an external reference ) then its virtually impossible to ascertain a direction from its output. even a small tilt creates substantial error.
    furthermore magnetic field lines are not parallel with the earths surface they tilt into the earth or up to the sky depending on location. not to mention magnetic inclination/deviation etc
    basically the concept of using this chip as a compass is unworkable see post 47
    Last edited by richard; - 3rd February 2015 at 11:57. Reason: typo

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,682


    Did you find this post helpful? Yes | No

    Default Re: HMC5883L Magnetometer chip Possibilities.

    I must add , the vector does not point north . it indicates the [ direction and magnitude ] of the magnet field relative to the device orientation.
    the link I posted is for accelerometers but the math is the same . the big difference is that gravity always points to the centre of the planet so orientation can be established
    Last edited by richard; - 3rd February 2015 at 12:13.

  8. #8
    Join Date
    Dec 2012
    Location
    Türkiye
    Posts
    103


    Did you find this post helpful? Yes | No

    Default Re: HMC5883L Magnetometer chip Possibilities.

    Quote Originally Posted by richard View Post
    if the device is held so that the xy plane is perfectly!!!! level then the xy angle is magnetic north (sort of). if the device is tilted then the xy angle needs to compensated for that tilt . the device alone cannot really be used as a compass . the device output is a 3d vector as drawn by the black line in my previous post, as you can see the result is relative to the devices orientation , if that is unknown (and it is without an external reference ) then its virtually impossible to ascertain a direction from its output. even a small tilt creates substantial error.
    furthermore magnetic field lines are not parallel with the earths surface they tilt into the earth or up to the sky depending on location. not to mention magnetic inclination/deviation etc
    basically the concept of using this chip as a compass is unworkable see post 47
    That was a nice a explanation Richard ... As you've previously said , we can at least use this IC to observe the pitch then ... For example I'm intending to read XZ or YZ to see the pitch angle for the control of an inverted pendulum ... I personally thought it's a low cost way of doing it compared to an encoder ... Bye the way .. For my module , should I keep it horizontally flat just like in the picture or upside down , does it matter ?

    Here is my module


  9. #9
    Join Date
    May 2013
    Location
    australia
    Posts
    2,682


    Did you find this post helpful? Yes | No

    Default Re: HMC5883L Magnetometer chip Possibilities.

    For example I'm intending to read XZ or YZ to see the pitch angle for the control of an inverted pendulum ... I personally thought it's a low cost way of doing it compared to an encoder
    not sure how effective that will be , it would probably need to be calibrated every time you relocate it (or maybe even rotate it) . don't forget its own orientation is its only reference point . an accelerometer might be more appropriate

Similar Threads

  1. 3 axis digital compass sensor HMC5883L
    By ScaleRobotics in forum General
    Replies: 1
    Last Post: - 8th June 2014, 23:19
  2. How to use this IO chip?
    By wdmagic in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 30th April 2013, 20:06
  3. compass chip
    By Macgman2000 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th October 2009, 02:42
  4. Do you use ICD possibilities of MicroCode Studio
    By octal in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th December 2007, 18:22
  5. Which chip do i use?
    By The Master in forum Off Topic
    Replies: 77
    Last Post: - 2nd December 2007, 23:28

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts