The iPhone 3GS and later have an actual electronic compass - iPhone 3GS uses the AK8973 3-axis electronic compass chip. iPhone 4 uses similar.
Ah, got it. Found a datasheet marked "preliminary" with a quick Google search, and noted that the phone/device manufacturer must insert any necessary offset into the chipset for any magnetic devices around the chipset (speaker, microphone) to calibrate it.
Also notes in the datasheet about the maximum magnetic levels the design should subject the chipset to, since speakers vary with the audio level and frequency they're driven at. So sounds coming from the phone during compass readings could have an effect. Same thing with (relatively) high RF levels if the network were to tell the phone, "Can't hear you now!" (Joke. But true.)
http://www.datasheetarchive.com/Indexer/Datasheet-014/DSA00244391.html
How exactly would a magnet fry the iPhone?
Depends on what's inside and how big a magnet someone reading my post might go pick up to try it. :wink2: I was just trying to put a disclaimer on it so someone didn't go grab some giant magnet, slap it up to their phone, and yell at me tomorrow, ya know?
Most of them base it off the compass data which is provided in the API. See the CoreLocation framework documentaion, in particular the CLHeading Class:
http://developer.apple.com/library/...Reference.html#//apple_ref/doc/uid/TP40008772
Yup, which was kinda the jist of my point... you have no idea in most Apps you download what they're using. They could be making it up for all you know. And has the Apple CoreLocation library itself been audited by anyone who knows navigation?
There's also a multiplexer in the device to switch/decide which axis you're using... so CoreLocation must do some guesswork using the accelerometers about which orientation the phone is in, relative to the Earth's center. In an aircraft, 60 degree banked turn that's coordinated... those accelerometers think the floor of the aircraft is the "center of the Earth", I bet.
And a pre-amplifier that can be adjusted by external voltage for sensitivity...
Cool to see that Apple's using a typical I2C bus in there somewhere. That's some interesting stuff, and fun to "bit-bang" on microcontrollers if you have a lot of time on your hands. My microcontroller days are long gone unless I can find a whole lot of hours left in a week to dig out all that stuff from the basement. I was kinda partial to the Microchip PIC, but wanted to try some coding for the Atmel AVR line also and never got around to it.
You probably see what I'm getting at here... Compass Apps on the phone, are probably best thought of as toys... right up until you've done a whole lot of your own testing against a known good compass.
Then you know that at least *your* phone is fairly accurate... but swap hardware, you better test it again, if you're going to rely on it for anything other than playin' around.
You've given me interesting ideas though... like playing with Compass Apps to see if they follow ANDS like a real compass would... or that question above... what does this thing do in steep turns? Would be fun to get a safety pilot and go play, and point a video camera at the phone while doing it for later analysis. If nothing else, it'd be an excuse to go flying!
(And if they don't follow ANDS or do the things "normal" compasses do... then you'd scratch your head and wonder "Why?"... Did the developer integrate the GPS information? Is the data mathematically smoothed over time by CoreLocation? How laggy is the algorithm?)
All sorts of fun tech-support engineer-geek implementation questions! I love finding other engineer's bad assumptions and patterns of mistakes in final products... it's what I do for a living!
("Mr. Customer, I've confirmed the behavior you saw, and I think I understand exactly the thought process that got us here. I've escalated a ticket with a good description of the problem, and we'll have to see what Engineering says.")
It's all relative, when it comes to compasses. If someone goes to the effort to create a compass card that accounts for errors introduced by the aircraft for a hard mount-point I wanna see it!
Even the good ol' FAA tells me on this study question for the written for my IFR ticket that I'm only supposed to make 2-3 degree corrections when on the localizer... and if they have some folks with sharp enough eyes to be able to see and fly a 2 degrees difference on my Skylane's DG in turbulence, they're bloody amazing pilots. I want to learn from them! Maybe I'll get that good someday, but that seems more like an arbitrary number taken while the pilot scanned the CDI and made the corrections that worked... hard to say. Not enough Instrument time under my belt. I could see it in nice stable day, but bumps? Just fly the needle... put the aircraft where you want it to be.
So yeah, my posting was a bit tongue-in-cheek, just to remind everyone that... "It's designed to be a phone. Not a navigation device."
CoreLocation was probably written by a guy/gal in a cushy office chair who's never needed a bearing to be accurate within 2 degrees or they're going to be miles off course, ya know?
This mixed hardware/software engineering stuff is HARD! Well, detailed and time-consuming anyway, at the very least.
Ever seen this on the Apple Support site about "Compass Calibration Mode"?
http://support.apple.com/kb/TS2767
Ever waved your phone in a figure eight? Were you supposed to lay it flat for that figure eight, or facing you, or some obtuse angle in-between? Portrait or Landscape orientation? Apple left out some details there.
Some fun discussion about it, and YouTube links of people's opinions in this posting:
http://www.iphonelife.com/blog/2440/iphone-3gs-compass-calibration
Here's a guy who's name in this forum is "B737" and he's "in a field where he can check the compass on airplanes" (paraphrased)... he says 45-90 degrees off is the worst he's seen, with it usually being about 25 degrees.
http://forums.macrumors.com/showthread.php?t=790895
Guess we know what that 737 pilot is doing in cruise!