×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

BASIC Program

BASIC Program

BASIC Program

(OP)
I need to write a program that will send out the Modified Julian Date to a part marker.  I will use the PLC date to calculate MJD.

I am thinking of using a lookup table, but want to field a few suggestions first.

Any ideas anyone.

RE: BASIC Program

If you use a lookup table what will you do with a leap year? Could you use some sort of incrementing counter that will reset on Jan 1 each year , then increment at 12:00 midnight. Then you use the year and the incremented date for you MJD.

RE: BASIC Program

(OP)
Sorry I should have been more specific.  I will use 2 tables one for leap year and one for non-leap.  

The only concern I have for counter is if the processor is placed in program mode during the time the date should change.

RE: BASIC Program

That is true and if the PLC is off for long periods of time. May be use the month as a quick reference then add whatever day of the month it is. For example if it is Mar 3 you would add 3 to 60(end of feb) for MJD of 63. Then you determine leap years and add a 1if the date is after Feb.

RE: BASIC Program

(OP)
Sounds interesting.

Thanks

RE: BASIC Program

You would have 11 move statements, depending on the month value from the PLC date. Move the correct value for the previous month into a register. Add the day value of the date of the current month to the register and that should give you your MJD. For a leap year you can program several compares to determine if the current year is a leap year. If it is you would just add 1 for any month date from 3 to 11.

RE: BASIC Program

Additional comment this is probably similar to what you would need to do to provide the index value for your lookup table.

RE: BASIC Program

(OP)
OK the program is done and has been tested.  I built two lookup tables, one for leap years and one for non-leap years.  The data took the form of Month, StartDay.  I also had to determine if the current year was a leap year, the BASIC module did not support MOD division so I divided the year by 4 and if there was a remainder I used the non-leap look up table.

The module used was the 1746-BAS T module, using PBASE to program.  PBASE has a nice translation feature that allows the program to be writen without line numbers.  This was usefull in that the source code is easier to understand.  

There is supposed to be a C translator available but I couldn't find it, C is much better to write code with.

Thanks to all for feedback.

RE: BASIC Program

Calculation of the Gregorian date (which is easily  
convertible to Julian) :

Nd ( # of day for Sun. to Sat.) = 0 to 6
Nm ( # of month, Jan to Dec, 1 digit ea. )
       = 400 351 362 402  spaced for readability.
Ny ( # of year, 0 to 6 ) e.g. for 1949 and 2005 = 1
'''  After each year and in a leapyear after Feb. 29, too
    Ny=Ny+1: if Ny>6 then Ny=Ny-7
    Nd = (Ny +Nm + D) mod 7

e.g. Nd(12/25/2005) = (1+2+25) mod 7 =28 mod 7=0 => Sunday

<nbucska@pcperipherals DOT com> subj: eng-tips

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources