Shop OBEX P1 Docs P2 Docs Learn Events
Penguin Compass Calibration — Parallax Forums

Penguin Compass Calibration

HumanoidoHumanoido Posts: 5,770
edited 2011-03-18 15:07 in Robotics
Calibrating Penguin's Compass
Tips n Techniques for Penguin's HM55b

Penguin's HM55b compass is on pins 13, 14, and 15.

There's 2 compass calibration programs. You can do some calibrating or checking with both. Print out the compass calibration sheet to do the calibrations. This has nothing to do with the computer screen other than following the debug suggestions for moving the Penguin incremental degrees during the calibration process.

Penguin uses the
Hitachi HM55B IC
http://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/ProductID/98/List/1/Default.aspx?SortField=UnitCost,ProductName

Calibration Documentation
Hitachi HM55B Compass Documentation (.pdf)
Hitachi HM55B Compass Module Source Code (.zip)

Penguin Documentation
http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/penguin/List/0/SortField/4/ProductID/435/Default.aspx
PenguinDoc-v1.4 (.pdf)

Avoid Magnetic Fields
Make certain Penguin is not by any magnetic fields that may affect its compass during calibration. This includes the computer, large motors, various machines, magnets, electrical and metal objects..Extend Penguin on its USB cord away from the computer to a maximum distance.

Plumb your Penguin
To get good compass values, please realize the compass is not at the center of the Penguin. So all your moving around Penguin is probably off to begin with. You need to locate the compass on the board, drop a plumb bob down and note that gravity will take it to the center point on the desk (must be leveled first) upon which all calibration movement is based upon. Otherwise, all those compass calibration efforts are in naught.

http://en.wikipedia.org/wiki/Plumb-bob
A plumb-bob or a plummet is a weight, usually with a pointed tip on the bottom, that is suspended from a string and used as a vertical reference line, ...

Penguin Compass Programs
Finally, after a good calibration, you need some compass programs. Try these:
http://www.p-robot.com/index.php/navigation-and-movements.html
http://www.p-robot.com/sources/Directions.zip
Penguin Scout Compass
Penguin Screen Compass
Penguin Sound Compass
Penguin Scouting Feet
*

*Programs may require servo calibration
using the Penguin Humanoido Suite of programs..

and my favorite program
Penguin Radio
http://www.p-robot.com/index.php/sounds-and-music.html
http://www.p-robot.com/sources/SoundsMusic.zip

and check Parallax Penguin Demos
PenguinCode-v1.3 (.zip)

New RevB Penguins
(According to Parallax) 3.5. OPTIONAL COMPASS CALIBRATION
To improve the accuracy of the compass, the calibration routines for the Hitachi HM55B Compass Module have been ported to the Penguin. With the calibrated compass routines added to the Penguin's control code, extra RAM and code space is required. Separate versions of the following programs have been created to allow for either more available resources or a more accurate compass.

Code Incorporating a Calibrated Compass

Penguin-CompassTest.bpx Penguin-CalibratedCompassTest.bpx
Penguin-AutonomousNavigation.bpx Penguin-AutonomousNavigation-CalibratedCompass.bpx
Penguin-MigrateNorth.bpx Penguin-MigrateNorth-CalibratedCompass.bpx
Before the calibrated compass routines can be used, Penguin-CompassCalibration.bpx must be run to record the compass calibration data. For more information about compass calibration, please read the product documentation and the associated code available from the #29123 product page at www.parallax.com.

3.6. OTHER HELPFUL DOCUMENTATION

The following materials are helpful documents for programming the Penguin; each can be downloaded from its associated product page:
BASIC Stamp PBASIC Syntax Guide (on-line version of help file installed with the BASIC Stamp
Windows Editor)
HM55B Compass Documentation (#29123)
HM55B Graphical Viewer for the HM55B (#29123)
Smart Sensors and Applications (a Stamps in Class Text) (#28029)
IR Remote for the Boe-Bot Text (a Stamps in Class Text) (#70016)
Ping))) Ultrasonic Sensor Documentation (#28014)

Compass Test Code from Parallax
' Parallax Penguin Robot
' Penguin-CompassTest.bpx
' {$STAMP BS2px}
' {$PBASIC 2.5}
Compass PIN 15 ' Transceives to/from Din/Dout
Clock PIN 13 ' Sends pulses to HM55B's Clock
Enable PIN 14 ' Controls HM55B's /Enable
Reset CON %0000 ' Reset command for HM55B
Measure CON %1000 ' Start measurement command
Report CON %1100 ' Get status/axis values command
Ready CON %1100 ' 11 -> Done, 00 -> no errors
NegMask CON %1111100000000000 ' For 11-bit negative to 16-bits
x VAR Word ' x-axis data
y VAR Word ' y-axis data
Heading VAR x ' Store Heading measurement
status VAR x ' Status flags
DEBUG CLS, "Heading:"
DO
GOSUB ReadCompass
DEBUG CRSRXY, 9, 0, DEC Heading, "° "
PAUSE 150
LOOP
ReadCompass: ' Compass module subroutine
HIGH Enable ' Send reset command to HM55B
LOW Enable
SHIFTOUT Compass, Clock, MSBFIRST, [Reset\4]
HIGH Enable ' HM55B start measurement command
LOW Enable
SHIFTOUT Compass, Clock, MSBFIRST, [Measure\4]
status = 0 ' Clear previous status flags
DO ' Status flag checking loop
HIGH Enable: LOW Enable ' Measurement status command
SHIFTOUT Compass, Clock, MSBFIRST, [Report\4]
SHIFTIN Compass, Clock, MSBPOST, [Status\4]' Get Status
LOOP UNTIL status = Ready ' Exit loop when status is ready
SHIFTIN Compass,Clock,MSBPOST,[x\11,y\11] ' Get x & y axis values
HIGH Enable ' Disable module
IF (y.BIT10 = 1) THEN y = y | NegMask ' Store 11-bits as signed word
IF (x.BIT10 = 1) THEN x = x | NegMask ' Repeat for other axis
Heading = x ATN -y ' Convert x and y to brads
Heading = Heading */ 360 ' Convert brads to degrees
RETURN

Comments

  • Capt.KerryCapt.Kerry Posts: 28
    edited 2011-03-16 14:55
    I tried the calibration code "CalibrateHm55bCompass.bs2" in the zip file above. As soon as I tried to "enter" the first heading the stride servo went to full extension. Should have checked. Is that calibration routine is for some other bit of hardware? I notice the compass is on pins 4, 5 and 6.

    On another note, whilst I am not worthy to contradict you on anything Penguin I would have to question the necessity of using a plumb bob to get the onboard compass directly over the compass rose on the desktop before calibrating. If you were walking along with a compass in your hand it wouldn't matter whether it was in your right hand, left hand or on a stick 20 feet behind you, the magnetic force on the compass and therefore its reference to you would be exactly the same. I have "swung" many a ships magnetic compass by traveling in a huge circle (and using a portable mechanical gyro compass as reference). However maybe this does not translate to micro electronics?
  • dw101sdw101s Posts: 27
    edited 2011-03-16 18:24
    Capt.Kerry wrote: »
    I tried the calibration code "CalibrateHm55bCompass.bs2" in the zip file above. As soon as I tried to "enter" the first heading the stride servo went to full extension. Should have checked. Is that calibration routine is for some other bit of hardware? I notice the compass is on pins 4, 5 and 6.

    The compass is only on pins 4, 5, and 6 as an example in the compass manual, if you only have the Hitachi compass separately. However, since the compass is built in to the Penguin, the pins are already predetermined. I just successfully calibrated my compass tonight and the only thing I used from compass manual was page 3 in the Quick Start section (it is the page with the huge compass on it). Once you have that page printed out you need to line the paper up with magnetic north based on your location. Then take your penguin and place it on the paper.

    The two programs I used to calibrate the penguin's compass were from the Penguin Parallax page
    http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/penguin/List/0/SortField/4/ProductID/435/Default.aspx

    Download the PenguinCode-v1.3.zip file
    Run: Penguin-CompassCalibration-v1.3 - follow the prompts in the program (I used the IR Detector and the USB connection to line up the penguin to the printed out compass and got great results, then
    Run: Penguin-CalibratedCompassTest-v1.3 - you should see that your penguin give fairly accurate compass directions +/- a degree or two.
  • Capt.KerryCapt.Kerry Posts: 28
    edited 2011-03-17 03:34
    I have followed this calibration routine a dozen times and no matter what test I do afterwards the compass output on the debug screen never varies more than a few degrees as I rotate the Penguin.
    I notice from the "Review your Calibration Settings" option on the calibrate program that the "Actual" degrees varies from about 303 to 243 with no correlation to the "Ideal" heading. Is there any way to manually enter the "actual" degrees and fudge the compass into giving correct values or is that not going to help?
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-03-17 04:36
    Capt.Kerry wrote: »
    On another note, whilst I am not worthy to contradict you on anything Penguin I would have to question the necessity of using a plumb bob to get the onboard compass directly over the compass rose on the desktop before calibrating. If you were walking along with a compass in your hand it wouldn't matter whether it was in your right hand, left hand or on a stick 20 feet behind you, the magnetic force on the compass and therefore its reference to you would be exactly the same. I have "swung" many a ships magnetic compass by traveling in a huge circle (and using a portable mechanical gyro compass as reference). However maybe this does not translate to micro electronics?
    Capt.Kerry, the plumb bob is to find the exact center pivot point when calibrating with the printout, otherwise all reference angles will be off. If a line is drawn from B rather than center point A, a tracing will show the geometry anomoly in the entire rotation from 0 to 360. The exact nature of the periodic error is an ellipsoid if I recall, depending on how you fudge. The amount of error can be defined by the sine of the angle and adapting cosine phi = AC/2r. It does not matter after Penguin is calibrated as you can carry around the little bot as you please, though keeping it level helps.
  • Capt.KerryCapt.Kerry Posts: 28
    edited 2011-03-17 10:55
    Ok, well even keeping the compass over the center of the rose when I calibrate I still get a weird result. The calibrated compass test readout only varies maybe 25 degrees as I rotate the Penguin through 360. Any suggestions?
  • schillschill Posts: 741
    edited 2011-03-17 11:26
    Just so you don't think you are alone, I experienced exactly the same behavior. I did not spend the time to look into it so I can't be of much help. My Penguin hasn't had the stock electronics on it since the first day.
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-03-17 21:11
    Capt.Kerry wrote: »
    Ok, well even keeping the compass over the center of the rose when I calibrate I still get a weird result. The calibrated compass test readout only varies maybe 25 degrees as I rotate the Penguin through 360. Any suggestions?
    Capt. Kerry, is this Penguin from the recent special charity offering? If yes, then you have two Penguins, and can try the second Penguin. It this one works with calibration, then your first Penguin may have a failed compass. Make sure the batteries are new and Penguin is distanced as far away from the computer as possible and any other magnetic fields.

    The compass has worked well in all my Penguins - the many programs written for it have comments regarding accuracy. The 18-Band Radio was written for 20 degree channels which worked best for this application and you can read comments here:
    http://forums.parallax.com/showthread.php?100136-PENGUIN-ROBOT-18-Band-Radio!!!!-the-Code
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-03-17 21:12
    Before Compass Calibrating Penguin
    Prep the calibration area

    A good tip is to use a simple analog compass to "explore"
    the surrounding region and note any deviations in the
    needle direction readings.
  • Capt.KerryCapt.Kerry Posts: 28
    edited 2011-03-18 10:09
    Gave him some nice fresh fish... i mean batteries.... and he was a new penguin. Doh!! Thanks for your help, Humanoido.
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-03-18 10:23
    Capt.Kerry wrote: »
    Gave him some nice fresh fish... i mean batteries.... and he was a new penguin. Doh!! Thanks for your help, Humanoido.
    Capt. Kerry, this is great news! I know, some of those "new" Penguin batteries set on the product shelf a little too long. That's why I built a battery eliminator which is good for running tests to determine if the batteries are low, and have access to freshly charged rechargeable batteries. You can also build the Bat Penguin, as he monitors the battery situation. Now I wonder which of the compass programs is the most accurate. I will probably mull this over until I get some free time..
  • Capt.KerryCapt.Kerry Posts: 28
    edited 2011-03-18 10:59
    I am going to be using the compass to drive a servo through the I/O port steering a model boat (be nice to have a GPS!!!) so if I run into any useful info I will post it. One quick question... why do the tilt and stride servos jump to max every time I power up? I am worried about stripping the gears, it doesn't seem to matter what program is loaded. Any ideas?
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-03-18 14:48
    Capt.Kerry wrote: »
    I am going to be using the compass to drive a servo through the I/O port steering a model boat (be nice to have a GPS!!!) so if I run into any useful info I will post it. One quick question... why do the tilt and stride servos jump to max every time I power up? I am worried about stripping the gears, it doesn't seem to matter what program is loaded. Any ideas?
    Capot. Kerry, would like to see a compass based steering program when available. About the twitch: The servos normally jump like that when Penguin is first switched on. I have a post somewhere that addresses this issue. When I find it, will post the like for you. To make the servos last longer, notice the direction of the jump when Penguin is switched on. Then, with Penguin off, slowly turn the servos in the opposite direction, so when Penguin is turned on again, the jump will not be out of range. It's a simple thing to do and can keep the servos in top notch condition for a long time..
  • HumanoidoHumanoido Posts: 5,770
    edited 2011-03-18 15:07
    You can read more about the servo twitch here and download the startup instructions.

    http://forums.parallax.com/showthread.php?130432-Penguin-Servo-Twitch&p=985446#post985446
Sign In or Register to comment.