ControlLogix - Timestamping using a CONCAT instruction missing 0 in time

Cydog

Member
Join Date
Feb 2018
Location
Maryland
Posts
313
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.
 
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.
 
Oddly enough, I made a routine exactly for this in the week for a string time stamp for a project.

//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.
 

Similar Topics

Hi folks, In ControlLogix5555 there is a timestamping feature that can timestamp a time when data has changes or when fault has occurs...
Replies
4
Views
6,087
Hi everyone i have a customer, who wants to show an alarm on the machine, if the I/O forces are enabled and set, on at ControlLogix L81E with...
Replies
3
Views
140
Does anyone know of a way to detect if someone is online with the controller in ControlLogix (from logic) I'm thinking that maybe there is a CIP...
Replies
7
Views
293
I've never paid attention to this, is this normal?
Replies
13
Views
420
Hi. I need suggestions. I want accumulate operating hours from a simple XIC condition, so I'm thinking a RTO with a 60000 or 3 600 000 preset, 1...
Replies
7
Views
225
Back
Top Bottom