Shop OBEX P1 Docs P2 Docs Learn Events
need code snippet for 3 axis compass — Parallax Forums

need code snippet for 3 axis compass

xylorxylor Posts: 3
edited 2012-05-26 08:08 in Accessories
i am building an autopilot with 3 axis compass. when i press pin 3, it goes low and i want that "current raw x" to become the new direction, and drive the motor back and forth from the current raw x heading, via hb25.

any ideas will be appreciated.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-26 05:53
    You need to supply more information like what compass you're using, what microcontroller you're using. If you're using Parallax products, there's usually code snippet links given on the Parallax webstore page for the product. If you're using a Propeller, there are all sorts of sensor routines in the Propeller Object Exchange (OBEX). Explain what you mean by "press pin 3, it goes low".
  • xylorxylor Posts: 3
    edited 2012-05-26 06:17
    you are correct, bs2, and at the moment i want to press pin 3 to go low, and simultaneously capture that magnetic heading. then i want to automatically move the dc motor back and forth,via hb25, to maintain the captured heading. i will use the kickstart program and integrate this into it.

    the objective here is how to capture the x raw heading and use that to maintain the heading...

    hope that's clearer.
  • Mike GreenMike Green Posts: 23,101
    edited 2012-05-26 07:49
    The KickStart code is a good starting point if you're talking about an HMC5883 compass. There are various tutorials on learning to set I/O pins to various values and how to program in PBasic like "What's a Microcontroller?". "Robotics with the BoeBot" explains how R/C servos work and how to get them to move the way you want with a Stamp. From the main Parallax webpage, click on the Downloads button. On the Downloads webpage, click on "Educational Tutorials and Translations". Make sure you have a copy of the "Basic Stamp Syntax and Reference Manual" downloadable from the Downloads webpage under Basic Stamp Documentation. The HB-25 essentially works like an R/C servo and there are examples of its use in the documentation off the webstore page for the HB-25.
  • xylorxylor Posts: 3
    edited 2012-05-26 08:08
    thanks for your info
Sign In or Register to comment.