Telescopic 1.0.1 Digital setting circles and display. 1.0.2 added ra/dec in one line march 2007 This code by A.M.Hugo 2004...2007. Squeezes into a 16F628 PIC. Email to: amhugo@optusnet.com.au Features: 12 character LED display of a telescopes position in RA and Dec Uses commercial encoders or home brew Mouse encoders to Digitize position Simultaneous display of encoders for RA and DEC axis Save and restore values in EEPROM 16 Navigation stars 8 Save and recall set points for user defined objects Real Time clock and siderial time counter Stopwatch / lap timer mode - 16 time records in EEPROM Serial data communications with your computer - MAX232 compatible Credits: Ideas from all over the net: Nigel Goodwin (RS232) Ed ? (digital setting circles) etc, 2003 Hardware assignments 12 character LED port: display messages and coordinates using only 3 wires by shifting (multiplexing) segment data and digit address to two 74HC595 chips; 2 Encoder inputs (4 wire) for RA and Dec encoders RS232 Serial Receive and Transmit Port LED lamp output for seconds indicator (1 sec ON, 1 sec OFF) 4 Pushbuttons for mode setting, increment, decrement and OK Internal Real time clock in case you stay out too late Siderial clock for RA conversion of hour angle encoder Stand alone mode. Doesn't need to be connected to a PC. (download/upload if it is) Notes: The Siderial timer is used to generate RA coords from encoder hour angle. It accurately follows the siderial rate but it is not 'correct" in an absolute sense. It is adjusted everytime the telescope is synched with the sky, to a value which makes the internal calcs work; so don't rely on it for truth. There is a stopwatch or lap timer function accurate to 100ths of a second. Button '+' could be "start counter" '-' "stop counter and save in EEPROM" 'OK' "record lap time" There is room for 16 time records to be stored in EEPROM and downloaded later TELESCOPIC - OPERATION SET UP Connect unit to telescope. First task is to set your lattitude... Align telescope on meridian (vertical) so that DEC display is the same as your lattitude Press mode button until "Set Lat" is displayed on LED Press OK button to activate This will store the declination encoder count as the Latitude in EEPROM. From now on, start each session by setting the time and declination counters followed by synching with one alignment star to set the siderial time as follows.. AT THE START OF EACH SESSION: SETTING TIMES: Press mode button until "tod hr" (Time of day, hours) is shown on LEDs Press '+' or '-' key to increment or decrement the hours value Repeat for "TOD nn" (Time of day, minutes) There is no need to set the Siderial time. SETTING THE DEC AXIS Align telescope on the local meridian with the tube vertical, with a level. Press mode button until "Set dEc" is displayed on LED Press OK button to activate This will centre RA encoder and set DEC to the Latitude stored in EEPROM (If the telescope tube is vertical, it is pointing at the declination equal to your lattitude) This will give rough alignment in DEC but not RA ALIGN TELESCOPE (USING ALIGNMENT STARS) Move telescope so that the selected star (say, Rigel) is centred, Press mode button until you see "Set" followed by a starname on the display Press + or - to change to the desired star name. (16 nav stars available) Press OK button to change the RA and DEC to the star position & update encoders. CREATE A SET POINT (USING ANY STAR OR OBJECT) Move telescope so that RA, DEC are true to selected object (say, M42), Press mode button until "Set Pt" is displayed on LED Press + or - to change to the desired set point, 0-7 Press OK button to save RA, DEC position in EEPROM Centre the same object in the telescope and execute the RECALL routine, next. SETTING THE RA & DEC ENCODER COUNTS FROM A SET POINT Move to the object used as a set point (say, M42) and centre in eyepiece or CCD Press mode button until "Recall " is displayed on LED Press + or - to change to the desired set point, 0-7 Press OK button to synch RA and Dec counters to this object (Stored in EEPROM) This will recall last values for RA, DEC and set Siderial time & Encoders as needed. CHANGE ENCODER LIMITS TO SUIT YOUR ENCODER TYPE Press mode button until "RA top" is displayed on LED Press '+' or '-' key to increment or decrement the value & save in EEPROM Press mode button until "dEctop" is displayed on LED Press '+' or '-' key to increment or decrement the value & save in EEPROM Note: if the encoder limits are changed, you will need to change the corresponding calculation constant as well. EDIT A CALCULATION VARIABLE The EDIT mode enables you to change any constant used by the program in the data variables, in the range 0f 0x20 to 0x7F. This is both clever and dangerous! Clever because you can update any variable, dangerous because you can mess up everything without even trying, especially if the changes are committed to EEPROM... Suppose you fit a new dec encoder with 8192 counts per full revolution (360 deg). This will not work properly because the calculations for Dec rely on a fixed constant that suited the old encoder, and this constant is loaded from EEPROM when Telescopic is turned on, so all the dec values are now wrong. What to do... First calculate a new Dec calc constant, thus: 216000*65536/EncMax, or 216000*65536/8192 = 1728000. In Hexadecimal this is $1A5E00 This value is stored at address 0x48 (low byte), 0x49 (mid byte) and 0x4A (high byte). Now use the EDIT mode to change these three variable addresses to your new values. Press mode button until "Edit" is displayed on LED along with a hex address. Press '+' or '-' key to increment or decrement the address until it matches the high byte. i.e. it will display "Edit 4A". Press the OK button to start editing that variable. The display will change to " Edit 4A 15" where 15 is the current hex value at $4A. Press '+' or '-' key to increment or decrement the value (change it to "Edit 4A 1A") At this point, no change will actually occur until you press the OK button. (You can cancel the edit by pressing the MODE key.) Press OK to make the change. In a similar way, change the other two variables: "Edit 49 5E" and "Edit 48 00" At this stage, your new values can be tested, but they will only remain valid until TELESCOPIC is turned off. (Restarting will restore the old values from EEPROM). To make the changes permanent, the data bank must be saved to EEPROM. Note: The hour angle calculation constant is at adresses 45, 46 and 47 (hex). The hour angle calculation is 86400*65536/HAEncMax. SAVING OPERATIONAL DATA TO EEPROM Press MODE button until "Set EE" is displayed on LED Press OK button to save the data in EEPROM, overwriting previous values. The following information is saved in EEPROM: The Set Point number, Time of day, Siderial time, RA and DEC calculation constants, navigation star number, encoder maximum values, current encoder count, latitude count, edit location, RA hr-min-sec and Dec deg-min in the form dd mm.m Display Modes: 0 display time of day: hr mm ss 1 display RA hh mm ss 2 display DEC -dd mm.m 3 set point: copy decoders to eeprom 4 recall point: restore encoders from eeprom 5 set navigation star 6 Set declination to latitude 7 Set latitude as current declination 8 display RA encoder value 9 display DEC encoder value 10 display RA max encoder value 11 display DEC max encoder value 12 adjust Time - minutes 13 adjust Time - hours 14 adjust SidT - minutes 15 adjust SidT - hours 16 store values in EEPROM 17 Alternate encoder counts 18 Alternate time/sid 19 edit a variable 20 Lap/stopwatch function TECHNICAL NOTES: STOPWATCH & LAP TIMER CODE In lap timer mode, a counter in KHz is incremented each interupt. Every tenth count is used in a 100Hz counter up to 3 bytes long. When a button is pressed, this counter can be copied to RAM and displayed on the LEDs. as "LAP 0 234.56" Button '+' could be "start/reset counter" '-' "record lap time" 'OK' "stop counter and save in EEPROM" In order to fit this in, I've trimmed it back to display a max count of 65535 (655.35 secs) but with three bytes of storage per record. While recording, display changes from "LAP..." when off, to "rec..." when running SERIAL RS232 FORMAT process messages via rs232 receive: followed by: reply 'z' ABCD 'r' download encoder max AB-dec CD=ra, low first 'h' ---- ABCD upload encoder max limits to PC (as above) 'y' ---- ABCD upload encoder counts to PC, format as above 'p' ---- A upload error to PC (skipped counts) 'd' HMSDMS 'd' download RA and DEC for lcd display - ---- 'E' comms error - unrecognised first character The 'E' code is also sent at program startup. rs232 transmitting code: transmit character at 9600 baud. Receive byte from rs232, using interupt RB0. RB0 interrupt disabled during receive, restore it when done. Encoder processing code ENCODER COUNTER _____ ____| |_____ _____ __ __| |____| 0 1 3 2 0 0 2 3 1 0 if encoder was: 0 1 2 3 00 80 10 18 00 02 04 06 upcount should be: 1 3 0 2 80 18 00 10 02 06 00 04 downcount is: 2 0 3 1 10 00 18 80 04 00 06 02 skipped error: 3 2 1 0 18 10 08 00 06 04 02 01 INTERRUPT CODE Interrupt processing: We handle four interrupts at once Real Time Clocks (Normal + Siderial) (timer0) 7seg display multiplexer (timer1) Stopwatch counter (timer2) Serial communications (RB0) LED port 3 wire interface to 12 x 7seg LED via 74HC595 shifter RB7 data shifts segment data and digit address to two 74HC595 RB6 enable latch outputs when all bits shifted in place RB5 clock pulse clock for each bit To send address or data to the LED segs, you disable the address/decoder latch, then send the bits one at a time, and toggle the clock for each bit. After 16 bits, pulse the enable latch. SETTING AND RECALLING SET POINTS (user defined coordinates) Set Points require saving RA and DEC coords in EEPROM and retreiving them at synch time. DEC can be a straight forward save of encoder counts and restoring them later. RA is complicated by needing to account for different siderial times; The RA can be stored as hh mm ss or a 24 bit number 0-86400. From RA, subtract Hour Angle, result is the correct siderial time. This assumes that hour angle encoder is set to mid count at startup. NAVIGATION STARS STORED IN ROM This list of Nav stars is biased South because I live in Australia. There is enough info in the rom code to enable other stars to be substituted for northern observers. If so, an effort should be made to space stars evenly in RA so that one or more are available at any time of the year. Achernar A Eridani A Taurus Aldebaran Rigel... B Orion or substitute A Orion. Betelgeus Canopus. A Carina Sirius.. A Canis Major Castor.. A Gemini Procyon A Canis Mn Regulus. A Leo A Crucis Acrux Spica... A Virgo Arcturus A Boot A Cent.. Rigil Ken Antares. A Scorpio A Lyra.. Vega Altair.. A Aquila A Psa.. Formalhaut end of text