10/6/2010 9:22 PM | |
Joined: 12/11/2009 Last visit: 9/8/2022 Posts: 243 Rating:
|
This is only for converting dint to string. it does not creat string hh:mm:ss Forexample you have md100 (time) T#1h1m1s move it to decimal md104 then FC5 DI_String Input = MD104 Output = String. Your string will be "+3661000" which is useless. Indeed I created string from time value but it's very long way.(find hour minute /seconds.. convert them to string one bye one. then move strings with sfc20 block move. send always ":" to related bytes.etc etc.. too much time ) I can't use that fc for many TOD values it will take too much time. I need FC Input =Time Output = String (hh:mm:ss) Splitted from Move variable type TOD to String. |
Last edited by: O_Moderator at: 10/11/2010 9:36 AMnew subject after splitting Last edited by: Osman_ at: 10/6/2010 9:29 PM |
|
10/6/2010 10:10 PM | |
Joined: 9/27/2006 Last visit: 6/7/2023 Posts: 12036 Rating:
|
Hello Osman; There are 2 ways I know of working with strings and DT variables. if you do not want to create your own FC to handle the conversion of every byte of the DT structure into a string and concatenate the strings with their seprerators. 1) oscat.de offers a free-downloadable set of functions that complement the Siemens instruction set in very interesting areas, math, complex math, double-floating point math, and conversions. One of the functions provided is DT_TO_STRF, and here is how its help is translated (using Babelfish): DT_TO_STRF converts DATE TIME a value into a formatted character string. The problem is that the documentation is German, but the online help is available in English (at least in the version I installed a few years ago). It is worth looking into. 2) Siemens proposes a Tool collection for converting data types: http://support.automation.siemens.com/WW/view/en/25629271 where you will find a function DT_to_String, Converting DATE_AND_TIME to STRING and vice versa. However,the code isnot free, it is sold through the Siemens AVC card, for 120 credits. For information on the AVC, look at http://support.automation.siemens.com/WW/view/en/28446694. Hope this helps, Daniel Chartier |
Last edited by: dchartier at: 10/6/2010 10:12 PMLast edited by: dchartier at: 10/6/2010 10:12 PM |
|
This contribution was helpful to
1 thankful Users |
10/7/2010 12:15 PM | |
Joined: 12/11/2009 Last visit: 9/8/2022 Posts: 243 Rating:
|
Thank you for helps dchartier. Last night I found a way to convert time to string. I want to share it.We can use this stl code for converting Date/DateandTime to String too. Firstly I converted time to dint with MOVE. then I found hours/minutes/seconds. I converted them to BCD then I putted them in code written down. L bHH // hours byte in BCD-format SLW 4 OW AW W#16#F0F //Mask out rubbish OW W#16#3030 // ASCII for '0' T MW100 L ':' T MB102 L bMM // the same procedure for minutes : : : T MW103 //The converted string starts from MB100 .. |
This contribution was helpful to
2 thankful Users |
10/11/2010 9:38 AM | |
Joined: 4/24/2009 Last visit: 2/23/2023 Posts: 2685 Rating:
|
Thread closed, because question is already discussed in the following thread Converting Time and Date and DateandTime To String in Plc. Best regards O_Moderator |
Follow us on