Support Forums
Date & Time

Hi,
I had made a simple program,

BEGIN"TEST"
RA2S
T
1$="\T"
END

The result was showed 1$ not equal to the T(time)

Kindly advise me on how to read the current time and save it into variable $1.

Regards,
Wan Rosli

Hi, I had made a simple program, BEGIN"TEST" RA2S T 1$="\T" END The result was showed 1$ not equal to the T(time) Kindly advise me on how to read the current time and save it into variable $1. Regards, Wan Rosli

Hi Wan Rosli,

Doing 1$="\T" will actually assign the System time(PC time) not the logger time

basically the \T will be replaced with the current PC time as a string when you run the job,it will have the same value every time schedule triggered .

Instead you can use the Channel variables to store the time

BEGIN"TEST"
RA2S
T(=1cv)
1CV
END

The above job will save the Logger time in seconds in 1 Channel variable

Created job "TEST"
DT80> Time 22:09:36.000
1CV 79776.0

Time 22:09:38.003
1CV 79778.0

Time 22:09:40.000
1CV 79780.0

Regards,
Lokesh

Hi Wan Rosli, Doing 1$="\T" will actually assign the System time(PC time) not the logger time basically the \T will be replaced with the current PC time as a string when you run the job,it will have the same value every time schedule triggered . Instead you can use the Channel variables to store the time BEGIN"TEST" RA2S T(=1cv) 1CV END The above job will save the Logger time in seconds in 1 Channel variable Created job "TEST" DT80> Time 22:09:36.000 1CV 79776.0 Time 22:09:38.003 1CV 79778.0 Time 22:09:40.000 1CV 79780.0 Regards, Lokesh

Hi Lokesh,
Actually, i want to send the time trough my serial port which is ;

BEGIN"TEST"
RA2S
T
1$="\T"
2SERIAL("{%s[1$]}"smile 'example of serial command'
END

But \T is the current PC time. is there any keyword to change it from %s[1$] to 1CV value but in Data Taker time format ?

Regards
WanRosli

Hi Lokesh, Actually, i want to send the time trough my serial port which is ; BEGIN"TEST" RA2S T 1$="\T" 2SERIAL("{%s[1$]}") 'example of serial command' END But \T is the current PC time. is there any keyword to change it from %s[1$] to 1CV value but in Data Taker time format ? Regards WanRosli

Hi wanrosli,

Why don't you use system timer 1ST (for second), 2ST (for minute) and 3ST (for hour), save into CV and then reconstruct the string via SERIAL command?

Best regards,
Rudy

Hi wanrosli, Why don't you use system timer 1ST (for second), 2ST (for minute) and 3ST (for hour), save into CV and then reconstruct the string via SERIAL command? Best regards, Rudy

Hi,
i thought that the time command should have a simple variable. (same as Day,Month,Year=20SV,21SV,22SV)

i have made a simple convertion by using Lokesh idea as per below;
T(=10CV,W) 'Read the time
11CV(w)=10CV%60 'Display Seconds time part
12CV(w)=(10CV/60)%60 'Display Minute time part
13CV(w)=(10CV/3600)%24 'Display Hour time part
20SV(=14CV,W) 'Display Day
21SV(=15CV,W) 'Display Month
22SV(=16CV,W) 'Display Year

All this variable i send it through serial and found work.
Regards,
WanRosli

Hi, i thought that the time command should have a simple variable. (same as Day,Month,Year=20SV,21SV,22SV) i have made a simple convertion by using Lokesh idea as per below; T(=10CV,W) 'Read the time 11CV(w)=10CV%60 'Display Seconds time part 12CV(w)=(10CV/60)%60 'Display Minute time part 13CV(w)=(10CV/3600)%24 'Display Hour time part 20SV(=14CV,W) 'Display Day 21SV(=15CV,W) 'Display Month 22SV(=16CV,W) 'Display Year All this variable i send it through serial and found work. Regards, WanRosli

Hi, this script has a bug in rounding. For example
5CV=2.2; DO"?5F0 "
will display 2. However, doing
5CV=2.7; DO"?5F0 "
will display 3.
This is different than in the majority of programming languages (like C, python) where is shows INT part of number indeed, not rounding.

So the correct version is taking only INT part of the number, which is a little bit cumbersome:
22SV(=20CV,W) 'year
21SV(=21CV,W) 'month
20SV(=22CV,W) 'day
T(=23CV)
24CV=(23CV/3600)-(23CV/3600)%1 'int hour
25CV=((23CV%3600)/60)-((23CV%3600)/60)%1 'int minute
26CV=(23CV%60) 'second
DO"Door opened ?20F0/?21F0/?22F0 ?24F0:?25F0:?26F2"

Hi, this script has a bug in rounding. For example 5CV=2.2; DO"?5F0 " will display 2. However, doing 5CV=2.7; DO"?5F0 " will display 3. This is different than in the majority of programming languages (like C, python) where is shows INT part of number indeed, not rounding. So the correct version is taking only INT part of the number, which is a little bit cumbersome: 22SV(=20CV,W) 'year 21SV(=21CV,W) 'month 20SV(=22CV,W) 'day T(=23CV) 24CV=(23CV/3600)-(23CV/3600)%1 'int hour 25CV=((23CV%3600)/60)-((23CV%3600)/60)%1 'int minute 26CV=(23CV%60) 'second DO"Door opened ?20F0/?21F0/?22F0 ?24F0:?25F0:?26F2"

Hi Smilauer,

When you define DO"?5F0", ?5 will refer to 5CV and F0 will refer to no decimal point.
If you need one decimal point please use DO"?5F1"
Or 2 decimal points DO"?5F2"

And you do not need to capture time with T because it will give you seconds in a day.
Instead of T you can use 1ST, 2ST and 3ST for second, minute and hour.
Similar to date, you can assign CV to ST (system timer).

Best regards,
Rudy Gunawan

Hi Smilauer, When you define DO"?5F0", ?5 will refer to 5CV and F0 will refer to no decimal point. If you need one decimal point please use DO"?5F1" Or 2 decimal points DO"?5F2" And you do not need to capture time with T because it will give you seconds in a day. Instead of T you can use 1ST, 2ST and 3ST for second, minute and hour. Similar to date, you can assign CV to ST (system timer). Best regards, Rudy Gunawan
71
6
4
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft