Write time or date to UROM locations?

bgriffith

Member
I'd like to be able to write times and dates to some of the UROM locations using the seturom.cgi function.  These would then be compared to CD and CT in the PLC code.  I have tried using the web interface to set UROM1 to 18:28:00, but that did not change the value of UROM1.  I haven't actually tried using seturom.cgi yet, but I assume the web interface goes through seturom.cgi anyway.
I suspect that I'll have to convert the times and dates to integers.  What would be the formula for doing that?  Is CD the number of days since 1/1/2000 and CT the number of seconds since midnight?
 
Thanks,
Ben
 
Yes, UROM is a 32 bit signed integer. To store anything on it, you will need to convert that to integer. 
If you want to convert the CD and CT to integer, it is probably easily to remember CTS, and compare how many seconds have been changed.
Since each day is how many seconds is fixed, that can be easily to div the later CTS to get the day.
 
If you have any suggestion to implement a new data type for this, we can work on that for you, too.
 
Thanks for your reply. 
I want to be able to compare the current date (CD) and the current time (CT) to a date and a time written into the UROM locations.  I want the time comparison in particular to be independent of the date comparison.  So if UROM1 is set to 6:30am I want the following operation to be true at 5am regardless of what the date is, and false at 7am regardless of what the date is.
 
TSTGT UROM1 CT
 
I could store the time as seconds since midnight and then compare it to the result of MOD CTS 86400, but I thought this was what CT was intended for.
Similarly I could store the date as days since 1/1/2000 and then compare it to the result of DIV CTS 86400, but isn't that the intent of CD?
 
In trying to figure it out last night I just added lines at the top of my program to set VAR1 and VAR2 to CD and CT respectively.  The following corresponds to 9/16/2013 at about 22:45:xx EDT (UTC-4).
 
VAR1=152045533 (CD)
VAR2=1387555 (CT)
 
How do I get from 9/16/2013 and 22:45 to those values?  VAR2 is way too big to be seconds since midnight, and I tried dividing VAR 1 by 86400 and then 365 but came up with 4.8, which would be sometime in October of 2004?
 
Thanks,
Ben
 
CT is a 24 bit number, with hour, minute, and second each occupy one byte in it.
CD is also a 24 bit number, with month, day, year in each byte position.
If you convert those number to hex, it will be easier to see what I mean.
If you have latest 3.02.17e firmware, you can store it in RAM, and check each byte for different value.
 
Thank you.  That makes sense now.
 
VAR1=152045533 (CD)  --> 09 10 07DD  --> 09/16/2013
VAR2=1387555 (CT)  --> 15 2C 23  -->  21:44:35  (That's off by an hour but I'll check my time zone and DST settings.)
 
It looks like for my purposes just using days since 1/1/2000 for the date and seconds since midnight for the time would be easier.
 
At one point last night I saved CDAY to a variable and it was stored as 256 (100h).  That made me even more confused, but now it's apparent that it is erroneoulsy grabbing 12 bits for the day instead of 8.  I'm guessing that today it might show up as 272 (110h).
 
That CD and CT has not changed for a long time.  Do you still have problem with it?  If you do, please let us know how to duplicate that.
 
Seems to be ok now.  I think it was just confusion about how CD and CT work. 
My comment about the time being off by an hour was actually based on the time stamp of an email sent by the board.  It looks as though the email timestamps are +1 hour from the system time. 
 
Ah, here we go:

Date: Wed, 18 Sep, 2013 20:36:07 -0500

I'm in the Eastern Time Zone, which is -0500, but I have the Daylight Savings Time box checked, which should make it -0400.  When I received the email, GMail adjusted it for me and said it was sent at 9:36pm (which is 34 minutes from now). 
 
Which version firmware do you run?  Are you running a WC32 board?  Since WC8 board does not support GMAIL, only WC32 support GMAIL SSL encryption.
 
I have the latest, 3.02.17e.  I just got it back from being updated on Monday. I'm not sure what a WC32 board is, but my board is Rev 2.2.2. 
 
I send the email out via Yahoo, but the recipient is my gmail address.  Gmail thought the timestamp in the email was using non-DST time (because it says -0500), so when it displayed the time it was sent it adjusted it to my timezone (-0400) by adding an hour. 
I assume the code that assembles the email just reads the timezone value and inserts that into the "Date:" line of the email header.  It should also look at the DST box and add +0100 to the timezone when it is checked.
 
Not really, WC8 actually sends out DST adjusted time. I think that problem  is something to do with Yahoo server and Google server.   If you could do a TCP capture on that, it will probably show the date stamp sending out is correct one.  We checked our code, the DST adjusted time being used by CD and CT are also being used to put in email header for sending time.
 
WC32 is WebControl 32, a board based on 32 bit processor. We have been shipping them to anyone wanting to purchase a beta kit.
 
The board does send out DST adjusted time but the time zone doesn't seem to be DST adjusted. 
 
This isn't a TCP capture (I can try to get one tonight if necessary), but here are the bottom five lines of the header of an email sent by my board last night.  I think the From, To, Date, and Subject lines are all generated by the board.  The X-Rocket-Received line and everything that was above that was added on by the servers that the message passed through.
 
X-Rocket-Received: from WEBCONTROL ([email protected] with )
        by smtp212.mail.bf1.yahoo.com with SMTP; 18 Sep 2013 16:53:32 -0700 PDT
From: WEBCONTROL <[email protected]>
To: [email protected]
Date: Wed, 18 Sep, 2013 19:53:28 -0500
Subject: WebControl test email
 
The email was sent at 19:53:28 EDT (-0400), and that's what time the web interface on the board said it was.  The date line above says it was sent at 19:53:28 -0500, which would be EST (or CDT).  So the time is adjusted for DST, but the time zone is not.  Notice also that the timestamp from the yahoo server is 16h -0700, which corresponds to 19h -0400, not 19h -0500.
 
We did not send out timezone, that is generated by the email server.
We will see maybe we can do something to make email server adjust timezone
 
Latest firmware changed the number string send to the email server, now the email server display correctly. If anyone needs firmware update please contact us in private message or email to us directly.
 
Back
Top