Help - Search - Members - Calendar
Full Version: two digit date & time
Forums.MrPLC.com > PLCs and Supporting Devices > Allen Bradley
eccan
I have a Micrologix 1100, and I need to send all the date & time data from the RTC to a bar code printer. I want each part to consist of 2 digits (02/01/08 11:06:00). However, when any part of the RTC consists of only 1 digit (like 9 for 9am) I need to add the leading zero character. I figured out how to do this by using some math and sending each digit of each part to an individual string, then combining all the digits back together with an ACN, but I was wondering if anyone has a cleaner solution. My customer will look at this part of my program and wonder what is going on - and a confused customer usually means a phone call.

Evan

b_carlton
No matter what method is used remember:

Comments - Comments - Comments
Clay B.
QUOTE(eccan @ Feb 1 2008, 12:12 PM) [snapback]64611[/snapback]

I have a Micrologix 1100, and I need to send all the date & time data from the RTC to a bar code printer. I want each part to consist of 2 digits (02/01/08 11:06:00). However, when any part of the RTC consists of only 1 digit (like 9 for 9am) I need to add the leading zero character. I figured out how to do this by using some math and sending each digit of each part to an individual string, then combining all the digits back together with an ACN, but I was wondering if anyone has a cleaner solution. My customer will look at this part of my program and wonder what is going on - and a confused customer usually means a phone call.

Evan



That is the only method I have ever used. If you want to keep down confusion create one string file where all of this takes place so your customer can open it up and see exactly what you are doing. Along with comments, having your system organized can really help someone following you.
tpedley
be glad you're doing it the right way. Personally, I use a different string for each ACN, and document what each string shoud have in it. st9:0 (header), st9:1 (st9:0 + 2dhour), st9:2 (st9:1 + 2dminute) etc.

good luck. padding zeroes and building solid strings is never fun.
Alaric
Normally I would create an ST file contianing a look up table of the strings 01/ 02/ 03/ 04/ 05/ 06/ 07/... 10/ 11/ 12/ 13/... 31/

But the ML doesn't support indirect addressing on strings. I suppose you could use brute force, but maybe using a mathematical method is shorter. Anyways, I've attached how I do it in SLCs and included something that might work for the ML.



Clay B.
Found one other way to do the job on a ML1500. What I do is put each componet of the date in its own string location. Then I do a compare to the len value of each string. If the len is 1 I combine that string to a fixed string with a 0 in it.

Ugh. I can not attach a sample. will try again tomorrow.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.