Day of week in structured text

PFrog

Member
Join Date
Apr 2011
Location
Ohio
Posts
83
Hello,


I am currently doing a project in structured text and would like to get the calendar dates from the processor. I did import a DayOfWeek_ST AOI from rockwell, but am not really all that familiar with setting them up (especially in ST).


Is there a more straightforward way of doing this? Does anyone have some example code on how they call/run something like this in ST?

L36ERM processor with 5000 ver 30.



Thanks
 
It does appear the AOI I downloaded just returns the day for the system date. So maybe only partially usable as I would need both the day and the date. I am trying to get production counts broken down by the day/shift.
 
I was having trouble using the GSV command, but I did get it to work. Had to use a couple commas with a blank for instance in the setup. A syntax thing.
 
I currently have the data coming in with the GSV command. I am trying to link that data to the AOI I downloaded.



How do I run the AOI from structured text, and how would I best link the variables?


Would I be better off running the GSV within the AOI, or is there a way to link the local AOI tags to the controller scope tags (I'm sure there is, I am still searching for it).
 
Code:
(*  Day of Week Routine - 
    This version compensates for leap years and non-leap years, as well as the oddball leap century.

To use this routine, create a DINT array of 12 elements called "MonthValue", and assign it as follows:
MonthValue[0] := 0, 3, 3, 6, 1, 4, 6, 2, 5, 0, 3, 5
The final value, DayOfWeek is just that, Sunday = 0, Monday = 1, etc.
*)

Year         := GL_WC_Time[0];
Month         := GL_WC_Time[1];
DayOfMonth     := GL_WC_Time[2];
Curr_Hour    := GL_WC_Time[3];
Curr_Minute    := GL_WC_Time[4];


IF (((Year MOD 4) = 0) AND NOT ((Year MOD 100) = 0)) OR ((Year MOD 400) = 0)
THEN 
    MonthValue[0] := 6;
    MonthValue[1] := 2;
ELSE
    MonthValue[0] := 0;
    MonthValue[1] := 3;
End_If;

DayOfWeek := (DayOfMonth + MonthValue[Month-1] + (Year MOD 100) + ((Year MOD 100) / 4) + 6) MOD 7;


GL_WC_Time[] is my DINT array polling the system clock.
 
Thanks. I used that logic and it appears to be working. I am trying to populate dates in a spreadsheet type screen with part counts for the shifts. Using this logic I can say if the day is equal to friday put the date next to it. However, I'm not certain if I could run it out to populate future dates. For instance, I couldn't say just add/subtract one to get the future/previous date on the spreadsheet. Still looking into it. Thanks again.
 
Again PlantPAx has Date/Time AOIs.


I'll take a look at that. I'm still working through figuring out structured text... Calling the AOI, and then having the AOI use the data from the controller tags that are pulling the clock/date data from the controller. These areas are a little gray to me, as I have not used AOI's before, nor have set them up within ST (which appears to be a little more complicated).


I will look into it though.


Thanks
 
To learn it. It's actually turning out pretty well. Quite a few devices on it. Little bit of a mix of everything, but it's all ST.


You can, of course, use AOI's written in any of the four available languages. They don't have to be in ST just because the rest of the application is. Probably preferable to use one that is written, verified, and tested, rather than trying to "roll-your-own" in a language you are not 100% familiar with.



The AOI is just another "instruction" to be used in the rest of your application.
 

Similar Topics

Hi All, I'd like to know can we use DTR instruction to get a week pulse ? Could anyone please help me to understand that one ? I've managed to...
Replies
4
Views
177
The day of week program started changing day of week 2 hours early. It changes at 10 P.M. instead of 12A.M. Just started this year.
Replies
22
Views
2,654
For some reason that I do not understand, FactoryTalk is showing the Day of Week in the time and date display, despite the fact that this isn't an...
Replies
5
Views
1,221
This is the reason why I signed up here and decided to get some help before I tackle the traffic light program on Wednesday. It looked good on...
Replies
17
Views
11,686
Hey everyone. I am trying to create some logic that will turn on an output only during production times. M-F 5am to 3:30pm. The output is for...
Replies
3
Views
1,358
Back
Top Bottom