Shop OBEX P1 Docs P2 Docs Learn Events
New Penguin and others : Compact Calibrated Compass programs — Parallax Forums

New Penguin and others : Compact Calibrated Compass programs

InteractInteract Posts: 79
edited 2008-12-17 01:46 in Robotics
Well as I stated in this thread: THREAD . I needed to re-write the Parallax-Calibrated-compass routines so they were more optimized for variable usage and program space. The result of that work turned out to be just as accurate as the original Parallax code. I finally got around too commenting and cleaning it up for public criticism.
In theory the original code should be more accurate but due to the fact that the actual resolution of the HM55B is only good for 255 positions around the compass at best, my new routine came out to be of equal angle accuracy. The whole Compass routine including the calibration calculation only uses·3 word, and 1 byte, length variables. And the routine is not much longer than the non-calibrated routine. Although it was written for the Penguin, the attached programs would work for anyone using the HM55B.
I needed to re-write the calibrate compass program to get this to work, so you must run the Compact-Compass-Calibration.bpx Before you run Compact-Calibrated-CompassTest.bpx.
The Original program stored· 4 words for x and y axis offsets, one word for index·of lowest angle, and 15 Reference compass angles.·With the new compact routine 17 words for Reference compass angles is all that·is needed. (I decided to eliminate callibration for true·north since I didn't plan on him actually trying to get there) The first byte is always 0 (brads) and the last in the table is·always 255. The penguin and the paper compass he is standing on must BOTH be facing·north for the first data point to enter. Adjust this by turning the paper with the penguin until it is facing 0 deg.
The calibration will keep asking for the first entry (Penguin facing north) until it actually gets a 0 deg reading from the HM55B, so it may take a few pushes of the enter key to get that 0 deg entry. After that you enter the 15 angles as before, by turning JUST the penguin to the different angles and hitting enter. I taped my Penguin to a CD with a line drawn across the middle and that helped a lot to get accurate angle turns.
The Calibrated-CompassTest.bpx. will display the angle the penguin is facing using the compact calibration calculation, which uses the table generated by the calibration program. This is the section of code you will need to paste into a project using the compass.
When testing there was quite a bit of error using just the raw data from the HM55B, if I was to plot out the N-S-E-W on a graph paper it would look like a bad peace sign, instead of a plus sign.·For applications that only need to know which way north is, the raw data is probably good enough.

Comments

  • Tom CTom C Posts: 461
    edited 2008-10-01 11:55
    Interact,

    How does "CompassTable CON 0" define the compass table as a table of data (array)?

    Should it be "CompassTable DATA (16)?

    Regards,
    TCIII

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If you are going to send·a Robot·to save the world, you·better make sure it likes it the way it is!

    Post Edited (Tom C) : 10/1/2008 12:27:08 PM GMT
  • InteractInteract Posts: 79
    edited 2008-12-16 22:55
    "How does "CompassTable CON 0" define the compass table as a table of data (array)?"

    The 'READ" statment reads a value stored in EEPROM. The compass callibration program stores values for compass headings in EEPROM starting at location 0.

    If for some reason you wanted the 'table of stored values' to start at location 33 because your program was already using the first 32 locations, you would change "CompassTable CON 0" to "CompassTable CON 33". in both the calibration program,·and the program with the compass reading routine.

    Post Edited (Interact) : 12/17/2008 3:26:25 AM GMT
  • Tom CTom C Posts: 461
    edited 2008-12-17 01:46
    Interact,

    Thanks for the explanation. Makes sense.

    Regards,
    TCIII

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    If you are going to send·a Robot·to save the world, you·better make sure it likes it the way it is!
Sign In or Register to comment.