DTOS + CONCAT help please

stretch_af

Member
Join Date
Mar 2011
Location
Drinking in Wisconsin
Posts
69
I'm writing a new program for a CompactLogix 5069-L310ER.

I used a GSV to grab the date and time from the processor. Then several DTOS and CONCATs to convert the DINTS into one string to display on my HMI, (event driven time stamp). That all worked just fine until this afternoon. When "14:00" should have been displayed, "14:0" was shown. My logic cut off one zero. How do I get my missing zero back? Minor issue, but it's bugging me.

Thanks
Justin
 
When I need to fill the string with 0's, I take the original DINT, add it to some order of magnitude larger, do the DTOS and the use MID or DELETE to take the part I want. For example add 100 to your minutes, do the DTOS and then drop the 1 off the front. The resulting string will be 'xx'. You can CONCAT that with your time to get your 14:xx.
 
Here's one I made which I adapted from the Rockwell one.

There is a routine in there to convert wallclock time to string.
 
Check out this thread. It also has a subroutine you can import.
http://www.plctalk.net/qanda/showthread.php?t=122670

It formats the Time as this: 01/14/2013 08:35:57

But if you have yours built just add a branch to CONCAT '0' if values are less than 10

Depending on your format this could include Month, Day, Hour, Minute and Seconds as shown above.

Good luck with your project!
 

Similar Topics

So what I thought would be simple has turned out not to be, or at least it hasn't become obvious enough to me yet. I have a DINT coming into a...
Replies
6
Views
4,022
OK, So I have a problem where I have SINT[450] array (Data[x]). I created an index that runs through and does 450 itterations of DTOS instruction...
Replies
4
Views
2,842
Hi all I am trying to set up a lhttp instruction to connect to an api https (with our IT) this will send data back to the plc? I have an api https...
Replies
9
Views
1,785
Hello, I am using Machine expert - basic with an M221 PLC. I have two 16 bit modbus registers coming in and I want to convert to a 32bit real...
Replies
8
Views
3,892
Can I take 2 strings, concatenate them and use that result as a TagName of a Bool or any other element? I'm creating an AOI for MSG stats and it...
Replies
3
Views
1,473
Back
Top Bottom