Dint to Time convertion on Siemens S7-315 CPU with TIA v11

nicknzj

Member
Join Date
Apr 2012
Location
kampar
Posts
17
Hi All,

Can anyone advice and share on the following?
- How can we convert Dint to Time format on S7-315CPU with TIA v11?
- If i need to insert a (TON)timer setpoint from HMI,how can i convert the msec to Hr,Min,Sec and finally the timer will display in countdown mode on the HMI.

Thanks and Regards
 
in SCL you can try with this: PT:=dint_to_time(variable)
in LAD and FBD i think there t_conv block that do the same.
as for STL i don't think it's possible.

if you need this a lot try with writing a function in SCL that has var for input and give time as return result.

PS: if using SCL you can go with integer, eg. dint_to_time(int_to_dint(variable))

i wrote a similar function once:

FUNCTION "T_min" : Int
VAR_INPUT
"Time_int" : Struct
"h" : Int;
"min" : Int;
END_STRUCT;
END_VAR

BEGIN
#T_min:=#Time_int.h*60+#Time_int.min;
END_FUNCTION

!!! IMPORTANT: do not forget that Timers have PT in msec, so multiply with right factor if you do not have time in msec already
 
Last edited:
Thanks Balash,
Im not fomiliar with other programming language than Ladder, can you please generate and share a function block which create by SCL ?
 
well the code is already written, but do as follows:
1. create new function T_dint, choose SCL for language
2. declare input paramter Time_dint DINT
3. declare function return value as TIME (default is void)
4. write: #T_dint:=dint_to_time(#Time_dint);

that's it

of course if #Time_dint is in minutes then everything has to be multiplied with 60000

EDIT:
or if you have hours, minutes and sec declared as inputs then use this:

#T_dint:=dint_to_time(((#hours*3600) + (#minutes*60) + sec)*1000);

vice versa function would have time as input and hours, minutes, sec as output:

#temp:=time_to_dint(#Time_ET)/1000;
#hours:=#temp/3600;
#minutes:=(#temp-(#hours*3600))/60);
#sec:=(#temp-(#hours*3600)-(#minutes*60));

that would be on the fly...
 
Last edited:

Similar Topics

Hi I am being given several fault words (as a DINT) from a Drive that I am receiving into a Compactlogix L33ER controller. I have a small...
Replies
12
Views
1,140
I am working on a project with a Controllogix 5582 processor using v32 firmware where I will be communicating with a Genset using Modbus TCP. It...
Replies
14
Views
973
Hi! It is always said, that DINT is the most performant datatype in AB plcs. I while ago i made a performance test. Several instructions like ADD...
Replies
4
Views
656
Im trying to use a MSG instruction to get the serial numbers of all addon cards and display the serials on a HMI interface. I have the logic done...
Replies
2
Views
552
Just something I think about when choosing data types in Studio 5000. It seems logical, but I've never looked deeply into the question. When...
Replies
12
Views
1,365
Back
Top Bottom