DateTime loss

Hi again,

got another question, since the 1.2 Hydra doesn’t have a RTC, I need to have my
"Screensaver-Clock" running from DateTime.Now!
My problem is that every 10 seconds I loose a second…so after a minute my clock is already 6 seconds behind.
And for a system that controls the entry/exit-time at work such a high loss is not acceptable :wink:
I searched the forum and net for a bit but couldn’t find any similar problem,
any idea how to solve this or is there no solution?

We just ordered a 32kHz 12.5 pf crystal, but it will take a while until it gets here.

Thx in advance,

Matt

Are you sure you are loosing 1 second every 10 seconds?

If you only update the screen once per second then it can “look” like you are loosing time, because your update and the time isn’t synchronised, so the time updates then you update the screen and all looks fine, but then suddenly the screen updates before time updates, then it looks like the same time is shown for two seconds.

The best is to update the screen more often, at least every half second, preferably every quarter second…

I can be wrong, but I don’t think the Hydra’s clock can be run so slow that it looses 6 seconds per minute.

I currently update it every tenth of a second(before half a second), so should not be the problem, or at least it didn’t make any difference.
If I run it on the emulator it runs fine, but on the hydra it looses time.

I first had it running in a separate thread since it is my screensaver counter and auto login/logoff-counter too and I thought maybe that would
affect the performance in some way. So I changed to a timer but it stayed the same.

The crystal is 32.768khz

@ Gus,
But the 32Khz crystal is only used by the RTC, so only used when restoring the time from the RTC, right? The normal DateTime.Now comes from a normal timer or time that gets updated by the system tick, not the RTC. This is how the EMX works, has this changed for the Hydra?

You are correct. I wasn’t answering the question as I do not have an answer but wanted to point out the correct crystal.

Srry, the crystal is 32.768kHz, just wanted to save some typing :wink:

So gus you have no idea or guess what could be causing this loss?

I do not have an answer but someone else from GHI will answer this.

Are you using QFE2 RC2 release few days ago?

not yet since I’m waiting for the ethernet module to get here on tuesday next week so I only have to update the boards FW once,
since the ethernet FW works only with the module plugged in if I understood everything right?
as soon as its here I will update to QFE2 RC2.

What is the version of the firmware that you are using?

@ Weeman13

We did a test on the latest firmware and did not notice a discernible time loss when running this code:


using System;
using System.Threading;
using Microsoft.SPOT;

namespace HydraSystemClockTest
{
    public class Program
    {
        public static void Main()
        {
            uint counter = 1;
            while (true)
            {
                Debug.Print("System Time: " + DateTime.Now + "..." + counter++);
                Thread.Sleep(1000);
            }
        }

    }
}

How are you trying to utilize the DateTime.Now variable? Please provide us with some code that we can reproduce this anomaly.

Hi Aaron, I’m on 4.1.3.1 not the newest I know, since the ethernet module is coming on tuesday I want to wait with the update until then.
If its no problem changing from the 4.2 without ethernet to the one with ethernet I will do it right away.


 
TextBlock timeBlock = (TextBlock)windows[0].GetChildByName("timeBlock");

            while (true)
            {
                timeBlock.Text = DateTime.Now.ToString();
                if (index == 0)
                {
                    Glide.MainWindow = windows[index];
                }
               
                Thread.Sleep(100);
             }

This runs in a separate thread and changes the textblock every 1/10 of a second( I tried different times too),
then if the index is 0 it keeps reassigning the screensaver window to Glide.Maindow so you see the time change!
Not sure if this is the best way of showing a clock by reassigning the mainwindow every time.
It has to keep running in the back since this device will be used to log the employees working hours, it activates the auto login/logoff action and the screensaver.

EDIT:
I wrote this before, but the whole thing worked like a charm in the emulator

EDIT2:

changed the code Glide.MainWindow = windows[index]; to Glide.MainWindow.Invalidate(); that didn’t help but is probably still better then the first

Hi Weeman,

Yes changing from Non Ethernet to Ethernet firmware is easy. Once you have the Ethernet module, you can use MFDeploy and just deploy the Ethernet Firmware instead of the Non Ethernet version.

Damn, the update was not a good idea…my T35 shows nothing but the boot screen…seems like I cant deploy right

Go through your references. Make sure tha none are set for Specific Version.

If that does’nt work then you must create a new project and import all your source files…

@ Weeman13

What do you mean your T35 shows nothing but the boot screen? What did you do?

I’ve seen this if the app that you deploy links to the wrong dependancies, then it just dies almost silently, still showing the logo and a bit of text about memory and IP and stuff…

I’m not sure if anyone noticed the release notes but this latest version of Hydra (4.2.3.0) has Serial debugging capabilities. You can plug a USB to Serial module into socket 5 and ground pin 8 on socket 14 and it will boot up in Serial Debug Mode and you can use Tera-Term to view messages. This may help with diagnosing the problem too but you are right GMod that the dependencies could be causing it, especially if they were local copied into the directory.

if @ Weeman13 updated the firmware, then he needs to start a new project or rip and replace the old references and re-target 4.2 framework. Quickest way is start a new project; don’t forget it !

I updated the hydra to 4.2.3.0 but only the firmware updated but apparently not the tinybooter. When I started the device it showed the bootloader and the screen turned white or black everytime after that.
So I reverted to 4.1.3.1 and everything was fine. Redid the update and both tinybooter and fw updated correctly but the screen is white as soon as i power it up, no bootloader nothing.

I already created a new project and changed all the references of the old one…nothing. Screen is always white, so before solving the time problem I need to get the device to boot or the screen to show. Although I think it boots since I can get both the fw- and tinybooter-version and when deploying it gives me no error