![]() |
Forum Index : Microcontroller and PC projects : GPS calculation / Electride / Fortran
![]() ![]() |
|||||
Author | Message | ||||
bigfix Senior Member ![]() Joined: 20/02/2014 Location: AustriaPosts: 129 |
TassyJim, thanks for the referral to the "The Basic Handbook 2nd edition" by David A. Lien I found an electronic version & other Vintage Basic books at a Sinclair Docs site ftp://worldofspectrum.org/pub/sinclair/books/ |
||||
TassyJim![]() Guru ![]() Joined: 07/08/2011 Location: AustraliaPosts: 6283 |
I recommend ABE books as a source of "old but goodies" text books. I went mad and purchased a copy of The Basic Handbook 3rd edition. Not a well laid out as the second edition but a useful reference. Arctan has always been a problem. Here is an ATN2 function and a test program to check that it works for all quadrants. There are interesting things happening at 90, 180 and 270 degrees. The DOS version of MMBasic gives slightly different results to the MicroMite version due to the indefinable value of TAN 90 degrees. Is it plus or minus infinity? I have also included a function called "compass" which takes an angle in +- PI radians and converts it to degrees from 0 to 360. The program has been tested on DOS and Micromite. I will be glad when the DOS and Maximite MMBasics have STR$ working the same as the Micromites. ' ATN2 function ' TassyJim Feb 2015 ' IF LEFT$(UCASE$(MM.DEVICE$),9)="MICROMITE" THEN strOK=1 PRINT " deg rad x1 y1 TAN ATN ATN2 compass" FOR n = 0 TO 360 STEP 5 a= RAD(n) x1 = COS(a) y1 = SIN(a) IF strOK=1 THEN PRINT STR$(n,3,1);","; STR$(a,1,4);","; STR$(x1,2,4);",";STR$(y1,2,4)","; PRINT STR$(TAN(a),4,4);","; STR$(ATN(TAN(a)),4,4);","; STR$(ATN2(y1,x1),4,4); PRINT ",";STR$(compass(ATN2(y1,x1)),3,1) ELSE PRINT FORMAT$(n,"% 6.1f");","; FORMAT$(a,"% 8.4f");","; FORMAT$(x1,"% 8.4f");",";FORMAT$(y1,"% 8.4f")","; PRINT FORMAT$(TAN(a),"% 9.4f");","; FORMAT$(ATN(TAN(a)),"% 9.4f");","; FORMAT$(ATN2(y1,x1),"% 9.4f"); PRINT ",";FORMAT$(compass(ATN2(y1,x1)),"% 6.1f") ENDIF NEXT n ' END FUNCTION atn2(y,x) IF ABS(x) < 0.0000001 THEN arctan = 0 x = 0 ELSE arctan = ATN(y/x) ENDIF IF x > 0 THEN atn2 = arctan ELSEIF y>=0 AND x<0 THEN atn2 = PI + arctan ELSEIF y< 0 AND x<0 THEN atn2 = arctan - PI ELSEIF y> 0 AND x=0 THEN atn2 = PI / 2 ELSE ' y< 0 and x=0 atn2 = PI / -2 ENDIF END FUNCTION FUNCTION compass(x) compass = DEG(x) IF compass < 0 THEN compass = compass+360 END FUNCTION Jim VK7JH MMedit |
||||
isochronic Guru ![]() Joined: 21/01/2012 Location: AustraliaPosts: 689 |
It depends, what sort of heliostat ? For a bit of warmth and sunlight this might be the go - http://www.instructables.com/community/heliostat-and-sun-tra cker-basic-program/ but for precise work you need corrections for atmospheric refraction , accurate time, etc. Incidentally for distances I would use the fortran geodesic demo on cdeagles pages. Vincenty and other methods use converging-approximation. Using electride and double precision the results agree ( to two micrometers !! ) but the vincentys program I saw has a test and subsequent error message about convergence failure .. ![]() |
||||
cdeagle Senior Member ![]() Joined: 22/06/2014 Location: United StatesPosts: 265 |
The zipped file I posted on this thread (February 6) is an MMBasic implementation of the Fortran routine that chronic mentions. |
||||
redrok![]() Senior Member ![]() Joined: 15/09/2014 Location: United StatesPosts: 209 |
Hi chronic; Yes, I know Dave Williams, at least when I frequented the newsgroups. This works ok at low precision. I'm not sure but I don't think he does the bisector correctly. A better example is that by Keith Burnett. And I added refraction to Keith's code. Now for real accuracy one should use good astronomical codes for solar position. I've been using those by Stephen L. Moshier. This is accurate to a few arc seconds for centuries. But for geometry, the spherical codes are the thing to do. I really like the "movable-type" reference for this. And yes, I really am interested in high precision heliostats, accurate to at least 1/20 degree. It turns out the mechanics is the easy part. It's the software that's hard. Especially when trying to fit the accurate "Equation of Time" code into a nice computer like the uMiteII. This pretty much requires double precision floating point trig functions. Actually the uMiteII is well suited to drive the mechanics. The single precision floating point trig functions are plenty accurate for this. redrok |
||||
isochronic Guru ![]() Joined: 21/01/2012 Location: AustraliaPosts: 689 |
(maybe move this to the solar energy section ) That's a lot of heliostats ! ( on the redrock site ) So,, is there a public-domain heliostat program that works well for concentrators ?It is probably less needed since photovoltaics dropped in price I guess |
||||
isochronic Guru ![]() Joined: 21/01/2012 Location: AustraliaPosts: 689 |
Now the eyesight is improving well I have updated Electride (description) somewhat to version 2. It is experimental but passes simple testing (and all the examples work), let me know if interested 2015-08-07_024345_bld3adoc.zip Snow in the outback ?? What next ?! |
||||
domwild Guru ![]() Joined: 16/12/2005 Location: AustraliaPosts: 873 |
When I "acted" as a consultant for Alcoa I managed to get the Fortran program from the WA Mines Dep. and I faintly remember having to input also ZONE. Perhaps that was the trick to account for the oblate spheroid. Was it AMG grid references rather than lat/long? Too long ago! Taxation as a means of achieving prosperity is like a man standing inside a bucket trying to lift himself up. Winston Churchill |
||||
isochronic Guru ![]() Joined: 21/01/2012 Location: AustraliaPosts: 689 |
I think the different area of the globe use different models and fudge factors which may be the zone reference (?) BTW I see mobile phones are now including GLONASS, is that the euro GPS ? So ...what happens if GLONASS and GPS disagree ?? (Will Evil Barbie and Siri scrag ?!!! ) |
||||
Chris Roper Senior Member ![]() Joined: 19/05/2015 Location: South AfricaPosts: 280 |
Globalnaya Navigazionnaya Sputnikovaya Sistema From that I think you can guess it is Russian. The European one is Galileo and will begin service in 2016 I think. Cheers Chris http://caroper.blogspot.com/ |
||||
isochronic Guru ![]() Joined: 21/01/2012 Location: AustraliaPosts: 689 |
Arrgh ! Siri : turn right.. Evil Barbie : Actually you should keep going .. Glonass : Nyetski !!! Turn Left comrade !! GPS : Where do you want to go today ? Galileo : Stop being so terribly terribly childish. And send drachmas dammit .. sob ... ! |
||||
isochronic Guru ![]() Joined: 21/01/2012 Location: AustraliaPosts: 689 |
Its good to see the sunshine again !! My interest in gps was originally triggered by the thought of a mobile solar collector, that would be portable or at least trailerable, which would be largely automated and thereby be a useful source of hot water or power without requiring extensive human intervention to start and run. Hence the idea of using gps info. Some years later.. So, to test Electride vers 2 a bit further with something purposeful, I thought I would try some solar position code and compare it to reality. There are a number of existing programs around, I have used some that was based on Michalski's method and tweaked the refraction correction by using the NOAA spreadsheet javascript as an assist. The results are quite good, (apart from some embarrassing bugs (mine) that need workarounds until I fix them properly). Using a published location (guess where !! :) ) I have run it to predict solar positions for December 1, 2015. So I will sink or swim... My confidence is boosted by comparing it to the NOAA predictions below, there is usually agreement to within 0.01 of a degree apart from noon where the azimuth is 0.02 degrees off - hopefully not so important at the elevation. Now to fix those embarrassments .. After that, it would be good to write it up properly and get help testing it with some real tests in some different locations - anybody ?? Latitude and longitude ? -31.5,151.0 Day, month, year ? 1,12,2015 What is the time zone offset ? 10.0 Day of year is 335 Hr El Az 1.0 -33.8523 158.7965 2.0 -27.7178 144.2080 3.0 -19.1659 132.1936 4.0 -8.9594 122.3798 5.0 2.5379 114.1601 6.0 14.3061 106.9515 7.0 26.7012 100.2136 8.0 39.3799 93.3362 9.0 52.1510 85.3228 10.0 64.7196 73.6578 11.0 76.0331 48.2817 12.0 79.6541 339.8968 13.0 70.6044 295.6404 14.0 58.4000 279.6097 15.0 45.6787 270.3106 16.0 32.9352 263.0431 17.0 20.3844 256.3204 18.0 8.2372 249.4054 19.0 -3.4129 241.7459 20.0 -14.2411 232.7881 21.0 -23.6652 221.9274 22.0 -31.0708 208.6292 23.0 -35.6184 192.8551 24.0 -36.5662 175.6464 Finish [NOAA] 1.0 -33.85490726 158.7992583 2.0 -27.72088766 144.2098802 3.0 -19.1692475 132.1947499 4.0 -8.96293936 122.3803809 5.0 2.534538286 114.1603091 6.0 14.30254649 106.9514729 7.0 26.69759425 100.2134148 8.0 39.37634931 93.33582068 9.0 52.14739528 85.32227727 10.0 64.71595081 73.65778102 11.0 76.02961127 48.28651229 12.0 79.65345181 339.9169479 13.0 70.60612865 295.6502146 14.0 58.4022171 279.6154067 15.0 45.68100213 270.314752 16.0 32.9375546 263.046596 17.0 20.38657276 256.3236183 18.0 8.239184913 249.4086276 19.0 -3.411166545 241.7493252 20.0 -14.23983879 232.7918372 21.0 -23.66443581 221.9314953 22.0 -31.07090207 208.6337047 23.0 -35.61935875 192.859699 24.0 -36.5681754 175.6505146 |
||||
![]() ![]() |
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |