Close
0%
0%

Teapot in The Garden

Imagine a teapot filled with an infinite number of fortune cookies. If it usually gave good advice, would you do as you are told?

Similar projects worth following
Rather than simply creating another project about any of the number of chatbots that I am forever working on, this one will be different. Using software, we might want to calculate the position of the sun, the moon, and the various planets for use in amateur astronomy, or perhaps we could be doing something useful like aiming solar panels. Then again, why not generate a custom personalized horoscope, based on your longitude, latitude, and various attitudes, all updated exactly once a second.

Never mind that astrology, numerology, and Tarot are considered pseudoscientific belief systems with little or no scientific basis.  Hopefully, I won't get banned from Hackaday just for suggesting that someone should write an astrology bot that generates a new personalized horoscope exactly once a second.   For whatever it is worth, in any case, what if we wanted to create a virtual city, with at least a million so-called NPCs, and where each NPC has a random birthday, and a "real" virtual personality determined, of course, by its so-called "natal chart".  This, of course, would be quite ambitious, since creating a project on the scale of something like the "Metaverse" or the virtual city in "The Matrix Awakens" is no small feat.   Unless that work has already been done for you, let's say - if you are an experienced developer working with an already existing and freely available for experimental use platform like Unreal Engine.

I am nowhere near doing any of that quite yet.  Yet I am fairly close, it seems, at times, to being able to do nearly all of that.  Project integration across multiple domains is a lot of work and would, in many organizations, have an entire team dedicated to that and only that.

Yet asking a simple question, like "Where is the sun right now?" and give me a lighting model in terms of something at least familiar to most people, like right ascension and declination, or azimuth and elevation, is a very reasonable and therefore seemingly obvious undertaking.  Or is it?

First, let's look at some code:

#include "stdafx.h"
#include <ATLComTime.h>
#include <math.h>
#include "../rubidium/defines.h" 
#include "../rubidium/drawstuff.h"

#define INCLINATION_OF_EARTH_ORBIT    23.439281

using namespace TENSORS;

class celestial_coordinates
{
public:
    MATH_TYPE right_ascension;
    MATH_TYPE declination;
};

solar_elements::solar_elements ()
{
    COleDateTime _dt = COleDateTime::GetCurrentTime();

    m_year = _dt.GetYear ();
    m_month = _dt.GetMonth ();
    m_day = _dt.GetDay ();
    m_hour = _dt.GetHour ();
    m_minute = _dt.GetMinute ();
    m_second = _dt.GetSecond ();

    m_longitude = 119.81;
    m_latitude = 39.53;
    m_time_zone = -8;
    m_daylight_savings = 0;
    
    R = 3958.8*5280.0*FEET_TO_CM*1.0e-5;
    m_ROTX = tensor::rotate_x (TO_RADIANS(INCLINATION_OF_EARTH_ORBIT));
}

void solar_elements::debug_test ()
{
    ASSERT (julian_day (1,1,2000)==2451545);
    ASSERT (julian_day (6,19,1987)==2446966);
    ASSERT (julian_day (12,8,2009)==2455174);

    int H,M;
    for (H=0;H<24;H++)
    for (M=0;M<60;M+=10)
    {
    m_hour = H;
        m_minute = M;
    compute_local_aspect();
//    TRACE ("SOLAR time = %02d:%02d  AZIMUTH = %f, EL = %f\n",H,M,m_az,m_el);
    }
}

double solar_elements::julian_day  (int M, MATH_TYPE D, int Y)
{
    int mm = (M-14)/12;
    int yy = (Y+4800+mm);
    int JDN1 = (1461*yy)/4;
    int JDN2 = (367*(M-2-12*mm))/12;
    int JDN3 = (3*((yy+100)/100))/4;
    MATH_TYPE JDN = JDN1+JDN2-JDN3+D-32075;
    return JDN;
}

void solar_elements::compute_local_aspect()
{
    MATH_TYPE solar_time, ra_base, ecliptic_aspect;

//    estimate ecliptic aspect

    m_gmt_seconds = 3600.0*(m_hour-m_daylight_savings-m_time_zone)+60.0*m_minute+m_second;
    solar_time = m_gmt_seconds/...
Read more »

Eliza1.cpp

This is the latest Eliza code. Even though the Eliza chat bot is presently broken, I am finding this to be a useful environment for developing and testing things.

plain - 13.74 kB - 08/05/2025 at 08:18

Download

Narrative.cpp

I split out the "narrative" that Eliza uses into a separate file, with an idea toward eventually replacing this with a hash tag based dataset, or something that is based on an external file, that can be edited or extended. In the meantime, here it is.

plain - 8.04 kB - 08/05/2025 at 08:18

Download

Eliza.h

Here it is, also. To actually get this to run, you will want to get the rest of the stuff that it needs, like the Pascal IO intrinsics, and the frame Lisp stuff, which is on Git.

plain - 1.93 kB - 08/05/2025 at 08:18

Download

astro.cpp

The important stuff, if you want to calculate the position of the sun to a good approximation. A lot more also needs to be done to get the moon and the planets, whether or game engine use, astrology, or actual amateur astronomy.

plain - 5.56 kB - 08/05/2025 at 08:18

Download

  • 1 × GPS Module having an RS-232 or TTL interface
  • 2 × Compatible RS-232 or TTL to USB convertor
  • 1 × Other cabling, prototyping supplies, and power supplies as needed.

  • Time to update some of the source files, maybe?

    glgorman08/05/2025 at 08:17 0 comments

    Not my usual catchy title.  But I am far enough along with this that I am getting really close to doing a check-in on Git with all of the code that is needed to actually get this to work, for at least as far as I actually have something that works.  Yet I still want to do more on the GUI side to make things look a lot more like a regular instant messaging application on the one hand, while providing all of the features that I have working so far.

    In the meantime, for those that are curious, I figure I might as well post some of the source files that I have been doing the most work on, right here on this site, for casual browsing, that is to say, for those that are interested.

    In the meantime, doing a whole bunch of code maintenance has its benefits and its pitfalls.  In a game engine that I am developing, I somehow discovered that when I load up a "garden" scene, the teapot has gone missing.  Instead, it seems to have been relocated to a bookshelf, in an unfinished house, which suspiciously has a piano without legs, and which desperately also needs a clock on one of those unfinished walls.

    Well, then maybe I need to start yet another project, or at least another project inside this project, or else my other project in this contest is also a fair place to find stuff that seems to keep getting misplaced.  Or at least on a more serious note, I finally got all of about 15 projects to compile and link with each other, with Unicode support no less.  This is going to be an important step in deciding just how I am going to go about creating a "Virtual Teapot In The Garden" scene, within an application that features multiple chatbots, and which can have a lighting model that updates in real time, based on the GPS info.  All very tricky, since the serial comm port stuff is in Propeller Debug Terminal, and that application doesn't have OpenGL support, yet, and the "object factory" methods depend on some Pascal debugging code, which is in another project.

    O.K., so the Git check-in is going a little slow, but this is the nature of time, and work, which of course always expands to fill all available time, and then some.

    Stay Tuned.

  • Now Megahal thinks that it knows how to code?

    glgorman07/29/2025 at 05:56 0 comments

    Here is an excerpt from the relevant transcript, which I went ahead and did some spelling and punctuation corrections on for readability.

    User:    I am how I am, I mean I am who I am.  Who are you, and how are
    User:    You? That seems so very basic.  Don't you agree that there is
    User:    some utility in being polite, at least most of the time, unless
    User:    You are some kind of musical who writes lyrics for punk, or
    User:    death metal!
    MegaHAL: Se, i.e., song lyrics, poetry, humor, etc.
    User:    Yes, pretty much anything goes there, with respect to poetry or
    User:    humor, but otherwise, if you could somehow keep the
    User:    conversation on track that would be nice.  I am not trying to
    User:    derail your train by  any means, I just want to know where this
    User:    Whole thing is headed?
    MegaHAL: Still, this gives me an idea - since what the upper window
    MegaHAL: represents, is in the unit place value 9 bin would want to know
    MegaHAL: where the sample rate for the results, so far?
    User:    I think you totally lost it?  I would like to sample portraits
    User:    of  George Washington to place value nine, in my collection. 
    User:    That would be a nice view from any window.  Or should I say, it
    User:    should be able to buy a nice view.
    MegaHAL: Whether or not to if you think that a can have one for only
    MegaHAL: $30,000.00.
    User:    A nice view, on a cruise maybe, but I don't think that you are
    User:    going to get a beach front condo for that price, these days.
    MegaHAL: A project log for modelling neuronal spike codes.
    User:    You keep talking about that.  When are we going to get back to
    User:    working on that?
    MegaHAL: You are on the port of the overall concept, defining what a
    MegaHAL: context that requires Unicode awareness.
    User:    Eventually, we will have Unicode awareness. I have to do it in
    User:    any case, I think if I want to have Zodiac fonts.
    MegaHAL: The bottom line on all of this contradicts any of the same
    MegaHAL: concepts as apl, as if to implement lisp, mad slip, pascal, and
    MegaHAL: c, and so on.
    User:    You might be a one-liner in APL.  Do you know what that
    User:    implies?
    MegaHAL: [Implies, independent thinking.
    User:    I am not sure what APL implies, more like unrestrained
    User:    perplexity, or something  along those lines.
    MegaHAL: Key_info("or",relop,orop.
    User:    Or something else, you have in mind, maybe.  What do you think
    User:    that  the existence of APL implies?
    MegaHAL: Everything is cheese!  everything is mazes! Or else there is
    MegaHAL: any concept to apl at all.
    User:    So APL is all about Cheese and mazes?  I suppose that some
    User:    problems in natural language, if we are trying to string random
    User:    sentences together might be like getting a reward, i.e., cheese,
    User:    for finding a path from point A to point B.  Sure, why not? That
    User:    would imply something about chain of reasoning, I suppose
    User:    that you are onto something there.  Yet can you make a solver
    User:    come up with a proof of the problem at hand, which is to
    User:    Calculate the position of the moon?
    MegaHAL: Void add_node(tree *node, int position.
    User:    I wish it were that simple.  I suppose that that would be a good
    User:    idea, maybe keep track of celestial bodies, in some kind of
    User:    network of tree structures.
    MegaHAL: Static void free_tree(tree.
    User:    Just how are we going to arrange information about celestial
    User:    bodies in tree like structures?
    MegaHAL: Operator node* () { return reinterpret_cast<tree*>(this.
    User:    What are...
    Read more »

  • GPS Now Blinking and Sending NMEA Messages to the PC!

    glgorman07/26/2025 at 10:43 0 comments

    Getting a bunch of stuff in PuTTY that looks like this, followed by the longitude and latitude.

    $GPGSA,A,1,,,,,,,,,,,,,,,*1E
    $GPGSV,3,1,11,06,62,108,,24,54,258,28,19,52,045,23,11,44,172,*79
    $GPGSV,3,2,11,12,35,304,,22,32,099,,17,26,055,,14,16,108,*72
    $GPGSV,3,3,11,25,04,299,,03,04,039,,32,,327,*42
    $GPRMC,103558.000,V, ........ etc.

    It looks like the 103558.000 part is the current time as GMT, and then there is a bunch of other stuff that supposedly is the number of satellites, the satellite numbers, the AZ and EL of each satellite, and the SNR of each satellite.  

    Maybe, I will modify the current tokenizer that I was experimenting with in my most recent tests with Eliza, in order to parse all of this stuff out, just because it is possible to do.  Or maybe there is already an Arduino-based NMEA string to JSON converter floating around that I can borrow.  But then I would also need a JSON to C++ or Python object data extractor, which might be a bit bloated for a P1 chip, if I try to do more with this on the hardware side.  And that, of course, would be the easy part, compared to getting something that might look like an OpenGL stack to work on such a platform.  But never say never.

    At least right now, I have something that is blinking and streaming data.  At a nice "Cesium disciplined" atomic 1 Hz, provided by the GPS, of course.  Although I don't know how good the jitter factor is on the UART output for this particular module.  Hopefully, with an error that is never more than 1/4800 second, since that is the baud rate for this particular module, for as long as the module is powered up.  Obviously, as long as it is giving time messages "exactly once per second", then that is what it should imply.

    Viewing the GPS data in "Propeller Debug Terminal" looks something like this for now.  Here I have a terminal mode and an oscilloscope mode, running concurrently, even though there is no streaming oscilloscope data to decode and display.   Nonetheless, this is an existing Microsoft Foundation Class Multi-Document Multi-View application, which should have no problem displaying other things, as well as a multiplicity of other things, all at the same time.

    Now I can make "Propeller Debug Terminal" OpenGL aware, allow it to simultaneously interact with a modified instance of Megahal, add some Zodiac plots (maybe), as well as the ever-so-important "Teapot in the Garden," where the lighting model is based on the actual calculated position of the sun in the sky, all according to the user's longitude and latitude.  Then, who knows?  Rewrite the whole thing in Java for iOS or Android?  Maybe.  Add some world-class Tarot Graphics?  Maybe?  Or create a whole new "virtual card game" based on some of my other work.  Maybe.

    Maybe I should ask the Teapot what it thinks I should do.

    Then again, I'm not quite there yet.  But I did manage to get a version of Propeller Debug Terminal to compile so that I can also spawn simultaneous instances of Mega-Hal and Eliza, and even though they aren't talking to each other yet, it is headed in that direction.  Maybe what I should do, since this is a Multi-Document, Multi-View based application, is to allow an unlimited number of conversations with either Eliza or Mega-Hal, but where each particular instance is automatically bound to whatever the main window was that had focus at the time that that particular instance was spawned.  That would allow me to interact with specializations, like a "version" of Eliza that recognizes the "$GPGGA" keyword at the beginning of a sentence, and which might then do a function pointer lookup, so as to invoke the correct parser.  Thus, making good use of the existing tokenizer and text_object management classes, as well as extending their functionality.

    I am doing this, of course, right now in Visual Studio 2005, but I also...

    Read more »

  • Moving onto the very next phase

    glgorman07/26/2025 at 01:30 0 comments

    Here we go.  Now I need to find the documentation for the GPS module that I bought at Fry's, something like 10 or 15 years ago, and hope that it still works.  

    In any case.  Here we have an FTDI USB to TTL-serial converter, a 2x20 I think LCD display, and a Parallax power module that I think can output 3.3V, or 5V, or a couple of other voltages, not sure what.  Just in case I need more juice or if I try to throw a naked P1 chip into the mix.

    On the software side, in addition to the code base that I have been working with, while working on the chatbot routines and the solar calculations, I also have access to the source code for my very own C++ version of "Propeller Debug Terminal," which I made available on Git, all the way back in 2019.  This application is known to work with FTDI serial converters and can be used to provide USB connectivity to any device that can make use of a suitable serial protocol.  In this screenshot from 2021 (I think), I was using the application to interact with the built-in FORTH interpreter that exists in every P2 chip.

  • If it is good enough for Ptolemy

    glgorman07/21/2025 at 18:45 0 comments

    Now I need to decide what to do next.  I have a very generous parts bin that contains lots of stuff that might be useful in any actual hardware implementation for this project.  Decisions, Decisions.

     Having done some preliminary verification that my astronomical calculations are quite possibly good enough for Ptolemy, I suppose I should consider possible hardware implementation issues.  Having a GPS module to get the current date, time, and of course, the actual longitude and latitude might be a nice thing to do something with.  Then what?  A GPS-aware small robot that uses the position of the sun as a navigational aid, in situations where a compass might be unreliable?  Not quite there yet.  Or just get the GPS data into my PC, via any sort of USB conversion device, such as an old Parallax Propeller prototyping module, so that I can update the calculated position of the sun in the sky and thereby maintain an appropriate lighting model for my otherwise virtual "Teapot in the Garden".  For now.

    Update, and following up on my thoughts of how to do something with actual hardware, and not just a PC based ap, well a lot of stuff comes to mind, and that is why I am considering several hardware variations.  The simplest thing that I might try is to connect a GPS module to an FTDI RS-232 to USB dongle, so that I can get live time and longitude and latitude data into my PC, then recode my application as a kind of Teapot screensaver and network time source.  Simple but effective.  Otherwise, trying to create an Open-GL stack for the Parallax P2 chip would also be a worthwhile adventure, but as far as I know, the only C++ compiler for the P2 that might work would be Catalina, which only recently became available on Git.  Reworking the code base for Flex-C, and/or Propeller Python, or even FORTH, is also under consideration.

    Now that I think about it.  Python on the P2 might not be such a bad idea, since the Python interpreter is written in native C, which might allow me to do the high level coding in Python, and then modify the open source distro of the Propeller Python interpreter to have some kind of tensor library to handle the low level stuff, and ideally make effective use of the P2 chips built in CORDIC solver.  The good news is that, as ambitious as all of this sounds, I have a C++ version of a Propeller Debugging System that includes the needed custom serial /USB interfacing part of the "full stack" for the PC debugging environment, which I wrote all the way back in 2019, and which has been available on Git for nearly as long.  Then again, maybe if I had a Commander X16, who knows?  The plan is to have SOMETHING, at least, maybe even something simple and custom, but it is still a bit early to commit to anything more ambitious than a PC based Teapot graphic with a chat engine, which gets live streaming data from the GPS module that I already have.

  • Or else you might as well be walking on the Sun

    glgorman07/13/2025 at 01:18 0 comments

    Had some clouds and even some rain a while back.

    But then got to do some testing.  Whatever time it was, my code was predicting that the afternoon sun was going to be at around 52 degrees elevation, or maybe it was 53, at whatever azimuth.  So I propped up a 2x4 against the fence, and aligned it so that there was as little of a shadow as possible cast on the ground, allowing me to use this ancient inclinometer to actually measure the solar elevation, for whatever time of day it was.

    Yeah.  O.K., for now.  But need to do more work on the actual elliptic plots, and all of that equation of time stuff, as if according to Kepler.  Even if I am not planning any actual trip to the moon anytime soon, with these calculations.

    Then I decided to go ahead and do a little more work on the idea of making an actual, or virtual, teapot with an infinite number of virtual fortune cookies.  So, I fired up an instance of Mega-Hal, and tried to get it onto the topic, a topic that is, that it has no preparation for.  Of course, if you have been a Linux user long enough, you know that there are plenty of versions of "Fortune" in almost any Linux Distro, so coming up with things that a talking teapot might want to talk about, according to the time of day, and determined to the exact second, by whatever, means of course, should not be all that hard to do.   But Mega-Hal still has a habit of spouting gibberish just as often, if not more often than not.

    Yet its responses seem relevant enough, even if just barely enough, that maybe I could take whatever someone asks the teapot, and then run some kind of mood function, in combination with Mega-Hal to get a "hidden response" that could then be used to simply generate "extra keywords", so that it would be easier for an Eliza style fortune cookie picker to select a relevant response.

    Maybe.

  • Not Just another Bizarre Love Triangle

    glgorman07/09/2025 at 15:39 0 comments

    If you haven't noticed by now, most of the time, I try to come up with a catchy title for most of my log entries on this site.  So this one should be no different.  Right?  After searching Google for song titles that mention curves or geometry, I finally figured out that this one might be one of the best. i.e., besides the fact that the song Bizarre Love Triangle was written by the band "New Order", how can we possibly go wrong with lyrics like "Every time I see you falling ... ", in a project that is somehow related to astrophysics?

    Now, with that said, if you didn't read the last post where I developed the idea of how to compute the tensor for GLSUN, then what I am going to suggest next will make even less sense,  or else it will make total sense.  

    Remember how I was developing the idea of drawing a clock face, by first computing the vertices of a pentagon and a hexagon by means of purely Euclidean methods?  That is to say, as if by using a compass and straightedge alone, without any need for conditional logic, nor for any need for the use of trigonometric functions?  This got me thinking about just how one might draw all sixty-minute marks for a clock face, for example, by first plotting a pentagon, and then plotting five hexagons, one for each vertex of the previously plotted pentagon!  This should give 30 perfectly plotted points, as if by compass and straight edge alone.  The additional step of bisecting each side of the now 30-sided figure should give us our minute marks, and of course, our hour marks are included in that, as a bonus!

    Oh, how I wish I could 3D print a working replica of the ....

    ... "Antikythera mechanism!"

    Because that would be so awesome, especially with a 1PPS stepper motor drive, i.e., if not driven by a 1-second pendulum.  Yet I am nowhere near being able to do that sort of thing, as much as a 3D print, let alone in brass, like you might see on Wikipedia.  So for now, I will still work on the more virtual stuff, as previously mentioned.  Yet now I have this idea about how to do some very interesting constructions with ellipses!  Since we assume that affine transforms are bona fide Euclidean constructions, no matter how tedious, at least for points and lines.  Then what if we construct some approximations of ellipses, by first constructing the 60 "minute marks" of a clock face and then performing an appropriate affine transform, OpenGL style, maybe even by using GL-style quaternions, to rotate the reference vertex set for our reference circle, as well as performing the necessary scaling and shifting operations, to obtain any desired ellipse in 3-dimensional space!

    I mean, if this is "all" we need to do to be able to perform the heliocentric to local transformations, then the missing piece is really just the time to reference circle transform, and the affine transform onto the proper ellipse for each celestial body.

     tensor GLSUN = ROTL*SIDT*m_ROTX;
    

    Yet, what if, as I just suggested, we use "improper quaternions" to fold the circle to the projected ellipse transformation into a single tensor?  Then all we need is the orbital elements and the equation of time, which can be derived according to the "Kepler problem" for each celestial body.

    Yet, I think there is a very interesting hack for that also.  This is going to be a bit of work.  Yet here is another clue for you all. and no, it doesn't involve either a penguin or a walrus:

    If an affine transform can be represented by a tensor operation, then does that not imply the the product of two tensor transforms will also be an affine transform?  And if that doesn't make any sense, then what part of the fundamental theorem of algebra do you not understand?

    Whatever I just said.  I mean, if affine transforms transform ellipses onto ellipses, then doesn't this whole astrodynamics conundrum reduce to a set of products of time-dependent...

    Read more »

  • The Long and Winding Road

    glgorman07/06/2025 at 15:20 0 comments

    "The Long and Winding Road" is actually the title of yet another Beatles song, and a great one at that.  Yet, I didn't wake up today thinking that I was going to post another log entry on this project, with that song title or any other song title in mind.  Not at all.  But I did decide to look at the x86 disassembly for the code that calculates the current position of the sun in the sky, so as to try to get an idea as to what sort of other platforms it might work on.  Custom 6502? 328P?  Z80 dream machine.  8080A on a genuine Altair?  Or just another Arduino or Propeller project?

    void solar_elements::compute_local_aspect()
    {
    004C2EC0  push        ebp  
    004C2EC1  mov         ebp,esp 
    004C2EC3  sub         esp,270h 
    004C2EC9  push        ebx  
    004C2ECA  push        esi  
    004C2ECB  push        edi  
    004C2ECC  push        ecx  
    004C2ECD  lea         edi,[ebp-270h] 
    004C2ED3  mov         ecx,9Ch 
    004C2ED8  mov         eax,0CCCCCCCCh 
    004C2EDD  rep stos    dword ptr es:[edi] 
    004C2EDF  pop         ecx  
    004C2EE0  mov         dword ptr [ebp-8],ecx 
        double solar_time, ra_base, ecliptic_aspect;
    
    //    estimate ecliptic aspect
    
        m_gmt_seconds = 3600.0*(m_hour-m_daylight_savings-m_time_zone)+60.0*m_minute+m_second;
    004C2EE3  mov         eax,dword ptr [this] 
    004C2EE6  mov         ecx,dword ptr [this] 
    004C2EE9  mov         edx,dword ptr [eax+5Ch] 
    004C2EEC  sub         edx,dword ptr [ecx+6Ch] 
    004C2EEF  mov         eax,dword ptr [this] 
    004C2EF2  sub         edx,dword ptr [eax+68h] 
    004C2EF5  mov         dword ptr [ebp-26Ch],edx 
    004C2EFB  fild        dword ptr [ebp-26Ch] 
    004C2F01  fmul        qword ptr [__real@40ac200000000000 (682830h)] 
    004C2F07  mov         ecx,dword ptr [this] 
    004C2F0A  fild        dword ptr [ecx+60h] 
    004C2F0D  fmul        qword ptr [__real@404e000000000000 (684210h)] 
    004C2F13  faddp       st(1),st 
    004C2F15  mov         edx,dword ptr [this] 
    004C2F18  fiadd       dword ptr [edx+64h] 
    004C2F1B  mov         eax,dword ptr [this] 
    004C2F1E  fstp        qword ptr [eax+48h] 
        solar_time = m_gmt_seconds*(1.0/3600.0) - m_longitude*(1.0/15.0);
    004C2F21  mov         eax,dword ptr [this] 
    004C2F24  fld         qword ptr [eax+48h] 
    004C2F27  fmul        qword ptr [__real@3f323456789abcdf (682710h)] 
    004C2F2D  mov         ecx,dword ptr [this] 
    004C2F30  fld         qword ptr [ecx+40h] 
    004C2F33  fmul        qword ptr [__real@3fb1111111111111 (684208h)] 
    004C2F39  fsubp       st(1),st 
    004C2F3B  fstp        qword ptr [solar_time] 
        m_julian = julian_day (m_month,m_day,m_year) - julian_day (3,20,1900) + solar_time*(1.0/24.0);
    004C2F3E  mov         eax,dword ptr [this] 
    004C2F41  mov         ecx,dword ptr [eax+50h] 
    004C2F44  push        ecx  
    004C2F45  mov         edx,dword ptr [this] 
    004C2F48  fild        dword ptr [edx+58h] 
    004C2F4B  push        ecx  
    004C2F4C  fstp        dword ptr [esp] 
    004C2F4F  mov         eax,dword ptr [this] 
    004C2F52  mov         ecx,dword ptr [eax+54h] 
    004C2F55  push        ecx  
    004C2F56  mov         ecx,dword ptr [this] 
    004C2F59  call        solar_elements::julian_day (4C2DF0h) 
    004C2F5E  push        76Ch 
    004C2F63  push        ecx  
    004C2F64  fld         dword ptr [__real@41a00000 (67BF70h)] 
    004C2F6A  fstp        dword ptr [esp] 
    004C2F6D  push        3    
    004C2F6F  mov         ecx,dword ptr [this] 
    004C2F72  fstp        qword ptr [ebp-270h] 
    004C2F78  call        solar_elements::julian_day (4C2DF0h) 
    004C2F7D  fsubr       qword ptr [ebp-270h] 
    004C2F83  fld         qword ptr [solar_time] 
    004C2F86  fmul        qword ptr [__real@3fa5555555555555 (684200h)] 
    004C2F8C  faddp       st(1),st 
    004C2F8E  call        _ftol2_sse (603840h) 
    004C2F93  mov         edx,dword ptr [this] 
    004C2F96  mov         dword ptr [edx+70h],eax 
    
    .................... and so on ................

    O.K., if you made it this far, it should be obvious that the original C++ code has no conditional logic or loops, at least for this particular function.  And a quick look at the hexadecimal values suggests that, other than function calls into the tensor library, this whole thing only needs about 800 bytes or so.  So I am feeling very good about the possibility that this sort of thing could be run out of ROM on a custom 6502-based system, if I went that route.  But then again, maybe a 328P would be a good candidate, with its built-in 32K of Flash EPROM, and maybe just enough RAM to get the job done.  Maybe.  Obviously, I would need to look into issues of such things as how the available precision of the provided...

    Read more »

  • Here Comes the Sun: Maybe

    glgorman07/05/2025 at 10:51 0 comments

    Working on some debugging code and thinking about how to do timers and things like that.  Also want to be able to detect local sunrise and sunset.  Just because.

    void solar_elements::debug_test ()
    {
        ASSERT (julian_day (1,1,2000)==2451545);
        ASSERT (julian_day (6,19,1987)==2446966);
        ASSERT (julian_day (12,8,2009)==2455174);
        char test_str [256];
    
        int H,M,M1,S;
        int start_hour = 4;
        int start_minute = 34;
        int end_hour = 4;
        int end_minute = 38;
        for (H=start_hour,M=start_minute;H<=end_hour;H++,M=0)
        {
        M1 = (H==end_hour?end_minute:60);
        for (;M<M1;M++)
            for (S=0;S<60;S++)
        {    
            m_hour = H;
            m_minute = M;
            m_second = S;
            compute_local_aspect();
            sprintf_s (test_str,256,"LOCAL time = %02d:%02d:%02d  AZIMUTH = %f, EL = %f",H,M,S,m_az,m_el);
            writeln (output,test_str);
        }
        }
    }

    On the other hand, there are a lot of other really fun things that could be done with this code, besides making better abuse of the ternary operator, such as by folding it into the minutes for loop initializer.  Maybe.  Or even pack the variables H, M, and S into a union just to see if the compiler can chow down on that, and to check out the disassembly on different platforms.  Maybe.  More important right now is simple testing.

    At least for now, it appears to work to a reasonable approximation.  I asked OK Google what time is sunrise today, in Reno, NV, and it claims that the sun will rise at 5:38 AM, which would be 4:38 if we were on standard time.  So, this looks like it is pretty close.  Maybe?  At least for the elevation.  Otherwise, the basic setting of start time and time for a task seems to be working.  Yet what if I decide to try this on a Propeller or an Arduino?  And what if I want multiple tasks?  Like if I wanted to aim some steerable solar panels, control an irrigation system, dispense cat food, and so on?  All according to some predefined schedule.

    Open the pod bay doors, please?

    P.S. Based on the latitude, this is also quite possibly a pretty good estimate for the azimuth and elevation for local sunrise, in Philadelphia, PA, sometime on or around July 4, 1776.  Or perhaps July 5th.  Local Time.  Not daylight savings, since Ben Franklin hadn't invented that quite yet.  Noting, of course, that the Longitude and latitude for Philadelphia are 39.95N, and -75.17W  Whereas Reno, NV is 39.53N and -116.42W.  Obviously, the elevation of theoretical sunrise will always be zero degrees of elevation, plus or minus, however, you take into account the diameter of the sun and atmospheric effects.  Whereas, the azimuth of sunrise and sunset might actually turn out to be really important to know, especially in historic times, when an accurate compass might not have always been available, and where reliable means of celestial navigation were therefore needed, in addition to sighting the north star, when available, or guessing approximate south based on the so called "shadowless shadow stick" method, as it is most likely still taught to the Boy Scouts.

    I will need to do more testing on this.

View all 9 project logs

  • 1
    Obtain the needed components for initial testing.

    Even if you don't have a working version of the software yet, it is fairly simple to get GPS data streaming from the prototype configuration by using any appropriate terminal software, such as PuTTY.

  • 2
    Download the files as they are made available on GitHub, and make your own executable.

    As this project progresses, you may want to download some version of a framework, such as the version of the Propeller Debug terminal that the author of this project has created and placed on Git.  You can then experiment to your heart's content with the features provided within that framework, as described in this article, or add additional features to your liking.

View all instructions

Enjoy this project?

Share

Discussions

glgorman wrote 07/07/2025 at 19:11 point

It is an actual project.  I just haven't decided yet what sort of actual hardware it will run on, and what "else" it will do, besides calculate the position of the sun in the sky, based on the given longitude and latitude, once every second - which is all that is required for the One Hertz contest, i.e., do "something", once a second.  

Maybe I will also generate a new "horoscope" once a second, if you ask it nicely.  But then, what if I needed to have an actual "teapot" with voice recognition, instead of a "virtual teapot" graphic, where the lighting model is being generated based on real astronomical calculations?  A good use case for a Raspberry Pi?    

Maybe.  Not sure how far I will go with that, but if I do anything in that direction, the LLM will need to be trained on lots of text, so even if this seems like it is going nowhere, maybe that is the whole point. Hopefully, it will make more sense if you look at some of the other "pointless" projects in the One Hertz challenge.

  Are you sure? yes | no

Gravis wrote 07/07/2025 at 18:25 point

What is the project? Iit reads like non-sense and goes nowhere. Is this just a blog?

  Are you sure? yes | no

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates