Pikes Peak SkyCam Information
Looking for the SkyCam?
The Pikes Peak SkyCam is here. This page explains the purpose of the SkyCam and how it works.
SkyCam Focus
There are a lot of Cams out there and quite a few Pikes Peak Cams. One of the things that inspires me the most about Pikes Peak is its
cloud formations and the light shows that often accompany them. Because some of the other Peak Cams do such an excellent job of viewing the Peak
itself the SkyCam uses a wider angled lens so that more of the sky surrounding the Peak can be seen. This is where the Sky in SkyCam comes from!
SkyCam Setup
Setting up a Cam is a very simple process. However since the SkyCam is about 80 feet away from the computer a typical USB
Cam could not be used since they do not allow for very long cable runs. The WinCam
can be up to 200 feet away using inexpensive cat 5 cable and much farther away with a relatively inexpensive adapter. Although outdoor enclosures
are sold for the WinCam I opted to build an enclosure out of a small garbage can. It was simply turned upside down and silicon was used to affix
an inexpensive UV filter over the small hole cut into the can for the Cam lens. The sunshield was made out of aluminum dryer duct. Except for a few weeks out of the year it keeps sunrays from directly reaching the lens which causes bad reflections. Nothing can be done to save the image when the sun is in direct view of the Cam however.
Uploading the Images
This is the easy part:-) The WinCam comes with software that allows you to set your FTP schedule. As you can see from the screen shot there are a lot of options.
The software was set to upload the photos 2 minutes before the page would be refreshing. 2 minutes was used because that is enough time for
the WinCam to take the picture, process the image, and FTP it to the website. I added a 2 to the Time Offset field so that the timestamp reads correcly.
Displaying the images
All that was left was addressing a display issue that seems common on many Cam pages which is that they refresh based on a timer
that has nothing to do with when the image is actually updated. That is no big deal if the image is updated often. However many outdoor Cams, including
the SkyCam, update only after 10 to 30 minutes or even longer. If the timer for the refresh starts when you first visit the
page the page may refresh a long time before or after the image is updated. This also makes figuring out when the
next real image update will occur very hard, especially if the incorrect timer is displayed as it often is. In fact, they are usually displayed
as a countdown to next image timer but after waiting out the countdown it is often a bummer to find out that it was really just a countdown
to a refresh that displays the same image:-(
What time is it? Part 1
To address the timer issue the time that the page is being viewed is needed so it can then be calculated when to do a refresh. I started with this
simple line of JavaScript code:
var now = new Date();
This returns the time on the users computer. Another line of code is used to account for when people look at the SkyCam while in another
time zone:
var PcOffset = now.getTimezoneOffset()/60;
From there it is pretty straight forward to check the zone adjusted PC time against the SkyCam schedule.
If the adjusted time is before or after the SkyCam is running a slide show gets started. Otherwise the most current photo
is displayed until it is time to refresh the page 2 minutes after a new photo is uploaded. Done! Why do so many Cam pages refresh
at the wrong time?
What time is it? Part 2
Too simple! It turns out that very few people keep track of their PCs clocks let alone keep them accurate to within the 2 minute window
that the upload schedule calls for. As such, all those with PCs with clocks 2 or more minutes faster than mine would see a page refresh before
a new photo was uploaded which left them just as bad off as they were on the Cam pages that did not even try! When the SkyCam page was first put up a
note about setting the computers time to the correct time was displayed. Of course that was not very user-friendly:-(
The solution was to change the page from an HTML page to an ASP Active Server Page. That is why this HTML page is no longer
the SkyCam page. Although the SkyCam had been up for only 2 days this page was turned into the about page just in case some people had already
added it to their favorites folder.
At any rate, in the ASP resides this line of code:
ServerTime = time()
Unlike the JavaScript Date() command the Time() command gets the servers time. The first bonus here was that it got rid of all the time
zone issues! Not much else had to change. There, now I can sleep at night:-)
What time is it? Part 3
Well, not quite. It turns out that the web host does not keep their PCs clocks very accurate either. However, that is just one computer so
it is just a simple matter of adjusting the time that it gives with the following line of code:
ServerTime = dateadd("s", 416,time())
This simply adds 416 seconds to the servers time which was the difference between the servers time and the official US time
for my time zone when the SkyCam page code was written. Once in a while a little piece of code I wrote is run
to check to see if the adjustment number needs updated. The page I use has an extra line of code that writes the adjustment number to an ASP
file that gets included by the SkyCam ASP making manual updates to the code unnecessary:-) The number the code writes for my computer works
for the SkyCam page because it is the computer that uploads the images to the server so it is the only one that needs to
be concerned about the 2 minute window. Also my PC is kept synchronized using the built in Network Time Sync option built into the
WinCam software see screen shot above. For those that dont have a WinCam you can download a free Atomic Clock Sync utility off of the web:-)
In the closet
After a couple of months of running the SkyCam on my main PC I transferred the WinCam software over to an old
Pentium 90 and stuck it in the closet. With the closet doors closed you cant even
hear it and I keep the monitor turned off about 99% of the time:-)
That is where things are as of now. Feel free to ask questions.
SkyCam Pseudo Code
This is the logic behind the SkyCam code. You can look at the source of the SkyCam page to see the actual JavaScript code. You wont see the ASP code because by definition it is parsed as it is fed to your browser. The key here is that when the ASP page is written
the variable ServerTime mentioned above gets written into the Pikes Peak time form. From there the JavaScript reads it and uses it as the basis for
adjusting the time as it does all of its calculations.
ASP - run when page written
Store server adjusted time in Pikes Peak time form
HTML - written as page loaded
Display last photo and all the information
JavaScript - run while loading
Get pre load UserTime
Declare vars like cam start/finish, slide info etc.
JavaScript - run after page loaded
Get post load UserTime
Calc load time
Add load time to ServerTime (important for slow connections)
Calc difference between UserTime and ServerTime*
Call Timer Function
Get UserTime
Adjust UserTime with difference to ServerTime
Write Pikes Peak time
Calc time to next photo
Write time to next photo
If time for new photo then reload page
If time to next photo greater than CamInterval set Cam to off
If Cam off start slide show
If delay count not reached add 1
else next slide
Timer Function calls itself every second
*You will note in the actual code I check to see if I am seeing ASP code
or not. This is because I look at the SkyCam while offline to see what is
getting posted for the users and ASP does not run offline.
Return to the Pikes Peak SkyCam Page
|