HMC5883 provides you with the angles relative to the magnetic field vector... For example, a regular compas shows you the deviation from north, so does of the sensor when z perpendicular to the magnetic field vector. When you tilt, you get different values for xy and non-zero for z. As you will become aware when reading the Erdmagnetfeld wiki entry, the calculations it becomes quite complex depending where you measure because the field is heavily 'bent'. The compas sensor tells you only which direction to the magnetic field vector you are heading. I do not know how they exactly work, but they could include 3 orthogonally oriented hall sensors... (Magnetometer and Erdmagnetfeld). You may give it a try, but I doubt that it works well enough, because I'm not sure if a neodine can create a far enough reaching field of strength that the earth's field does not really matter. How much (inch / mm) does the plunger in the clip travel? This site may be of some help. I still believe that a resistive technique is the most affordable and still accurate enough approach.
If you want to get down to a 1/100 inch/ 3/100 mm, you can 'hack' a cheap ($10..$20 for 4..6 inch 10..15 cm) digital caliper made of metal or composite material... and most of them have even some kind of serial interface. If you can 'hack' the built-in chip ('s scaling factor - may be through the serial interface), you can even modify the displayed value to match the number of rounds left!... ;) - let me know how far you get with that... we could ask the manufacturer to add a third setting: inch/mm/rounds :||
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
HMC5883 provides you with the angles relative to the magnetic field vector... For example, a regular compas shows you the deviation from north, so does of the sensor when z perpendicular to the magnetic field vector. When you tilt, you get different values for xy and non-zero for z. As you will become aware when reading the Erdmagnetfeld wiki entry, the calculations it becomes quite complex depending where you measure because the field is heavily 'bent'. The compas sensor tells you only which direction to the magnetic field vector you are heading. I do not know how they exactly work, but they could include 3 orthogonally oriented hall sensors... (Magnetometer and Erdmagnetfeld). You may give it a try, but I doubt that it works well enough, because I'm not sure if a neodine can create a far enough reaching field of strength that the earth's field does not really matter. How much (inch / mm) does the plunger in the clip travel? This site may be of some help. I still believe that a resistive technique is the most affordable and still accurate enough approach.
If you want to get down to a 1/100 inch/ 3/100 mm, you can 'hack' a cheap ($10..$20 for 4..6 inch 10..15 cm) digital caliper made of metal or composite material... and most of them have even some kind of serial interface. If you can 'hack' the built-in chip ('s scaling factor - may be through the serial interface), you can even modify the displayed value to match the number of rounds left!... ;) - let me know how far you get with that... we could ask the manufacturer to add a third setting: inch/mm/rounds :||
3 Attachments