Industry Online Support
Technical Forum
10/12/2014 3:09 PM | |
Joined: 1/28/2009 Last visit: 1/19/2025 Posts: 6858 Rating: (1366) |
Hello, Have a look here: How can timers be programmed in a S7-1200 in the DTL time format? I hope this is what you are looking for, Hamid Hosseini |
10/16/2014 5:54 PM | |
Posts: 22 Rating: (6) |
Hello, Just in case you or anyone else that find this post is still looking for more info, I though it would be nice to offer a small demo of SCL code for this. I find it to be far, far more readable and easy to work with then any of the other examples I have found. Below is a basic code example that does exactly what you asked for and nothing else. I've also attached an s7-1200 project. Give SCL a try. As you'll see, it's pretty easy to work with and it's power full! Code Example: //You can paste this right into a TIA Portal SCL program block. //this script will turn on an output when the local time of day reaches the operator set point. //I tried to keep it very easy to read since the main goal was to demonstrate a very easy way to //work with DTL data types. //capture the local time //you can look up the "RD_LOC_T" instruction in the help file "rdLocTStatus" := RD_LOC_T("myTimeDb".currentLocalTime); //check if the time of day is equal to or greater then the operator setpoint //the way this is written, it will stay true until midnight IF ("myTimeDb".currentLocalTime.HOUR >= "myTimeDb".operatorTimeSetpoint.HOUR) AND ("myTimeDb".currentLocalTime.MINUTE >= "myTimeDb".operatorTimeSetpoint.MINUTE) AND ("myTimeDb".currentLocalTime.SECOND >= "myTimeDb".operatorTimeSetpoint.SECOND) THEN "operatorTimeSetpointReached" := 1; ELSE "operatorTimeSetpointReached" := 0; END_IF; //when the operator setpoint has been met turn on the output //I use edge detection so that the output is only turned on once per day. IF "operatorTimeSetpointReached" AND NOT "operatorTimeSetpointReachedLastScan" THEN "output1" := 1; END_IF; //write some other code here to turn the output off based on some condition. Possibly //a time delay or process completion. It will have to be turned off eventually if you //plan on triggering it again tomorrow. //assign last scan status for edge detection "operatorTimeSetpointReachedLastScan" := "operatorTimeSetpointReached"; End Code Example Cheers Attachments7-1200 dtl demo.zip (583 Downloads) |
This contribution was helpful to3 thankful Users |
10/16/2014 5:58 PM | |
Posts: 22 Rating: (6) |
Code looks so bad in this forum. Please cut and paste the code example above into TIA Portal before you judge its readability. Cheers
|
Follow us on