TIA Portal v18: Saving current date/time to a tag...

Mas01

Member
Join Date
Oct 2020
Location
Leicester, England
Posts
1,109
I'm struggling with this...Times and Dates are always a mental-block for me.

See picture.

When I press SAVE, I want to take the current date/time (i.e. "wall clock time/date") and save it in a tag, i.e. it needs to be like a "snapshot" of the time when SAVE was pressed.

Then the next problem is adding 182 days (6 months approx) to that tag and save it in the box below it.

Can anyone point me in the right direction as to how to do this?

Thanks

CAL screen.png
 
Last edited:
I've managed to add 182 days to a date...that works fine (tick/check)

Problem is, the parameter IN1 is just a 'startup' value I had set up in the DB (by way of experiment).

If I can somehow MOVE the current date/time into IN1 tag (CA_Last_Calibration), I think I'm almost there.

182 days added OK.png
 
In the interface of the block. I use the data type to precede the variable name so iRetVal is an integer, dtlNow is of type DTL
Comes in handy when screen shots are posted and you have no idea what data types are being used. I also recommend using
CamelCaseWhereYouSeparateEachWordWithACapitalLetter rather_than_using_underscores.(NB this site introduced the space before the letter r for some reason)
 
Many Thanks for this - but where are #iRetVal, #dtlNow defined?
Are they integers?


Since their tags start with a #, they are declared in the local data FC or FB that holds this rung. The are probably Temp variables, although iRetVal could be an additional output parameter from the function (see below) so the caller can determine if there was a problem in the FC.

The TIA Help for the RD_SYS_T instruction documents the data types. #iRetVal will almost certainly be an integer, probably an INT data type; dtlNow will be a DTL data type, because the T_CONV that follows converts DTL data type to Date data type.
Untitled.png
 
Last edited:
Once again, I'm indebted to your replies, chaps.
I didn't even know these functions existed.
I'm back home now but I'll implement it tomorrow.Many thanks.
 
Internal PLC system time/date is not correct, probably still with factory default time/date

Set new PLC time date. You can do in two different ways:

1. use function WR_SYS_T

2. Go online with PLC, then select Online & Diagnostics --> Set time --> Apply button
 
Internal PLC system time/date is not correct, probably still with factory default time/date

Set new PLC time date. You can do in two different ways:

1. use function WR_SYS_T

2. Go online with PLC, then select Online & Diagnostics --> Set time --> Apply button

Superstar! It's working now, cheers.

date correct.png
 

Similar Topics

hello every one. i'm new to tiaportal, i have created new project and HMI screen the program works fine with PLC-sim, but when i try to cntrol the...
Replies
9
Views
414
My PLC (S7-1200) and HMI (KTP-1200 Basic) has been delivered on-site to the customer. To be able to do "off-line" updates to the code, I am using...
Replies
4
Views
223
hi everyone. i hope you guys are doing great. i am trying to built communication between aveva intouch hmi 2023 and tia portal v18. i dont have...
Replies
1
Views
567
Hi, My PLC hardware has been delivered to customer site - many thanks for the invaluable help on this forum! I was looking into see if it's...
Replies
12
Views
2,510
Tia portal v18 issue,online icon greyed out but plc comms must be established as.blocks showing and no offline copy on laptop.
Replies
7
Views
1,104
Back
Top Bottom