| Menu | JAQForum Ver 19.10.27 |
Forum Index : Microcontroller and PC projects : Anyone interested in astronomy?
I've got some code to test. You would need a Pico with a GPS connected to check it (and preferably a telescope). Let me know. |
||||||
Sounds interesting. I have a Pico with GPS connected but no telescope. |
||||||
That sounds very interesting! I should still have GPS receivers - I have a telescope... Frank |
||||||
While we are on the subject of GPS, The GPS code used for the PicoMite is outdated code for 8 bit micro-controllers (i.e. Arduino). Most modern GPS modules will give a few additional decimal places of precision than will fit in a single precision float. I submitted updated and tested code in this thread: https://www.thebackshed.com/forum/ViewTopic.php?TID=15035 See the last post in the thread for the updated GPS.c (zip) file. I tested the code against several generations of GPS receivers/module. It seems that the ArmMiteH743 may be the only MMBasic interpreter that was ever updated? Edited 2025-12-14 07:26 by Sasquatch |
||||||
UPDATE I've added two new commands: LOCATION datetime$, latitude, longitude This sets an internal memory of where and when you want to calculate for ASTRO [BODY] altitude!, azimuth! [,J2000RA!] [,J2000Dec!] [,pm_ra!] [,pm_dec!] This is exactly the same as the STAR command, except that it uses the location data defined by LOCATION This allows you to use the functions without a GPS 'plot the altitude against the azimuth for the moon for the next two days a%=Epoch(now) b%=a%+(86400*2) Do Location DateTime$(a%),52.02174,0.28766 Astro moon alt!,az! 'Print alt!,az! Inc a%,720 Circle az!,(alt!+100)*2,3 Loop Until a%=b% Here is what I am playing with STAR [BODY] altitude!, azimuth! [,J2000RA!] [,J2000Dec!] [,pm_ra!] [,pm_dec!] This function calculates the altitude and azimuth of any celestial object from a given location and at a given time. It uses the GPS to get the users latitude and longitude and time (UTC). Using this it calculate the sidereal time and the Julian centuries which are then used as input to the main calculations. The simple form of the command is star BODY altitude!, azimuth! This updates altitude!, azimuth with the current location of the body from the observer It supports the following bodies in the solar system + 85 named stars and galaxies MOON, MERCURY, VENUS, MARS, JUPITER, SATURN, URANUS, NEPTUNE The more complex form of the command is: STAR altitude!, azimuth! ,J2000RA! ,J2000Dec! [,pm_ra!] [,pm_dec!] This allows calculation for any celestial body based on its Right Ascension and Declination. In order to get better accuracy you can also input the bodies Proper Motion and Precession in arcsecond/year to allow the code to update from the J2000 values. The objective is to make it trivial to point your telescope accurately to any body in the sky at any time from any given place on earth given a pico and connected GPS It is currently all working and the output has been tested against authoritative sources. At the moment it is totally linked into the GPS but I will extend the functionality to allow user input of lat/long/time to allow more general use Below is the analysis of the code and what it does and doesn't do and its limitations. Edited 2025-12-15 00:46 by matherp |
||||||
~40 years ago I made an eight inch reflector telescope but never got around to motorising the mount. The main mirror needs attention but this might be a good reason to dust it off. Jim |
||||||
My project is building a 6" reflector from scratch (other than grinding the mirror). The progress so far is making the tube as a nonagon out of 1cm thick mahogany sawn from my old conservatory roof beams. The mirrors are arriving from China in the next few days: parabolic and supposedly pv1/6-1/8 - we will see. The mount will be fully computerized hence the new code and I'm learning onshape for the mount design. Should keep me busy for a few months now 6.01 is pretty much out of the way. |
||||||
Always interested in this kind of thing. One project I should get going to build my MMBasic skills is to translate the code from Caxton Foster's book "Orrery" written for PC basic so I can run them on the Pico or CMM2. Shouldn't be difficult, just need to set aside the time. (Famous last words!) |
||||||
I'm sorry to be so dense. I'm interested in this topic. How can I get access to the code? I wrote a pretty nice sunup and sundown app in MMBasic for some gadgets that play bird sounds based on sun up or sun down- it was for biologists- pretty precise and could run for months. Lat and Long was a manual input, having a GPS input would be slick. I still have interest in this and other biologists have mentioned doing monitoring bases on full moons, etc. |
||||||
Pluto is going to be miffed.. left out in the cold.. ![]() |
||||||
I have been using Stellarium on a laptop connected to a commercial servo tripod to position and track stars. I can use my Cannon camera with a short or long lens to take pictures, or watch on the laptop screen, or a smaller telescope to look through. While that is nice, I have a rarely used 6" Dobsonian reflector that just has a position readout. Once aligned, I can move it to a target manually and the readout gives me the position. It does work but there are two problems. I would prefer to automate the reflector to move based on a program and I would like to mount a telescope camera on it. I have hardly used the reflector because of the effort to point it and having to bend over a lot, at my age, to see things. Of course, the weight and bulkiness make it hard to transport and setup but it can be done. What I need is an incentive to do something about the shortcomings of using the reflector. A little control panel that allows me to find or enter coordinates, and the reflector points itself would be great. Having a tracker would be nice as well or at least the ability to watch a small view of the sky while fine tuning the position would be good. |
||||||
I have an 8" reflector (GSO) and a Skywatcher EQ5 equatorial mount. I have added stepper motors to drive it and written a Picomite program to control the tracking. I have added a database of all the objects brighter than magnitude 9. I have not been able to test it because it has been always cloudy whenever the time is suitable. Maybe over xmas. I have written code that does similar things to what you have done but have not included the planets - that is next level. I am thinking of redoing it and your function would be very helpful. The alt-azimuth system suits simpler mounts and works against my mount as I need to covert everything to equatorial coordinates. I am not using a GPS as I know my location (setting in my program) and I am using an accurate RTC to get accurate time. Maybe you could allow these to be optional parameters. This is handy because sometimes you want to calculate for other locations. Rather than using the Picomite touchscreen, it is better to let it just to the tracking and accept commands using the Skyscan protocol (or others) over Bluetooth. You can then use Stellarium on a mobile phone or tablet to control it. This is far better than what I have done and is a superb program with lots of data and images built in. |
||||||
Other things to think about: In the southern hemisphere we don't have the luxury of Polaris and the best we have is very faint. The advanced mounts allow you to take sighting of multiple stars and then use that data to offset the calculations and the tracking. As long as you point the telescope roughly in the right direction they work fine. Another option is tracking stars. With a tracking mount, wait 10 minutes and see how far the star has drifted off and use that as a correction. With equatorial mounts you can move across half the sky and then you need to do a flip to see the other half. So you tend to want to see what is nearby before doing that. For beginners like me you really want to see cool stuff but you need to know what you are looking for, how big it is and what to expect. Even with a large telescope the really cool stuff is faint. You are lucky enough to have Andromeda easily accessible. So you really need cooled cameras with lots of multiple exposures and heaps of compute to see them. If find the Australian forum very informative: Ice In Space |
||||||
It is very easy to convert altitude/azimuth to equatorial coordinates. I'll find a way to integrate this into the code. The code will be in 6.01.00 for the rp2350 but I won't include in the manual but will write a separate note on how to use it. The code already supports calculations based on any arbitrary location and time using the LOCATION and ASTRO commands as in the snippet of MMBasic code in my previous post. jwettroth: Basic GPS support is already in MMBasic. Have a look at the OPEN command and GPS function. damos: Does your database include the motion parameters for the stars? If so, could you let me have it and I can integrate any I'm missing - my data is below. const Star starCatalog[] = { {"Achernar", 24.428000, -57.236750, 0.09774, -0.04008}, // HIP 7588" {"Acrux", 186.650000, -63.099000, -0.03500, -0.01400}, // HIP 60718" {"Alcyone", 56.871250, +24.106111, 0.01900, -0.04500}, // HIP 17702" {"Aldebaran", 68.980162, +16.509301, 0.06278, -0.18894}, // HIP 21421" {"Algenib", 0.139167, +15.183333, 0.00200, -0.00300}, // HIP 1067" {"Algieba", 154.993333, +23.750000, -0.24800, -0.05000}, // HIP 50583" {"Algol", 47.042083, +40.955556, 0.00200, -0.00300}, // HIP 14576" {"Alhajoth", 14.177500, +60.716667, 0.00200, -0.00300}, // HIP 12390" {"Alhena", 116.313333, +14.195000, -0.07100, -0.02000}, // HIP 31681" {"Almaak", 2.065000, +42.329000, 0.00400, -0.00200}, // HIP 9640" {"Alnair", 332.058333, -46.960000, 0.01000, -0.01200}, // HIP 109268" {"Alnilam", 84.053389, -1.201917, -0.00100, -0.00200}, // HIP 26311" {"Alnitak", 85.189000, -1.942000, -0.00300, -0.00200}, // HIP 26727" {"Alphard", 141.896389, -24.374167, -0.02400, 0.00600}, // HIP 46390" {"Alpheratz", 2.096389, +29.090556, -0.13600, -0.05000}, // HIP 677" {"Alpherg", 23.079167, +15.205000, 0.02500, -0.01000}, // HIP 11767" {"Alrescha", 30.511667, +2.763333, 0.13500, -0.05000}, // HIP 8833" {"Alsephina", 114.828333, -30.360000, -0.01800, -0.01000}, // HIP 31592" {"Alshain", 296.565000, +6.425000, 0.53600, 0.38500}, // HIP 94779" {"Altair", 297.695827, +8.868322, 0.53682, 0.38554}, // HIP 97649" {"Aludra", 97.962083, -29.247500, -0.00400, -0.00200}, // HIP 30324" {"Andromeda Galaxy (M31)", 10.684708, 41.269167, 0.0, 0.0}, //" {"Antares", 247.351915, -26.432002, -0.01016, -0.02321}, // HIP 80763" {"Arcturus", 213.915300, +19.182410, -1.09345, -2.00094}, // HIP 69673" {"Aspidiske", 122.383333, -47.336667, -0.01200, -0.00600}, // HIP 39953" {"Bellatrix", 81.282000, +6.350000, -0.00800, -0.01300}, // HIP 25336" {"Betelgeuse", 88.792939, +7.407064, 0.02495, 0.00956}, // HIP 27989" {"Bode's Galaxy (M81)", 148.888750, 69.064444, 0.0, 0.0}, //" {"Canopus", 95.987875, -52.695718, 0.01993, 0.02324}, // HIP 30438" {"Capella", 79.172327, +45.997991, 0.07552, -0.42713}, // HIP 24608" {"Caph", 2.294167, +59.149444, 0.00300, -0.00200}, // HIP 746" {"Castor", 113.650000, +31.888333, -0.19100, -0.04500}, // HIP 36850" {"Cigar Galaxy (M82)", 149.062500, 69.679722, 0.0, 0.0}, //" {"Deneb", 310.357979, +45.280338, 0.00146, 0.00129}, // HIP 102098" {"Denebola", 177.264167, +14.572056, -0.49700, -0.11400}, // HIP 57632" {"Dubhe", 165.460000, +61.751000, -0.13500, -0.03500}, // HIP 54061" {"Elnath", 81.572917, +28.607500, -0.00400, -0.00900}, // HIP 25428" {"Eltanin", 269.151667, +51.488889, -0.00900, -0.02200}, // HIP 87833" {"Enif", 333.375000, +9.875000, 0.00400, -0.00300}, // HIP 107315" {"Fomalhaut", 344.412750, -29.622236, 0.32995, -0.16467}, // HIP 113368" {"Gacrux", 187.791667, -56.363056, -0.04000, -0.01400}, // HIP 61084" {"Hadar", 210.955000, -60.373000, -0.03300, -0.01400}, // HIP 68702" {"Homam", 326.046667, +9.875000, 0.00300, -0.00200}, // HIP 106481" {"Kaus Australis", 283.816667, -34.374167, 0.01300, -0.02500}, // HIP 90185" {"Kochab", 222.676667, +74.155000, -0.01700, -0.01100}, // HIP 85670" {"Kornephoros", 245.997500, +21.489444, -0.00900, -0.00600}, // HIP 80816" {"Large Magellanic Cloud", 80.891667, -69.756111, 0.0, 0.0}, //" {"Lesath", 263.733333, -37.103333, -0.00200, -0.00100}, // HIP 85927" {"Markab", 346.190000, +15.205000, 0.02500, -0.01000}, // HIP 113963" {"Menkalinan", 90.983333, +44.947500, -0.00400, -0.00900}, // HIP 28360" {"Mimosa", 191.930000, -59.688000, -0.03695, -0.01342}, // HIP 62434" {"Mintaka", 83.001667, -0.299167, -0.00200, -0.00300}, // HIP 25930" {"Mirfak", 51.080833, +49.861111, 0.02500, -0.02700}, // HIP 15863" {"Nunki", 283.816667, -26.296111, 0.01300, -0.02500}, // HIP 92855" {"Peacock", 311.918333, -60.282222, 0.01300, -0.01000}, // HIP 100751" {"Polaris", 37.954560, +89.264109, 0.19893, -0.01560}, // HIP 11767" {"Pollux", 116.329000, +28.026200, -0.62655, -0.04595}, // HIP 37826" {"Procyon", 114.825493, +5.224993, -0.71459, -1.03677}, // HIP 37279" {"Rasalgethi", 259.056667, +14.390000, -0.00900, -0.00600}, // HIP 84345" {"Rasalhague", 263.733333, +12.560000, -0.13700, -0.23400}, // HIP 84893" {"Regulus", 152.093333, +11.967222, -0.24993, 0.05027}, // HIP 49669" {"Rigel", 78.634467, -8.201639, 0.00187, 0.00056}, // HIP 24436" {"Rigil Kent", 219.902058, -60.835153, -3.67925, 0.48184}, // HIP 71683" {"Ruchbah", 10.126667, +60.235000, 0.00200, -0.00300}, // HIP 4427" {"Sabik", 250.321667, -15.757222, -0.00800, -0.00400}, // HIP 81266" {"Sadalmelik", 322.493333, -0.010000, 0.00200, -0.00300}, // HIP 109074" {"Sadalsuud", 330.790000, -0.319000, 0.00300, -0.00200}, // HIP 110960" {"Sadr", 305.557083, +40.256667, -0.00200, -0.00300}, // HIP 100453" {"Saiph", 86.939167, -9.669722, 0.00400, -0.00200}, // HIP 26207" {"Scheat", 345.940000, +28.080000, 0.02500, -0.01000}, // HIP 113881" {"Shaula", 263.402083, -37.104167, -0.00200, -0.00100}, // HIP 85927" {"Shedir", 10.127500, +56.537222, 0.00200, -0.00300}, // HIP 3179" {"Sirius", 101.287155, -16.716116, -0.54601, -1.22307}, // HIP 32349" {"Small Magellanic Cloud", 13.158333, -72.800278, 0.0, 0.0}, //" {"Sombrero Galaxy (M104)", 189.997917, -11.622778, 0.0, 0.0}, //" {"Spica", 201.298247, -11.161322, -0.04235, -0.03173}, // HIP 65474" {"Suhail", 131.175000, -42.654167, -0.01000, -0.00500}, // HIP 42312" {"Tarazed", 297.042000, +10.613000, 0.53600, 0.38500}, // HIP 94779" {"Triangulum Galaxy (M33)", 23.462083, 30.659722, 0.0, 0.0}, //" {"Vega", 279.234734, +38.783688, 0.20094, 0.28623}, // HIP 91262" {"Whirlpool Galaxy (M51)", 202.479167, 47.195278, 0.0, 0.0}, //" {"Zubenelgenubi", 229.251667, -16.202500, -0.01000, -0.00500}, // HIP 72622" {"Zubeneschamali", 233.671667, -9.382500, -0.01200, -0.00600}, // HIP 73473" }; // Convert Alt/Az to RA/Dec // Inputs: Alt, Az, latitude, LST (all in radians) // Outputs: RA, Dec (RA in radians, Dec in radians) void altaz_to_equatorial(double Alt, double Az, double lat, double LST, double *RA, double *Dec) { // Declination *Dec = asin( sin(Alt) * sin(lat) + cos(Alt) * cos(lat) * cos(Az) ); // Hour angle components double sinH = -cos(Alt) * sin(Az) / cos(*Dec); double cosH = (sin(Alt) - sin(lat) * sin(*Dec)) / (cos(lat) * cos(*Dec)); double H = atan2(sinH, cosH); // Hour angle, radians // Right Ascension *RA = LST - H; // Normalize RA to [0, 2π) while (*RA < 0) *RA += 2.0 * M_PI; while (*RA >= 2.0 * M_PI) *RA -= 2.0 * M_PI; } Edited 2025-12-15 18:39 by matherp |
||||||
Below is the Algorithm that I use to calculate sunset and sunrise in various gadgets for biologists. I coded this is mmbasic and it works quite well. I can send my mmbasic code if desired- just a straight crib. This reference is more explanatory for those interested. I found it to be very accurate for use anywhere in the continental US, never tested in southern hemisphere, etc. Only problem is that its full of magic numbers- lots of constants that I never quite understood. I like that I can choose the zenith for civil nautical astronomical, etc. Might be useful. I have some interest in doing similar for moon phases. Thanks for all your work Peter. I hope that these functions might eventually migrate into the DOS/PC version as well. Regards, john ... Source: Almanac for Computers, 1990 published by Nautical Almanac Office United States Naval Observatory Washington, DC 20392 Inputs: day, month, year: date of sunrise/sunset latitude, longitude: location for sunrise/sunset zenith: Sun's zenith for sunrise/sunset offical = 90 degrees 50' civil = 96 degrees nautical = 102 degrees astronomical = 108 degrees NOTE: longitude is positive for East and negative for West NOTE: the algorithm assumes the use of a calculator with the trig functions in "degree" (rather than "radian") mode. Most programming languages assume radian arguments, requiring back and forth convertions. The factor is 180/pi. So, for instance, the equation RA = atan(0.91764 * tan(L)) would be coded as RA = (180/pi)*atan(0.91764 * tan((pi/180)*L)) to give a degree answer with a degree input for L. 1. first calculate the day of the year N1 = floor(275 * month / 9) N2 = floor((month + 9) / 12) N3 = (1 + floor((year - 4 * floor(year / 4) + 2) / 3)) N = N1 - (N2 * N3) + day - 30 2. convert the longitude to hour value and calculate an approximate time lngHour = longitude / 15 if rising time is desired: t = N + ((6 - lngHour) / 24) if setting time is desired: t = N + ((18 - lngHour) / 24) 3. calculate the Sun's mean anomaly M = (0.9856 * t) - 3.289 4. calculate the Sun's true longitude L = M + (1.916 * sin(M)) + (0.020 * sin(2 * M)) + 282.634 NOTE: L potentially needs to be adjusted into the range [0,360) by adding/subtracting 360 5a. calculate the Sun's right ascension RA = atan(0.91764 * tan(L)) NOTE: RA potentially needs to be adjusted into the range [0,360) by adding/subtracting 360 5b. right ascension value needs to be in the same quadrant as L Lquadrant = (floor( L/90)) * 90 RAquadrant = (floor(RA/90)) * 90 RA = RA + (Lquadrant - RAquadrant) 5c. right ascension value needs to be converted into hours RA = RA / 15 6. calculate the Sun's declination sinDec = 0.39782 * sin(L) cosDec = cos(asin(sinDec)) 7a. calculate the Sun's local hour angle cosH = (cos(zenith) - (sinDec * sin(latitude))) / (cosDec * cos(latitude)) if (cosH > 1) the sun never rises on this location (on the specified date) if (cosH < -1) the sun never sets on this location (on the specified date) 7b. finish calculating H and convert into hours if if rising time is desired: H = 360 - acos(cosH) if setting time is desired: H = acos(cosH) H = H / 15 8. calculate local mean time of rising/setting T = H + RA - (0.06571 * t) - 6.622 9. adjust back to UTC UT = T - lngHour NOTE: UT potentially needs to be adjusted into the range [0,24) by adding/subtracting 24 10. convert UT value to local time zone of latitude/longitude localT = UT + localOffset |
||||||
| The Back Shed's forum code is written, and hosted, in Australia. |