9/8/2014 6:28 PM | |
Posts: 22 Rating: (6) |
Hello, Here is some code to solve this question. I realise this question is several days old but you never know who it may help. I chose an s7-1500 for this since you didn't specify a processor. It's written in SCL which I highly recomend. In case you have never used this before, to create an SCL Block choose: Add new block --> Organizational block --> and in the Language drop down choose SCL. Also attached is a sample project for an s7-1500 Code: //set two time stamps so that we can practice calculating the difference between them. //subtracting the earlier time from the later time will result in a positive difference. "TimeStampDb".timeStamp1 := DTL#2014-9-2-20:30:20.250; "TimeStampDb".timeStamp2 := DTL#2014-9-1-20:30:20.250; //calculate the difference between the two times "deltaT" := "TimeStampDb".timeStamp1 - "TimeStampDb".timeStamp2; //convert the time difference in to minutes //we must first convert Ltime to Time because Ltime is in nanoseconds and will //be to much data for our dint to hold. Then we divide by 60000ms to convert to minutes. "deltaTInMinutes" := LTIME_TO_TIME("deltaT") / 60000; //you can view the results in a watch table AttachmentDTL difference in min.zip (577 Downloads) |
This contribution was helpful to1 thankful Users |
3/21/2018 10:30 AM | |
Joined: 6/19/2017 Last visit: 9/6/2024 Posts: 8175 Rating: (174) |
New question published by KailashG is split to a separate thread with the subject Project for local time & running time. Best regards |
Follow us on