OK, let me "PIC" your brain...

Status
Not open for further replies.
And more:

To Mike, K8LH: You can check the usage out from the previous posts. Thanks for the code, but I ain't got a clue as to what to do with it!

To joemcder: The axial tilt mentioned was in reference to the sun. And leap years are a result of both rotational and revolutional anomalies. Thanks for the tips!

To Reloadron: For the GPS angle; Might have to try that one! Thanks!

And to Mikebits: Captain Kirk's dog was a Great Dane named Butler. (Nexis) Re: Star Trek Generations. Good question. Trekkies love to yak about their stuff!


Keep it coming, guys! Chew me up, spit me out, but keep bringin' the data. I figure that when this is all over I might wind up being the world's foremost authority on Sidereal Time. (I will DEFINITELY be the world's foremost authority on foolish endeavors.) Thanks again to all!

P.S.--If you're curious about the Local Apparent Sidereal Time at your location, check out the U.S. Naval Observatory's LAST calculator here: [https://tycho.usno.navy.mil/sidereal.html]
 
Last edited:
While I despise PICs from a production standpoint, these days using one is like PICking your corporate nose after the manner of the Egyptians ( have you seen the movie "The Mummy"? ), they are often a good choice for hobbyists.

using a 32KHz watch crystal, a temperature compensation algorithm, and a 1-5 second offset per day you can get a clock that will keep within one minute per year, and you CAN do it with a PIC.

What you can NOT do is calibrate something with the accuracy you want without a very EXPENSIVE time base. Is it worth your money to spend a few hundred dollars to rent a frequency counter of the caliber required?

Dan
 
To Mike, K8LH: You can check the usage out from the previous posts. Thanks for the code, but I ain't got a clue as to what to do with it!

Hi captain',

You asked if you could build a Sidereal Clock with a PIC and I was trying in my own stumbling and bumbling way to tell you that you could, just not exactly in the way you and other Forum members might have imagined.

I asked how you were going to use the Clock because there are plenty of ways to display Sidereal time on your PC or a laptop already. I was curious if you had a Clock circuit and just wanted to drive it with pulses from a PIC "sidereal" time base generator or if you wanted to build an entire Clock with display (LCD or 7-segment) around the PIC?

The code example does exactly what the comments say it does. If you include that very simple driver in a PIC program you can generate 86,400,000 "sidereal" millisecond pulses in an 86,164.1 second day. If you add display hardware and drivers to the PIC and build a relatively simple program you can display local time, UTC time, and "sidereal" time, if you like. Plenty of chaps here on the Forum can help write the program if you're interested in building this project.

With a 'standard' crystal you can expect accuracy of about 1 second per month but not much better then that due to crystal aging and temperature drift. This implies that you should calibrate the Clock before using it to aid in your observations because the time could drift by 20 or 30 milliseconds each day.

Using a TCXO instead of a crystal would improve performance significantly. AADE used to offer a small 1-ppm 10-MHz TCXO board for $15 but I don't see it listed on their site anymore.

So, are you thinking about building somethin' like this or are you just kickin' tires (grin)?

Regards, Mike
 

Attachments

  • sidereal clock..PNG
    16.9 KB · Views: 157
  • sidereal clock #2&.PNG
    27.4 KB · Views: 159
Last edited:
So, who's got a price list and a tutorial? I don't want to do it this way, but that's what I keep getting. Are PIC memories non-volatile? I don't want to have to do this again when I change batteries. Thanks. <ckd>
 
I'm wary about helping anyone who comes from "Uranus" but here goes anyway...

One system you can use is this high-adjustable technique from my web page;
Code:
Clock xtal super-fine calibration.

The int period and 1second period value can both be multiplied by the same number, giving an increase in the timer resolution much greater than the original resolution of the xtal value in Hz.

This next example uses a PIC with 1Mhz xtal, and testing against a GPS receiver over a month shows the PIC clock is 9 seconds fast. So the 1second correction value is calculated as;
(1month+9secs) / 1month which in seconds is; 2678409 / 2678400
Which is 1.0000033602
Multiply by 1Mhz to give the correct 1 second period; = 1000003.3602 ticks


Since we are using an unsigned long variable for the bresenham accumulator the same code will take a value up to 4.29 billion with no issues. So we just multiply both the periods by 1000, which gives 1000 times finer resolution to calibrate the clock but still uses the same simple C code;

C code for PIC 1Mhz xtal super-fine calibration

	// uses 1 variable; unsigned long bres
	// gets here every TMR0 int (every 256 ticks)

	bres += 256000;		// add (256*1000) ticks to bresenham total

	if(bres >= 1000003360)	// if reached 1 second!
	{
		bres -= 1000003360;	// subtract 1 second, retain error
		do_1sec_event();	// update clock, etc
	}

This gives you adjustability down to 1 billionth of a second, obviously you just put int he value you want, and you need a good xtal too and possibly keep the xtal at a regulated temperature.

Below would probably be my preferred method, to use the 50Hz or 60Hz mains (not a xtal) to generate your sidereal time;
Code:
Procedure;
1.  Count 6 mains input pulses (period is 0.1 second)
2.  Add 100000000 (0.1 billion)
3.  If accumulator >= 973350540;
   3a.  generate a sidereal second
   3b.  accumulator -= 973350540

As you can see that is the same basic zero-error algorithm but will generate the sidereal seconds directly from the mains fequency which in most civilised countries is locked to atomic clocks. Obviously for 50Hz countries you count 5 pulses per each iteration, for 60Hz countries you count 6 pulses per iteration.

As the sidereal second is smaller than one second you use the reciprocal, ie 1 / 1.0273 etc.

If you want mega accuracy you can just bump the resolution, instead of 1 second = 1 billion ticks make it 1 second = 100 billion ticks etc.

Hope that helps, my web page here; Zero-error 1 second timing algorithm
has more info on generating any time period from any xtal or from any input frequency etc.
 
Last edited:
Hello, Mr. Black,
Thank you for the code, (although I'm not sure at all what to do with it). Also, what kind of hardware am I looking at? I've never used any kind of PIC so any advice you have is appreciated. The AC mains idea you suggested is not practical as the whole point is to be able to take the device out into the field. In a perfect world, my wish would be to have a small, hand-held device where I would enter the longitude and latitude, press enter, and the Local Apparent Sidereal Time would be displayed. It would also be nice if it were linked to WWV or a GPS signal as well. Dream on, right?
 
Aha. Out in the field handheld and GPS etc. I thought you wanted to build something cool but it seems you want easy functionality. That changes things.

If you get one of these whizbang new phones that does everything including GPS, i'm sure you can just download an app that will display sidereal time and probably a heap of other astronomical data too, all synced to GPS.

Have you tried a google search for "iPhone astronomical time apps" or similar?
 
Never mind. To me it WOULD be cool. To build. And I'm NOT looking for some phone app. Although...I wouldn't mind finding a way to program my old TI-85 with an app. I'd have to modify it, of course, with a red backlight, but that shouldn't be too hard.

All the talk I've been getting about PICs has made me think that, "Hey, if a PIC can be programmed to turn on the stove, well then, teach it to crack the eggs, fry the bacon, and make the biscuits. Maybe even set the table, as well." In translation: I would find a cheap (low-cost, not crappy) GPS unit, find out how to get the time and coordinate data from it, feed that to the PIC, run some killer equations and have it poop out an answer. I would have a keypad for manual input, if necessary.

If that's a no-go, then a 60kHz RF link to WWVB and a bunch of US Forest Service Maps, (for longitude; their the only source I know). If this is still a fantasy, then I'd be happy with just a plain, ole digital clock that runs at the Sidereal rate.

I suppose that getting what I want is like trying to chop down a redwood tree with a kitchen knife. Too big a project with insufficient skills and the intelligence to do it. Maybe I should just quit and take up knitting. <ckd>
 
$30 GPS module...not a whole GPS unit

All the control and data are accessed through an asynchronous serial interface. then all you have to do is wait for a satellite lock and spit out the data to a display
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…