PLC3 Day of Week

ControlJoe

Member
Join Date
Jan 2011
Location
Salt Lake City
Posts
5
I am working with an ancient PLC-3 and I want to set a bit based off the day (Wednesday) and time (noon) of the week.

I have the following words that represent components of the date:

S1:0 = year, S1:1 = month, S1:2 = day, S1:3 = hours, S1:4 = minutes, S1:5 = seconds, S1:6 = milliseconds.

Any idea on how I could use ladder logic to set a bit after noon on Wednesday arrives?

Thanks in advance
- Joe
 
S1:2 = Wednesday and S1:3 = > or =12 then set your Bit true.

I think S1:2 is day of the month (or are you just being funny?):whistle:

So either add a lookup table for the foreseeable future or use an external device with comms to the PLC to set the bit...

I've never even seen a PLC-3, so I might be all wet...

:)
 
Day of month

OkiePC: Thank you for the correction. S1:2 is the day of month. I believe I will be stuck writing code that will determine the Wednesdays for the foreseeable future, but I am having trouble visualizing this. I have no idea how to build a lookup table.

Oceansoul: The Problem with the PLC3 is each of the following words: Year, month, day of month, hours, minutes, seconds and milliseconds are represented by an integer and not a string. So the day of the month, for example, is a value from 1-31 for January.
 
OkiePC: Thank you for the correction. S1:2 is the day of month. I believe I will be stuck writing code that will determine the Wednesdays for the foreseeable future, but I am having trouble visualizing this. I have no idea how to build a lookup table.

Oceansoul: The Problem with the PLC3 is each of the following words: Year, month, day of month, hours, minutes, seconds and milliseconds are represented by an integer and not a string. So the day of the month, for example, is a value from 1-31 for January.


Aye, i new this but unfortunately had a mental mind moment. :lol:
 
Fairly straightforward bit of maths (except the MOD function!!).

' **************************************************
' * *
' * WEEKDAY.BAS *
' * *
' * Calculates Day of Week from Date *
' * Using Zeller's Congruence *
' * *
' * Returns 0=Sun, 1=Mon, 2=Tue, ... 6=Sat *
' * *
' * Compile using QuickBasic 4.5 *
' * *
' * Judson D McClendon *
' * Sun Valley Systems *
' * 4522 Shadow Ridge Pkwy *
' * Pinson, AL 35126 *
' ' * *
' **************************************************
'
DECLARE FUNCTION WeekDay (Month AS INTEGER, Day AS INTEGER, Year AS INTEGER)
DIM Month AS INTEGER, Day AS INTEGER, Year AS INTEGER, DOW AS INTEGER

INPUT "Enter Date: MM,DD,YYYY: ", Month, Day, Year
DOW = WeekDay(Month, Day, Year)
PRINT MID$("SunMonTueWedThuFriSat", DOW * 3 + 1, 3)
END

FUNCTION WeekDay (Month AS INTEGER, Day AS INTEGER, Year AS INTEGER)
DIM M AS INTEGER, D AS INTEGER, Y AS INTEGER
IF (Month < 3) THEN
Y = Year - 1
M = Month + 12
D = Day
ELSE
Y = Year
M = Month
D = Day
END IF
WeekDay = ((13 * M + 3) \ 5 + D + Y + Y \ 4 - Y \ 100 + Y \ 400 + 1) MOD 7
END FUNCTION
Notes:
I just tried this in Excel, and it works....
"\" is Integer Divide
MOD can be done by subtracting 7 until the result is less than 7 (JMP->LBL)
 
Last edited:
Fairly straightforward bit of maths (except the MOD function!!).



Notes:
I just tried this in Excel, and it works....
"\" is Integer Divide
MOD can be done by subtracting 7 until the result is less than 7 (JMP->LBL)

That's simple enough, I would definitely do this in favor of a lookup table...
 
That's simple enough, I would definitely do this in favor of a lookup table...

Just need to be careful of how the PLC3 "Integer Divides", e.g. does it use an "Integer Maths" calculator and truncates the result, or does it do the calculation and rounds the result.

Been a long time since PLC3 and can't remember how exactly it functions.

The Excel forumalae I used, ....

c6=INT((13*M+3)/5)
c7=C6+D+Y
c8=C7+INT(Y/4)
c9=C8-INT(Y/100)
c10=C9+INT(Y/400)
c11=C10+1
c12=MOD(C11,7)
 
Is there an HMI connected to the PLC? I have used a Red Lion HMI to pass a bit to the PLC based upon the day of the week. This was a lot easier then using the PLC.
 
If you wanted real simple, you could use a counter which increments at midnight and self-resets at 7 days. Of course, this method would not be accurate through a power-down of more than a day and would probably be wrong after a download.
 

Similar Topics

We are replacing a PLC3 with a new ControlLogix. There is an existing mainframe application that communicates with the PLC3 via a 1770-KF2 (DF1...
Replies
1
Views
2,382
I have an iFIX system to upgrade that has and SLC504 and PLC3 on DH+. The current system uses an ABR driver and RSLinx with a KTX card. We have to...
Replies
0
Views
3,323
It seems simple - doesn't it? :banghead: Perhaps I have been spoiled with Omron? :p A few things I must say before I pose any questions -...
Replies
14
Views
17,115
I receive an "internal error" when exporting a PLC3 program from 6200 s/w. the .txt file contains 13 lines of correctly exported data until it...
Replies
3
Views
2,375
I am trying to use DosBox to run AB A.I. software on a XP machine. The software runs but it can't access the activation files. Any ideas? Any...
Replies
14
Views
6,825
Back
Top Bottom