4 digit Julian Date in RSLogix 5000??

TheStarr

Member
Join Date
Jan 2009
Location
Florida
Posts
383
Hi, my name is Marshall. Long time browser, first time poster!

I am looking for an elegant solution to a julian date problem. We have a label printer that encodes the julian date into the 2D Matrix ID (barcode).

It uses the "Juliandate" data type which worked fine for most of last year (it is a new machine), but now that we are in 2009, it does not add the zeros in front of the julian date.

Example: last year in December it said.... 3508, 350 being the day and 8 being the year.

Now this year we want 0059, but are getting just 59.

I need the julian date to always be 4 digits long. I don't see an easy way without writing a bunch of ugly code.

Any ideas???? Thanks in advance!
 
Hi
try this formula
JD=367*Y - INT(7*(Y + INT((M+9)/12))/4)
- INT(3*(INT((Y+(M-9)/7)/100)+1)/4)
+ INT(275*M/9) + D + 1721028.5

INT means integer.
Picked up from here and here

Also search Julian Date in this site.
 
WOW!!! I guess "Day of the year" is a more correct description of where I was going, being that the actual "Julian Date" number is huge!

Although the links help a ton and have given me a good idea of what the logic should look like.

Thanks manmeetvirdi!

P.S. I searched for julian date, but came up dry...
 
1. What did the printer do at this time last year?

2. Does the printer encode the date from an internal real time clock or do you send it the date?
 
You need to convert the number to a string, pre-pending physical zero's to the string if the number is less then "x"...
IE: LES DayNumber 1000 CONCAT DayString STR_Zero DayString
LES DayNumber 100 CONCAT DayString STR_Zero DayString
DTOS DayNumber TempString CONCAT DayString TempString DayString

Where DayNumber is your calculated dayte, STR_Zero is a constant string with the text '0', DayString is your output string, and TempString is a temporary string.
 
Marshall,
What if you just add a 1 to an integer file using a one shot every time the clock reaches 12am. Then monitor the year and when it changes you set the integer file back to 1. This will take care of leap year problems.
haven't given the zero thing any thought yet.
Dave G.
 
I think I have it. Take the int number and divide by 1000 then store it in a tag. Then use the Mid String command in the logix 5000 to strip out the dec point and the preceeding zero. 2 rungs of code.
 
It Works!!!

Turns out that the Machine Integrator used a faulty "User Defined" tag to calculate the Julian Date.

So I couldn't use their logic and had to make my own which wasn't in the original plan. But all the extra links you guys provided made it easy! And I learned a bunch.

Odlaw's idea to divide and then strip out the appropriate string with the preceding zeros worked great.

Best part, is very simple.

Here are some pictures that show all the logic and tags, I even added a bunch of comments explaining how everything works.

Thanks again to everybody for your input.

P.S. Make sure your system clock is set correctly before you insert the GSV (Get System Value)for the "wallclock" as it locks itself to whatever the time is when it is inserted.

Julian Logic 1.jpg Julian Logic 2.jpg Julian Tags.jpg
 
TheStarr said:
I need the julian date to always be 4 digits long

What are you going to do next year - when it will be 2010 ?

Will that just use 0 for the year, as in 0010 to 3650, like it was in 2000 ?
 
Yup, 0 (zero) for the year 2000, 2010, 2020, etc... That is the way the customer wants it.

We work in Automotive, so 10 years is like being in a different millennium!

Not much of a chance mixing up year 2000 parts with year 2010.

Although, putting a 2 or even 4 digit year would be easy.

For this format: 00709 (007 day of 2009)
- change rung 6 expression to: z_Day_of_the_Year*100+z_Current_Year-2000
- change rung 7 "source B" to 100000
- change rung 9 "Qty" to 5

For this format: 0072009 (007 day of 2009)
- change rung 6 expression to: z_Day_of_the_Year*10000+z_Current_Year
- change rung 7 "source B" to 10000000
- change rung 9 "Qty" to 7

FYI, you only need rung 1 thru 5 to calculate the Julian Date. The rest of the rungs are just creating and modifying a string that we output to a printer.

Also, I put the "z_" in front of all the tags so they would be together in the tag list. You could drop the "z_" and create a user defined data type to make it look real clean, but this way seemed more 'open' and easy for people to duplicate and debug later. K.I.S.S.!
 
TheStarr
Your pdf file which shows how to use RTC in RSLogix5000 turned out to be very usefull for me. Thanks for that.
But some problem out there to calculate Leap year. You need to use MOD instruction for this purpose.
 
I am glad someone got use out of it. Maybe the leap year calculation works different on different PLCs. Mine is on an AB CompactLogix and works well.
 
TheStarr in your leap year calculation you are doing the following

1)Movel z_wall_clock[0] to z_current_year

so z_current_year will be 2009

2)then you are computing: (z_current_year/4)*4=z_leap_year

so z_leap_year=2009

3)z_wall_clock[0]==z_leap_year

2009==2009

so z_leap_year_result bit will always remain ON for all years
 

Similar Topics

Good morning all, I'm integerating a device with a Rockwell PLC with V34 Studio 5000. The device reports error codes using a single integer to...
Replies
19
Views
1,286
Hi. I’m doing a PV 1400e to PVP 7 migration and I don’t know how to convert the old 8digit BCD type from PB1400e into something that will work on...
Replies
2
Views
589
Referencing KB document QA9877: "...FactoryTalk View SE Graphics supports single precision floating point values, and by default only provides...
Replies
4
Views
1,793
I am attempting to replace a single digit in string in studio 5000. I need to take the 23rd digit and change it from a 1 to a 5 while the rest of...
Replies
2
Views
1,551
Hello All, I have a Parker CTC touch screen Which connects with M340 Modicon plcs and also comunicates with a data aquisition computer using...
Replies
1
Views
1,556
Back
Top Bottom