Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

BASIC Program

Status
Not open for further replies.

jonesy29847

Electrical
Feb 28, 2003
133
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.
 
Replies continue below

Recommended for you

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

 
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.
 
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.
 
Additional comment this is probably similar to what you would need to do to provide the index value for your lookup table.
 
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.
 
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor