Friday, May 29, 2020

Can I trust my phone?

Recently, I was checking some of my past measurements and I found the latitude and longitude I recorded at The Bluffs to be off by about 130 miles. (I checked the GPS recording from the Physics Toolbox Pro with the latitude and longitude from Google Maps.) That's a tiny error in respect to the circumference of the earth. I still calculated that to within 1.01% on the same hike. But it would be pretty bad if I were telling someone where to meet me!

So I wondered how my other phone sensors perform. After all, the inside of a smartphone is a noisy place with so much electronics packed into such a tiny space building up heat, and so much energy swirling around in my urban setting. I decided to check my magnetometer so I set my phone in a quiet place (in my bedroom) using the Science Journal to record magnetic fields and left it for about an hour.

Here's the recording.


Not a lot of detail here but there are a few things that jump out at me. The first, oh, 23 minutes are rather "fuzzy" and then the tracing settles down into a nice flat line. After that, there are a few spikes somewhat larger than the earlier fuzz; then, at the end (maybe give minutes), the tracing drops and suddenly jumps up).

I don't see any drift. In other words, the tracing doesn't seem to drift up or down over time.

I am going to guess that the early fuzziness is internal noise as my magnetometer adapts to internal noise in the phone. Is the noise enough to worry about? Well, all instruments have errors, even manual tools like rulers and scales react to environmental noises like changes in heat and drafts. To check how much the tracing moved around, I saved the tracing as a comma separated values (cvs) file and loaded it into my DANSYS statistical spreadsheet. All I needed to check was the range of values in a section of the tracing.

The range here is 0.0165 μT. The average field strength is 52 μT (these figures are x10). The standard deviation is 0.028 μT. That last figure indicates that 66% of the samples will deviate from the average of 52 μT by only 0.028 μT, and 98% will deviate by 0.056 μT. I can live with that!.

The 52 μT background field strength is very close to what I found and reported in the Earth Specs blog. That's pretty close to the normal field strength of the Earth's magnetic field (25 to 65 μT).

By the way, background magnetism isn't constant over the Earth's surface. Dense rock and metal content in the Earth's crust can concentrate the magnetic field in certain areas much like iron cores in transformers and electromagnets can concentrate the magnetic field produced by an electric coil. This fact can be used by prospectors to find ore deposits and the magnetometer has long been in the prospector's tool chest. This close to the Front Range of the Rocky Mountains, it doesn't surprise me that the magnetic field strength is toward the upper range of Earth's background magnetism.

As for the spikes in the last half of the tracing, those do not surprise me either. The air system clicked on a couple of times while I was recording and electric relays and motors can kick out some heavy fields.

You always have to be concerned about the accuracy and reliability of your instruments. Different phones will have different sensors and driver circuits. You might want to check out your sensors. NASA has a cool book called "A Guide to Smartphone Sensor." It's a free download and you can get it here:



Monday, May 18, 2020

Earth's specs

Somewhen in the 200s BC, a Greek named Eratosthenes measured the circumference of the Earth. He worked and lived in Alexandria, Egypt and knew of a place in Syrene, Egypt where, on the summer solstice, the image of the sun could be seen in a deep well, meaning that the sun was directly overhead. That placed Syrene on the equator. 

Eratosthenes assumed the Earth to be a sphere. If that were true, he reasoned that, if he stuck a rod in the ground vertically, it's line could be extended straight to the Earth's center to form an angle with a similar line from Syrene and that angle could easily be calculated. All he had to do was measure the angle formed of the line from the tip of the sun's shadow to the tip of the rod with the ground, subtract that from the 90° angle of the vertical rod with the ground, and he would have it...and "it" would also be Alexandria's latitude. It worked out to be about 7°.

By that time, everybody knew that the Earth was round and that the angular measure of any circle was 360°, and Eratosthenes knew that Alexandria was 5000 stadia from Syrene, he could figure out the circumference of a great circle on the Earth and, therefore, the Earth. His result was 250,000 stadia, or 39,385 kilometers, which is 1.4% off from the accurate circumference, 39,941 kilometers. Not too shabby!

So, on my recent hike to The Bluffs, I decided to do a modernized version of Eratosthenes' calculation.

The summer solstice was still a ways in the future so, not trusting nature to provide me with a good shot of the sun on demand, I measured the latitude and the distance between Arapahoe and Ridgegate Stations on the RTC southern light rail lines. I used Veiyra Software's Physics Toolbox Pro for the measurements. Here are the readouts.

Arapahoe Station

Ridgegate Station.

The distance, measured as the crow flies using Google Maps, is 5.6 miles or 9 kilometers.

"As the crow flies" is another way of saying "along a great circle on the globe," so I now have a way of converting degrees along the circumference of the Earth to kilometers and vice versa. By the way, I have it from a reputable source, namely, a crow, that crows do not always fly in straight lines.

The two stations are at almost the same longitude, so I can ignore that. The difference in latitude is .08 degrees.

But what about the stick in the ground? Well, that's another thing. It's called a gnomon and was a primary tool of ancient astronomers. It simply measured the angle of inclination of an astronomical object. Today we have astrolabes (basically a protractor with a plumb bob and a pointer) and the more advanced theodolite used by surveyors. I have a theodolite on my phone, the Dioptra app by Workshop512.

Since I really had all the information I needed, and I didn't know how far I was from the equator, I just wanted to do a modern version of Eratosthenes' trick to find my latitude by the sun. True to course, it was so cloudy on the summer equinox that I couldn't even tell which quadrant of the sky the sun was in, but I slapped a welder filter on my phone and took this shot from Dioptra the next day.


The angle of inclination was 51.1°, which was close to the actual measure on the equinox taken from the Time and Date website:


Solar noon was at 1:07.

Angle of inclination was 50.5°, which placed my latitude at 90°-50.5°=39.5° . Looking at the Toolbox measurements above, I'm off by less than a tenth of a degree. The Dioptra measurement, which is also GPS is 39.58, so it's close.

But back to the real thing. The difference in measured latitude was 0.08° which is 4 minutes and 48 seconds (There are 60 minutes in a degree and 60 seconds in a minute). If 0.08 degrees is the same as 9 kilometers, 1 degree is 112.5 kilometers.

Okay, breath held, the moment of truth….112.5 kilometers times 360 degrees is 40,500 kilometers. The actual value is 39,941 kilometers. I was off by 1.01% Wow! I just impressed myself!

Of course, along with all the measurement error and such, the Earth is only approximately a sphere. The radius at the equator is larger than the radiuses at the poles.

We know the circumference of the Earth. The approximate volume is easy. The volume of a sphere is π\6 times the diameter cubed. The diameter is the circumference divided by π. Working backward, the diameter is 12,714 kilometers. So the volume is right at 10 to the 12th power cubic kilometers.

Okay, mass...mass is a bear. You measure mass with a balance and standard mass (remember the blog about mass and weight?) But Earth does have a mass. How in Sam Hill would you figure it out?

Well, obviously, you can't use a balance so any measurement has to be indirect. The first measurement to within 1% was made in 1798 by Henry Cavendish as a spin off of his accurate measurement of the gravitational constant. He used a torsion balance to do that and I can't even approach that kind of precision at home, so I'll just tell you how he did it. 

Isaac Newton figured out that the force of attraction (gravity) between any  two masses is directly proportional to the difference between their masses, and inversely proportional to the square of the distance between them. But to come up with an actual measurement, a proportionality constant was needed. He called it the Universal Gravitational Constant and never found it's value.

About 70 years later, Cavendish did it. Imagine a long, vertical, thin, flexible rod. At the bottom end is another rod forming an inverted T. At the end of that rod are two balanced heavy masses. His masses were  .73 kilograms each. He could set the bottom rod spinning back and forth and measure a slight force inhibiting the motion by comparing the frequency of oscillation with and without the force. The force, of course, would be another large mass close to one of the chunks of lead on the torsion balance. He knew the masses he was working with, the separation between them, and Newton's formula, so he was ready to calculate the Universal Gravitational Constant.

It was 6.67408 x 10^-11 m^3kg^-1s^-2 .

Believe it or not, that's what we need to calculate the mass of the Earth. Using Newton's formula we need the acceleration due to gravity (we found that approximately fooling around with the smartphone's accelerometer), multiplied by the radius of the Earth squared (we know that), divided by the Gravitational Constant.

So let's do it. Square the Earth first. The diameter is 12714 km so the radius is 6357 km. We need that in meters so 6357 x 10^3 meters. Square that to get 4.04 x 10^13 meters squared. The acceleration due to gravity is 9.18 meters per second square so the numerator is 3.71 x 10^14. Now we divide that by our Gravitational Constant, 6.67408 x 10^-11 m^3kg^-1s^-2  to get 5.56 x 10^24 kg (the accurate figure is 5.972 x 10^24 kg).

Actually, Cavendish didn't report the mass of the Earth. He stopped one step short by publishing the density of Earth which was 5.45 grams per cubic centimeter. He probably figured that, from there, it was easy to multiply that times the volume of Earth so, eh, let someone else do the easy part. 

If we look around and figure out what proportion of Earth is made of light rocks, heavy rocks, water, air... and come up with an average density we would say that it's around (and people before Cavendish had done just that) 2.7 grams per cubic centimeter, so where does all that mass come from?

Well, obviously, there's more underneath our feet than meets the eye. In fact, the deepest we've ever been is 12,262 meters and, although that's pretty deep, it barely scratches the surface. Still, the researchers expected temperatures around 212 degrees Fahrenheit and what they got was 356 degrees. It's hot down there.

But two things convince us that the core of the Earth is iron-rich molten metal. One is the surprising density of Earth. The other is something you don't see a lot of in the solar system...magnetism.

Earth is a magnet. The sun and gas giants like Jupiter and Neptune have strong magnetic fields. Mercury has a weak field. Some of the moons (but not ours) seem to be magnetic, but most of the smaller planets are magnetically inert.

We've used compasses that rely on the Earth's magnetic field for a long time. It wasn't until 1600 that William Gilbert proposed that Earth is a magnet. In fact, Earth is not a permanent magnet. It's an electromagnet.

Moving electrons (current) generates magnetic fields and our rotating molten metal outer core is one humongous magnetic field generator.

Our planet is special. We are just the right size. If we were too big, gravity would squash us. Too small and we wouldn't have enough gravity to hold onto our atmosphere. We get just enough sunlight for a healthy biosphere. We have plenty of that rare commodity - water. A nice balance of plants and animals conditions our air. And we have an effective magnetic shield that shunts dangerous solar radiations around the planet and out into space.

When I bought my current phone, I made sure it had a magnetometer in addition to the other regular sensors. Phones with GPS receivers will provide fairly accurate compass readings, but a magnetometer is more accurate and you can use it to measure both magnetic fields and electrical currents.

My Android has a AK09918 triaxial magnetometer. Since it's triaxial, it measures field strength in three directions (like the accelerometers). There are two common kinds of magnetometers in smartphones: magnetoresistive and Hall Effect. The AKM is a Hall Effect sensor that uses a flat conductive plate. A magnetic field causes electrons to deviate from their path and polarizes the plate. That can be sensed as a potential difference across the plate.

About a week ago, I hiked down a mile of  Little Dry Creek trail and used the Physics Toolbox Pro to record magnetic fields. I walked almost due west so I was cutting across the magnetic field lines.

The strength of a magnetic field is measured in teslas (in this case, in microteslas). A tesla is equal to a weber per square meter, and a weber is a kilogram per square second. If you understand induction (it makes transformers work), webers involve how much voltage you can crank out with a magnetic field. So with microteslas, don't expect geomagnetic electric generating stations any time soon.

I recorded the magnetic field in three directions at a rate of one measurement per second. Since I had the phone in my shirt pocket, the x direction was right-left, y was up-down, and z was forward-backward. I then saved the several thousands readings in a csv (comma separated values) file that I could pick up with DANSYS, my statistical spreadsheet.

Here's a graph of the tracings.

The tracings are pretty fuzzy, indicating a lot of noise. The inside of a smartphone has lots of electrical components crowded together and heat from those and the outside. Noise is to be expected and when you're measuring on the order of micro-anything, you can expect noise to blur the lines. 

All the lines have big spikes but the z component has the most. That is my forward and backward direction and I was walking in an urban environment, so power lines, underground cables…. yeah. So that's not the Earth's magnetic field, right? 

Many scientists call this the anthropocene epoch because the biggest influence on the Earth's environment, for the first time, is a single species - humanity. Every stray magnetic field alters Earth's magnetic field locally. Have you ever tried to get a compass to work in a house? You're likely to find it somewhat off the magnetic north.

But, we can sense some trends. There is a noticeable difference between the start of my recording and the latter part. That's because I started at my home and walked a ways more or less north before turning west on the trail.

The green line gives us the total field strength. It's measuring around 50 to 75 microteslas. The normal background magnetic field strength runs around 25 to 65 microteslas, so we're well within that range (once we get away from the houses.) The local residue from residences doesn't seem to spread out very far. The trail is generally about 200 to 300 feet (as measured by Google Maps) from the nearest houses.

Geophysics is the study of the physical attributes of our planet. After the barriers between East and West came down in 1957, scientists took the opportunity to focus on Earth and instituted the International Geophysical Year. You can learn a lot more with a team than you can alone. Perhaps you can join with some interested neighbors and have a Geophysical Year of your own!