Calculate the Right Ascension of Polaris

Go To Last Post
14 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In order to correctly polar align a telescope (so that it can accurately track the movement of the stars) a popular method is to use a 'polarscope' which requires knowledge of the current position of polaris, which moves around the true north pole in a small circle.

 

I had assumed that all one needed to know was its right ascension, which is added to the sidereal time MOD 24 hours. This is correct, but I did not know that Polaris' RA is changing rapidly, by 21 minutes since New Year 2000, and about 4 1/2 hours by 2100. Obviously this is a large enough drift that it needs to be taken into account - the polarscope reticule is marked in 1-hour divisions and can be estimated to about 10 minutes.

 

A plot of RA against year shows that it can be closely approximated by the equation (using just the last two year digits):

 

RA = 0.0092 * year^2 + 1.0998 * Year + 150.57

 

But, an accuracy of just 3-4 minutes is plenty for good polar alignment with a polarscope. This means we can approximate it easily using simple integer multiplication and right-shift division. Here's my solution, there are probably better ones but this is good enough. Note the use of the carry for rounding and that the final big division (by 128) is left to the end to retain accuracy.

 

;Calculate RA of Polaris given year in minutes

;RA = 150 +(year/8 + year) * (year+128)/128 give an accuracy of no worse than 3 minutes

POLARIS_RA:
	lds		temp,DATE+2	;Put current year in temp1
	mov		temp1,temp

	lsr		temp1
	lsr		temp1
	lsr		temp1			;year/8
	mov		temp2,temp1
	brcc	SKIP55
	inc		temp2			;round
SKIP55:
	add		temp2,temp		;year/8+2

	ldi		temp1,128
	add		temp1,temp
	mul		temp1,temp2
	lsr		R1
	ror		R0
	lsr		R1
	ror		R0
	lsr		R1
	ror		R0
	lsr		R1
	ror		R0
	lsr		R1
	ror		R0
	lsr		R1
	ror		R0
	lsr		R1
	ror		R0
	brcc	SKIP56
	inc		R0			;round
SKIP56:
	ldi		temp1,150		;add offset
	clr		temp2

	add		temp1,R0		;Ra in minutes in Temp1:temp2
	adc		temp2,R1

ret

 

It's me again...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

And in C that would be 1 line so you can then move on to thinking about the more important stuff! ;-)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I guess you are proposing that this code could be included in a telescope controller, is that right?  It occurs to me that you could also store a byte array of minutes_offset[], beginning with 2016 as offset 0.  You mentioned about 4.5 hours until 2100, so a single byte would cover most of that (and you know that in 2090 nobody would be using your device - in fact, it doesn't make sense to program for much beyond when your flash is likely to fail anyway).  Anyway, your code and approach take me back about 40 years to my own youth, programming a 2 MHz 8080 (but _I_ didn't have a MUL instruction!) and burning the programs onto 256x8 EPROMS.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

256x8 eproms! Luxury!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I just get a kick out of hard coding a function, complex or simple.

 

Finding a solution is like solving  a cryptic crossword clue.

 

Wasted some time yesterday on calculating sine using integers and only right-shift division, but a look up and interpolate will be more than enough for my needs.

 

Must be mad...

 

Neil

It's me again...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There's always CORDIC for such things.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Neil don't listen to the fun police an enjoy your assembler. wink

 

As always, in my bottomless pit of ASM stuff, I have sine and cosine routines. Never used them myself but they are supposedly able to run with AS4 end therefore the Atmel assembler.

The author is  João D´Artagnan A. Oliveira from Brasília, Brazil.

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

js wrote:
The author is João D´Artagnan A. Oliveira from Brasília, Brazil.

I'm just trying to get my head around the difference between using sin/cos written by another Asm programmer and the sin/cos provided in a C library (which, surprise, surprise, was also written by an Asm programmer). cheeky

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Because one is written in ASM (which the OP understands) and the other is written in C which the OP may or may not understand or even want to understand. wink

 

Anyway you must admit that something written by a D´Artagnan would be very sharp and to the point.....

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I would be pretty certain that the ASM routines that are written for the GCC libraries will have clear documentation on input conditions, registers used, outputs, ...
And should be understood by anyone.
The only "connection" to C is that register use will follow some form of convention. Anathema to the diehard ASM enthusiast.
.
Yes, there is satisfaction to be gained from a short or fast solution. Especially if it has a noticeable effect on the program size or efficiency.
.
For a one-off calculation, I doubt if the Stars will ever notice.
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Cordic is good but where extreme accuracy isn't important but a straightforward approach is, I'm surprised Bhaskara I's formula isn't more well known.

 

https://en.wikipedia.org/wiki/Bhaskara_I's_sine_approximation_formula

It's me again...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Depends if you consider multiply and division expensive.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Fewer multiplications than Cordic, so it's just the one division, but my point was more about simplicity than efficiency.

It's me again...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Stub_Mandrel wrote:

I just get a kick out of hard coding a function, complex or simple.

 

Finding a solution is like solving  a cryptic crossword clue.

 


Yep, I can understand this.  A while back I dusted off my ASM chops and wrote an ASM routine to drive strings of WS2812 RGB LEDs with an 8 MHz AVR (at the time I could only find code for 16 MHz AVRs).  It was the same puzzle-solving mentality driving me.