You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old March 4th, 2018, 08:05 AM   #1
Cydog
Member
United States

Cydog is offline
 
Join Date: Feb 2018
Location: Maryland
Posts: 68
Dog ControlLogix - Timestamping using a CONCAT instruction missing 0 in time

Good Morning ,

I'm working on trying to get timestamping done on some doses. I am very close, thanks to many of you with your advice. I used the two instructions DTOS and CONCAT . Everything is working well except when I see the time , for example 8:06 it appears has 8:6 . What can I do to get the 0 in its right place ? When it turns 8:10 i get 8:10. It only happens when the minutes are single digits .

Thanks so much for your help.
  Reply With Quote
Old March 4th, 2018, 08:43 AM   #2
AustralIan
Member
United Kingdom

AustralIan is offline
 
Join Date: Jan 2013
Location: UK
Posts: 764
Code:
LES    ]-----[CONCAT]
minutes]     [String]
10.    ]     ["0"   ]
             [String]
Put that rung before your CONCAT statement with your minutes String.
  Reply With Quote
Old March 4th, 2018, 04:56 PM   #3
Jeev
Member
Australia

Jeev is offline
 
Jeev's Avatar
 
Join Date: May 2008
Location: Brisbane
Posts: 435
When I'm trying to fill with 0's, I will add 10/100/1000/Whatever to the DINT, DTOS it, and then use MID or DELETE to chop the front off at the relevant spot. For you that looks like adding 100 to your minutes or hours, and then converting and chopping the first letter off.
  Reply With Quote
Old March 5th, 2018, 09:23 AM   #4
cwal61
Member
United States

cwal61 is offline
 
Join Date: Jan 2011
Location: NC
Posts: 977
Check out this thread Post #4

http://www.plctalk.net/qanda/showthread.php?t=11198

It will do what AustralIan explained. Less than 10 CONCAT '0'. I used it for Minutes and Hours.
  Reply With Quote
Old March 5th, 2018, 09:47 AM   #5
RonJohn
Lifetime Supporting Member
United States

RonJohn is offline
 
RonJohn's Avatar
 
Join Date: Jul 2013
Location: NE Ohio
Posts: 416
Quote:
Originally Posted by cwal61 View Post
Check out this thread Post #4

http://www.plctalk.net/qanda/showthread.php?t=11198

It will do what AustralIan explained. Less than 10 CONCAT '0'. I used it for Minutes and Hours.
cwal61, can you double check your link please? Looks like this one's talking about a broken Omron cable
  Reply With Quote
Old March 5th, 2018, 11:00 AM   #6
TheWaterboy
Lifetime Supporting Member + Moderator
United States

TheWaterboy is offline
 
TheWaterboy's Avatar
 
Join Date: May 2006
Location: State of Denial
Posts: 789
Maybe this will help? add one to length and insert a 0 when less than 9 .

Add 1 to len.jpg
  Reply With Quote
Old March 5th, 2018, 01:42 PM   #7
janner_10
Supporting Member
United Kingdom

janner_10 is offline
 
Join Date: Dec 2014
Location: Tewkesbury
Posts: 638
Oddly enough, I made a routine exactly for this in the week for a string time stamp for a project.

Quote:
//Reads the PLC date and time and converts it to a string value

//Read PLC Date Time. Write to DateTime in Controller Tags as usual DINT[7] format.
GSV(WallClockTime,,DateTime,PLC_Time[0]);

//Convert Year to String
DTOS(PLC_Time[0],YearString);

//Convert Month to String // Add leading zero if less than 10
If PLC_Time[1] >=10 Then
DTOS (PLC_Time[1],MonthString);
ELSE DTOS (PLC_Time[1],MonthTemp);
CONCAT (strConst[4],MonthTemp,MonthString);
END_IF;

//Convert Day to String // Add leading zero if less than 10
If PLC_Time[2] >=10 Then
DTOS (PLC_Time[2],DayString);
ELSE DTOS (PLC_Time[2],DayTemp);
CONCAT (strConst[4],DayTemp,DayString);
END_IF;

//Convert Hour to String // Add leading zero if less than 10
If PLC_Time[3] >=10 Then
DTOS (PLC_Time[3],HourString);
ELSE DTOS (PLC_Time[3],HourTemp);
CONCAT (strConst[4],HourTemp,HourString);
END_IF;

//Convert Minute to String // Add leading zero if less than 10
If PLC_Time[4] >=10 Then
DTOS (PLC_Time[4],MinuteString);
ELSE DTOS (PLC_Time[4],MinuteTemp);
CONCAT (strConst[4],MinuteTemp,MinuteString);
END_IF;

//Convert Second to String // Add leading zero if less than 10
If PLC_Time[5] >=10 Then
DTOS (PLC_Time[5],SecondString);
ELSE DTOS (PLC_Time[5],SecondTemp);
CONCAT (strConst[4],SecondTemp,SecondString);
END_IF;

//Merged all the strings together
CONCAT(DayString, strConst[1], stTemp[0]); //Add Bracket to Day
CONCAT(stTemp[0], MonthString, stTemp[1]); //Add Month
CONCAT(stTemp[1], strConst[1], stTemp[2]); //Add Bracket
CONCAT(stTemp[2], YearString, stTemp[3]); //Add Year
CONCAT(stTemp[3], strConst[0], stTemp[4]); //Add Space
CONCAT(stTemp[4], HourString, stTemp[5]); //Add Hour
CONCAT(stTemp[5], strConst[2], stTemp[6]); //Add Colon
CONCAT(stTemp[6], MinuteString, stTemp[7]); //Add Minute
CONCAT(stTemp[7], strConst[2], stTemp[8]); //Add Colon
CONCAT(stTemp[8], SecondString, stTemp[9]); //Add Second

//Copy the DateTime string to the Controller Tag
COP(stTemp[9], Date_Time_String, 1);
gives you an idea about the leading zero. If you want the routine, i'm more than happy to send it to you.
  Reply With Quote
Old March 5th, 2018, 05:22 PM   #8
cwal61
Member
United States

cwal61 is offline
 
Join Date: Jan 2011
Location: NC
Posts: 977
http://www.plctalk.net/qanda/showthread.php?t=111989

Looks like I missed the last digit.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Logix5000 - Unconditional Output behaviour when Faulted lambles LIVE PLC Questions And Answers 12 May 16th, 2017 07:43 PM
Time sync PV 1000 to Controllogix clock? elecmech1 LIVE PLC Questions And Answers 1 April 9th, 2013 07:03 PM
ControlLogix - How to clear ONS instruction in Prescan? bobby1234 LIVE PLC Questions And Answers 8 January 10th, 2007 12:04 PM
How AB Timers work. PhilipW LIVE PLC Questions And Answers 0 January 28th, 2005 02:47 PM
Using FSC instruction in Controllogix ettikudiappan LIVE PLC Questions And Answers 2 October 21st, 2002 05:07 PM


All times are GMT -5. The time now is 07:46 AM.


.