×
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

date algorthim for an Allen Bradley PLC

date algorthim for an Allen Bradley PLC

date algorthim for an Allen Bradley PLC

(OP)
Does any one know of an algorithm for converting the date stored in the S2 status file to the day of the week? I have been toying with this and am having dificulty trying to truncate and find the mod ie the remainder of a division while trying to program this PLC-5.thanks again folks
THE KAT

RE: date algorthim for an Allen Bradley PLC

First we'll assume dates in the Gregorian calendar that fall between 01/01/1800 to 12/31/9999.  All math must be 16-bit integer math.  If you use floating point numbers, the answer won't be correct.  In the PLC-5, you can use a series of CPT commands.  For example, the first one: Dest=N7:10 Expression=(14.0 - S:20) | 12.0.  The next CPT Dest= N7:11 Expression= S:18 - N7:10. The next CPT Dest= N7:12 Expression=(S:19 + (12 * N7:10)) - 2. And the final CPT Dest= N7:13 Expression= ((((S:20 + S:18) + (S:18 | 4)) - (S:18 | 100)) + (S:18 | 400)) + (((31 * S:19) | 12) MOD 7).

N7:13 contains the answer.  0=Sunday thru 6=Saturday.

RE: date algorthim for an Allen Bradley PLC

Sorry, I had a small mistake in the last CPT command.  The expression should read ((((S:20 + N7:11) + (N7:11 | 4)) - (N7:11 | 100)) + (N7:11 | 400)) + (((31 * N7:12) | 12) MOD 7)

RE: date algorthim for an Allen Bradley PLC

(OP)
Rdub,
thanks for the help but every time I attempt to use the MOD function in the program my PLC crashes horifically and I think the basic equations may be off as I attempted to work them by hand and was unable to come up with a sufficient answer.But thanks again for your time.
TTFN
THE KAT

RE: date algorthim for an Allen Bradley PLC

Sorry to hear that you are having problems.  Unfortunately, I do not have a PLC-5 here to verify this code.  Note that all division must be integer division.  If you verify this equation using your calculator, the answer will be incorrect since your calculator using floating point division.  Also, The MOD instruction is only used in Enhanced PLC-5 Series C Revision C and later processors.
This equation was obtained from the web site http://www.tondering.dk/claus/cal/calendar26.html. ...;

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