An Observation

I have a Propeller Controller running a system and displaying system data on the computer screen via the USB standard Parallax interface to the controller. The system has operated perfectly for months then the propeller stopped.

I had all the Internet programs and automatic programs removed from the controlling laptop computer so that it was just a basic control computer. However, I noticed the computer clock changed from Day-light time to Standard time and I noticed the propeller interface hung up.

Has this observation been reported before?

Also, how can I stop the computer from automatically changing the clock time?

Discovery

Comments

  • 9 Comments sorted by Date Added Votes
  • Was the computer sending the time to the Propeller? If so, you have a bug in your Propeller code - the Propeller didn't expect time to go backwards an hour. If not, the OS your program running on the computer has a bug - it resets the serial port when time runs backwards.

    I'm guessing you're using Windows, which always had problems with Daylight Savings Time and timezones in general. On Unixes, time is kept in UTC and only converted to local time when it's actually displayed as text, so these problems don't exist.

    I suppose you could somehow tell your computer that DST doesn't exist in your area. But supposing the bug isn't part of the OS, you should really just find the bug and fix it instead of preventing your computer from adjusting the clock automatically.
  • The laptop does not send time and date data to the Propeller as part of the operating system.

    The application program in the Propeller asks for the year, month, day, hour, minutes, and seconds then starts a Cog in the propeller that keeps the time.

    The Propeller program sends data to the laptop for display.

    I wonder if the USD ports get initialized when the laptop time changes from DST to ST and vice versa.

    One more thing...the Propeller application that was provided from someone in the forum asks if the "setclock" time is DST or ST. The "setclock" was in DST when the Propeller stopped operating.

    Discovery

  • I was under the impression that the Propeller did not have a built in RTC clock, thus has no means to keep track of time as in whether or not it is DST. Does the board have an external RTC circuit that keeps the time or is the board picking up the time from some sort of NTP server?

    Can you share more details regarding the board or circuit that you are using?
  • Can you set the computer clock back before the time change and force the problem to happen again?
  • PublisonPublison Posts: 9,768
    edited November 5 Vote Up0Vote Down
    He might be using the RTC object from the OBEX:

    http://obex.parallax.com/object/793

    or this one:

    http://obex.parallax.com/object/499

    Infernal Machine
  • Many years ago, I did receive a download supplied by a forum reference that used one Propeller COG as an RTC. It keeps time very well for my system. I don't know it the code is either of the ones listed above.

    I am not knowledgeable enough about the "C" code to know if there is a fault in the code or not. I will try to find the code and post or reference it.

    It may be a coincidence in the Propeller stopping during a clock time change but somehow...I don't think so.

    Discovery
  • I found it. The code was supplied by Ray Sadeika that was supplied to him from another. I modified the code slightly ...I don't use the SD card.

    Discovery

    // Add startup code here.
    uint8_t buffer[40];

    // int DO = 22, CLK = 23, DI = 24, CS = 25; // SD card pins
    // sd_mount(DO, CLK, DI, CS); // Mount SD card

    _rtc_start_timekeeping_cog(); // <---- important.

    print("This is softRTC\n");
    print("help - for menu\n");

    while(1)
    {
    // Add main loop code here.
    print("> ");
    gets(buffer);
    if(!strcmp(buffer, "quit")) break;
    else if(!strcmp(buffer, "help")) Help();
    else if(!strcmp(buffer, "setclock")) Set_Clock();
    else if(!strcmp(buffer, "time")) Get_Time();
    else if(!strcmp(buffer, "date")) Get_Date();
    else
    {
    print("Invalid Command!\n");
    }
    }
    print("System Stop!\n");
    }

    void Help()
    {
    print("Commands are: setclock, time, date, quit.\n");
    }

    void Set_Clock()
    {
    struct timeval tv;
    struct tm t;

    t.tm_isdst = getdst();
    t.tm_year = prompttime("Year")-1900;
    t.tm_mon = prompttime("Month")-1;
    t.tm_mday = prompttime("Day of the month");
    t.tm_hour = prompttime("Hour");
    t.tm_min = prompttime("Minute");
    t.tm_sec = prompttime("Second");

    tv.tv_sec = mktime(&t);
    settimeofday(&tv, 0);
    }

    int getdst()
    {
    int rc = 0;

    print("Use daylight savings time [y/n] ? ");
    fflush(stdout);

    rc = (getchar() == 'y') ? 1 : 0;
    getchar();
    return rc;
    }

    int prompttime(char *prompt)
    {
    int rc = 0;
    char *endp;
    char buffer[BUFFERLEN];

    do
    {
    print("Enter %s: ",prompt);
    fflush(stdout);

    fgets(buffer, BUFFERLEN,stdin);
    fflush(stdin);

    rc = strtol(buffer, &endp, 10);

    if(endp == buffer)
    {
    if('\n' == *endp)
    {
    rc = 0;
    break;
    }
    print("Invalid entry \"%c....\" Please enter a number.\n", *endp);
    }
    } while(endp == buffer);
    return rc;
    }

    void Get_Time()
    {
    char timebuff[16];
    time_t now = 0;

    now = time(&now);
    strftime(timebuff,16,"%T",localtime(&now));
    print("%s\n",timebuff);
    }

    void Get_Date()
    {
    char timebuff[16];
    time_t now = 0;

    now = time(&now);
    strftime(timebuff,16,"%b %d, %Y",localtime(&now));
    print("%s\n",timebuff);
    }
  • Is there something wrong with the day light code?

    Discovery
  • AleAle Posts: 2,301
    edited November 9 Vote Up0Vote Down
    its formatting ?

    for easier reading you can enclose your code between [ code ] [ / code ] without spaces between the word "code" and the brackets, it preserves indentation and forces a sane fixed width font :)
Sign In or Register to comment.