Monday, September 25, 2017

Tracking the Sun

Last week we figured out how to keep the mirror pointed in the right direction... as long as we know where the Sun is. This week we'll solve that part of the problem.

One way we could attempt this would be to use an infrared receiver to track the actual Sun. That's a very direct method, and Lego does produce IR receivers. But I'm going to skip that option for now, for reasons similar to why we decided not to use light detectors to keep the mirrors pointed: we'll lose tracking during cloud cover or an eclipse.

The other way is to use astronomical knowledge. The Sun and Earth move in predictable ways, predictable enough that we know to within fractions of a second of time and milliseconds of arc of location where the Sun will be in the sky for the next several centuries. That's far more accuracy than we need for this project.

Small aside: how much accuracy do we need, anyway? Suppose our estimate of the Sun's location is off by 1 minute of arc. Then the image will be off by the same amount, and we can apply the formula from a few posts ago to determine how far this is in linear distance. However, for small angles, `2 tan(1/2 theta) ~= theta`, and 1 minute of arc is 0.00029 radians, so the error will be very close to `30m * 0.00029 = 8.7mm`. That might be enough to see. Let's work backwards instead: if we want the linear error to be `< 1mm`, then the maximum angular error `theta < 1mm` `/ 30m = 3.3xx10^-5` radians = 0.113 minutes of arc. It's useful to know this value because it will help constrain the Sun-tracking method we choose.

The simplest - and probably most accurate - method is to use NASA JPL's HORIZONS system, which has a Web interface that allows the calculation of ephemerides for any specific location on Earth in a variety of coordinate systems, for most of the bodies in the Solar System, including the Sun. The output is specific locations for a given range of times. We can, for example, get an ephemeris for the Sun, at 1-minute intervals, from the perspective of Dallas, TX, on the eclipse date of April 8, 2024. Problem solved?

Sort of, but it's not ideal. One drawback of this method is that it's limited to a specific range of dates and a specific viewpoint. I'd like to test the Sun viewer in my backyard in California this year, so I'll need to generate a new ephemeris for that, and then remember to load up the correct one when the eclipse arrives. Also, anyone else who wants to copy my work will have to generate an ephemeris for their own location. I could provide instructions, but doing this work is inconvenient. Can we do better?

One possibility is to use a geocentric ephemeris rather than a topocentric one. This gives us Sun position relative to the center of the Earth, from which we can do a little vector algebra to find the topocentric coordinates from any point on Earth. So there's more math involved, but the method is more general and should be about as accurate. I did a little Googling around and found this paper, which combines all of this math into one method (the PSA algorithm) for calculating the Sun vector for any date/time and location on Earth. I implementation this in Java and tested it against HORIZONS data: it's quite accurate, to at least 4 decimal places. According to the paper, the PSA algorithm almost never has an error `> 0.4` minutes of arc, but quite often has an error `> 0.113` minutes. However, as discussed last week, we actually don't care about the exact Sun vector: we just care about the first derivative of the vector. As long as the error is a smooth function of time, the error in the first derivative should be very small indeed.

Next week, we'll discuss how to build a mirror pointer out of Lego...

Monday, September 18, 2017

Designing a Sun Tracking System

The design problems we're break down into two parts: theoretical and practical. This week we'll focus mostly on the theoretical, and next week we'll address the practical.

The purpose of the Sun tracker is to keep an image of the Sun focused on a single spot over a long period of time, during which the Sun will transit a significant portion of the sky. So the tracker needs to know these things: (1) the position of the Sun, (2) the angle of the mirror, and (3) the position of the target.

The physics of reflection is simple: the angle of reflection is equal to the angle of incidence. In mathematical terms, that means that given a unit vector from the mirror to the Sun (call it `hat s`) and a unit vector from the mirror to the target (call it `hat t`), the desired normal to the mirror is just `hat s + hat t`.

But the situation isn't quite so simple. While we can know `hat s` by doing some astronomical calculations, it's not so obvious how we find `hat t`: that's a surveying problem. Bear in mind that the target is going to be some 30m away, and we need to make measurements accurate to <1 degree. We can't just eyeball it. Adding to the problem, it's actually not even trivial to know the angle of the mirrors. Lego motors can keep track of how many rotations they've done, but they don't store this value forever. Once the power is removed, the data is lost. So when we turn on our device, the initial state of the mirror is going to be unknown. Lastly, even though we can know `hat s` in horizontal coordinates (oriented with `hat x` pointing north, `hat y` pointing east, and `hat z` pointing to the zenith, we don't know them in the coordinates of the tracker itself, which will be rotated (unless we require it to be carefully aligned) in relation to the Earth. And don't forget that all of the vectors here are 3-dimensional.

At first blush it looks like we need to make some compromises. For example, we could require the tracker to be aligned with the horizontal system, in which case we can know `hat s` in tracker coordinates. Or we can install some tiltmeters to the mirror controllers (these can be obtained for about $25 each) to let us determine the initial orientation of the mirror. Or we can force the mirror into a particular start orientation and then initialize the motor tachometers. Or we can use some known aim point or points to initialize the mirror. I spent some time thinking about all these possibilities before I had an epiphany: it's all unnecessary.

We can simplify the situation considerably. Suppose for a moment that everything is just 2-dimensional. Then the basic setup looks like this:

Note that this picture is accurate regardless of what direction we view the system from. In particular, if we view it from the side, where the angle shown is altitude, then it's easy to see that the desired altitude of the mirror is just the average of the altitude angle to the Sun and the altitude angle to the target. Or if we view it from the top, where the angle shown is azimuth, then the desired azimuth of the mirror is just the average of the azimuth angle to the Sun and the azimuth angle to the target.

We still have the problem of actually knowing these values, but here's where the epiphany comes in: we don't need to! The target isn't moving; only the Sun is. When the Sun's altitude changes by 2 degrees, the averaging we described above implies that the mirror's altitude needs to change by 1 degree; the same is true of azimuth. So the tracker can just update altitude and azimuth at just half the rate of the Sun and the image should stay on target.

Next week, we look at how to determine the Sun's location...

Monday, September 11, 2017

An Automated Mirror Pointer

We're lucky to be living in a time when automated systems are cheaper and easier to build than ever. That gives us a wealth of options for building an automated mirror pointer. The two that I'm considering are Arduino and Lego Mindstorms, and (for now at least) I'm making Mindstorms my baseline choice. I'm sure Arduino would work, but I'm unfamiliar with both the hardware and software, so there's a learning curve. I used Lego to build a manually adjustable mounting for my 1m pinhole viewer, and it worked great, so I see no reason it can't work for the larger version. Bear in mind that while the total system is much larger (30+ m versus 1m), the actual thing being pointed is much smaller: just a little hand mirror instead of a 1m cardboard tube.

There are several designs I've considered for the mirror pointer. The simplest is to just use a remote control. Lego motor controllers can be remote controlled: I've used this mechanism to make a small home-grown New Year's ball. But I have three problems with this approach: first, I'm not sure the range of the remote control is sufficient; second, manual control will be herky-jerky, not great if we want to make a movie of the eclipse; and third, it's not very interesting! That last one trumps any possible solutions to the other two. We want to automate this sucker.

There's a dead simple way to automate that sadly has a couple of flaws, one fatal. We could set up light detectors just barely outside the image of the Sun, and program the pointer so that when a detector fires (i.e. is illuminated), move the mirror until it is no longer illuminated. One flaw in this design is that while Lego does make light detectors, it doesn't make 30m wires. So hooking the detectors up to the controller isn't trivial. But the really fatal flaw is that we want to track an eclipse, so the image of the Sun won't remain a circle. So tracking the illuminated portion of the image won't keep the center of the eclipse fixed, and (much worse) will lose tracking entirely during totality (when the sliver of Sun flips discontinuously from one edge of the image to the other). And of course there's always the chance the Sun might go behind a cloud, which could also cause this design to lose tracking if the cloud cover lasted long enough (recall that the image moves a full diameter every two minutes, hence any loss of light longer than that would confuse the tracker).

That leaves a third design, more complicated than the other two but with a number of advantages: use astronomical knowledge to track the Sun's location, and use math to calculate the proper mirror angle to keep the image centered on a desired location. The advantages of doing it this way are: first, after an initial setup (stay tuned for how to do this!) the tracker will be fully automated, no intervention required; second, it works during cloud cover or eclipses; and finally, the entire pointer is self-contained with no need for remote control or long wires.

Next week, we'll get into the details of this design...

Monday, September 4, 2017

A Large Pinhole Viewer

The sun subtends an angle of about 0.53 degrees in the sky, which means that its image projected through a pinhole is about 0.00925x the distance from the pinhole to the projection screen (you can do this math yourself with a little trigonometry: if `d` is the distance, `s` is the image size, and `theta` is the angle, then `1/2 s / d = tan(1/2 theta)`, so `s/d = 2 tan (1/2 theta)`). This is why a pinhole viewer with a length of 1m shows an image of about 1cm. This is certainly a visible image, but not very impressive and not large enough for many people to view comfortably.

(Yes, there's an image of the Sun in the shadow on the righthand image: it's quite faint but if you look carefully you'll find it. A darker target area would improve the contrast.)

What if we want an image 30cm (about 1 foot) across? Working backwards, 30cm / 0.00925 = 32.43m, which is a bit over 100ft. That's big. If at this point you're envisioning a 100-foot cardboard tube with a pinhole at the end, supported by a crane so it points at the Sun, read on: there's a better way. Turns out we can skip the tube: all that really matters is that the image winds up projected into a dark place for easy viewing. And we don't even have to put the pinhole directly between the Sun and the viewing location. We can do the same trick with a pinhole mirror, and we can site that at ground level. The large brains at Cambridge did this for the 2004 Venus transit of the sun and got some beautiful imagery.

What we still do need is (1) a dark room, (2) with a nearby open door or window (we'll need to think a bit about letting in the light from the viewer without letting in so much ambient light that we spoil the image), (3) pointing into an open area at least 100 feet long, (4) which will be able to view the sun during the total eclipse on April 8, 2024. Turns out I have relatives who satisfy every one of these conditions. So we're in good shape: just get a mirror, put some electrical tape over most of it, wait seven-plus years, and then reflect the eclipse into the dark room.

Alas, it isn't quite that simple. According to NASA, the eclipse is expected to last 2 hours, 39 minutes and 20.3 seconds, during which time the Sun will cross around 40 degrees of the sky. If we focus the image at the beginning of the eclipse, the image will drift as the Sun moves. The drift rate is around 1 solar diameter every 2 minutes (the math: 360 degrees over 24 hours is 15 degrees/hour or 0.25 degrees/minute, and the Sun is 0.53 degrees wide). We need to have the mirror track the Sun to keep the image centered. With my 1m pinhole viewer I just moved it manually, but this is impractical for a 30m focal length.

Next week, we consider how to build an automated mirror pointer...