Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

obtain Station Date/Time in seconds?


mwebb Aug 10, 2012 09:42 PM

Hello,
I am trying to get the time in seconds (since 1970, but I can add an offset if its since a different date like 1990) from the CR1000 in CRBasic so that I can update the "clock" on some custom sensors we use with the CR1000.
I searched the forum and the Help in CRBasic and cannot find anything except RealTime(), which gives Y/M/D/etc separately.
Is there a built-in function to obtain the time in the other format?
Thanks,
Mark

* Last updated by: mwebb on 8/15/2012 @ 4:52 PM *


TweedleDee Aug 10, 2012 09:54 PM

Use the SecsSince1990 instruction.

btw, are you located in Africa?


mwebb Aug 10, 2012 10:07 PM

Africa? no, why? and thanks very much!
That will work fine. It doesn't recognize that function in my CRBasic/datalogger, so I am updating the CR1000 OS now (after making sure I have the settings ready to reconfigure with).

* Last updated by: mwebb on 8/10/2012 @ 4:56 PM *


mwebb Aug 15, 2012 10:49 PM

As an update for if someone else is searching to do something similar, what I ended up doing was as follows:

- Obtain datalogger time at start of current scan loop using RealTime --> This gives YYYY, MM, DD, HH, MM, SS, etc in an array.
- Use SecsSince1990 with the above values that I put into a string of the appropriate format to match what the function requires.
- Added 631152000 (seconds between 1970 and 1990)

An additional note is RealTime reports the time in local timezone, I did not find a way to obtain the GMT time (and loggernet sets the datalogger to the computer's local time), so I will have a separate manually defined variable for the GMT offset and have it add or subtract the appropriate number of seconds.


Dana Aug 16, 2012 05:56 PM

You can set LoggerNet to use GMT, regardless of the PC system clock, by going into the Setup window, Options, LoggerNet clock setting.

You can also set an offset to the PC clock for the datalogger -- In the Setup window, highlight the datalogger, choose the clock tab, Time Zone Offset field.

Dana


Dana Aug 16, 2012 05:57 PM

You can set LoggerNet to use GMT, regardless of the PC system clock, by going into the Setup window, Options, LoggerNet clock setting.

You can also set an offset to the PC clock for the datalogger -- In the Setup window, highlight the datalogger, choose the clock tab, Time Zone Offset field.

Dana


aps Aug 17, 2012 01:22 PM

If you want to run the logger on local time including the complications of running on "daylight savings" or "summer time" you may also want to check out the Daylightsavings instructions in the logger which will tell you any current offset caused by the seasonal offsets, which you can add to you correction to GMT.


Carolyn Aug 21, 2012 05:52 PM

Just FYI, you can also get Seconds since 1970 directly from a data table with Tablename.TimeSTamp(m,n)if you use m option 0, as described below....

You can get to the help for this from CRBasic help by searching for datatable access and then displaying the help for tablename.timestamp

Syntax

TableName.TimeStamp(m,n)

Remarks

The TableName.TimeStamp(m,n) syntax returns the time into an interval or a timestamp for the record n number of records ago. The name of the DataTable is entered in place of the TableName parameter. TableName is limited to 20 characters. The type of timestamp returned is based on the option specified for m and the format of the variable in which the timestamp is stored: The timestamp returned has a 10 msec resolution.

Variable formatted as Float or Long

m Time Stamp Element

0 seconds since 1970

1 seconds since 1990

2 seconds into the current year

3 seconds into the current month

4 seconds into the current day

5 seconds into the current hour

6 seconds into the current minute

7 microseconds into the current second


mwebb Sep 6, 2012 08:10 PM

I had moved on from this since there was a workable solution, but now have come back around to clean up and finish up system testing. The additional information is also helpful. Carolyn, am I correct that using the datatable method cannot be used to get the "current" time, but only the last time a specific datatable was updated? Or maybe there's a table it automatically makes for the scanloop and specifying "0" would be the "current" record?
If not, I may need to just stick with the SecsSince1990 + offsets.

Also, thanks for the GMT option and DaylightSaving offsets suggestions Dana/aps. I will make sure to either change the settings to GMT (this would be up to how the client wants them set up) or add in the DaylightSaving offset.

* Last updated by: mwebb on 9/6/2012 @ 2:13 PM *


Dana Sep 6, 2012 11:12 PM

Try the Public table (Public.Timestamp(1,1)). This is the table that is written every scan.

Dana


kirving Sep 7, 2012 01:05 AM

Very interesting about public.timestamp(1,1). I see it used in the CR1000 manual, but can't find documentation about it. Are there other properties in the public table? Can public program variables be accessed through it?

* Last updated by: kirving on 9/6/2012 @ 7:06 PM *


Dana Sep 10, 2012 06:25 PM

Take a look at the topic in CRBasic help "Data Table Access". The topic can be found from the Index. There is a variety of syntax that can be used for accessing information from a data table.

Dana

Log in or register to post/reply in the forum.