S7 SCL WeekDay

svoicum

Member
Join Date
Sep 2006
Location
Cluj
Posts
43
Hello again... maybe this problem was solved, but i can't seem to find the answer. i obtained the date and time form my plc (using Read_CLK) and i have the WeekDay as BCD (B#16#xx). how do i obtain the weekday from this type of data? i need to get the 4 LSB, but i don't know how to obtain them. please help me... thx...
i also have this code:FUNCTION FC 215 : VOID
TITLE =System clock
//: Get system clock components as integers
AUTHOR : KH
FAMILY : 'TIME'
NAME : SYS_RTC
VERSION : 1.0


VAR_OUTPUT
Year : INT ; //System clock: Year
Month : INT ; //System clock: Month
Day : INT ; //System clock: Day
Hour : INT ; //System clock: Hour
Minute : INT ; //System clock: Minute
Second : INT ; //System clock: Second
mS : INT ; //System clock: Millisecond
DayOfWeek : INT ; //System clock: Day of week
END_VAR
VAR_TEMP
SFC1_RetVal : INT ; //Temp variable for SFC1 return value
DateTime : DATE_AND_TIME ; //Temp variable for current date & time
END_VAR
BEGIN
NETWORK
TITLE =
//Ranges:
//Year 0 - 99
//Month 1 - 12
//Day 1 - 31
//Hour 0 - 23
//Minute 0 - 59
//Second 0 - 59
//mS 0 - 999
//Day of Week 1 (Sunday) - 7 (Saturday)
CALL SFC 1 (
RET_VAL := #SFC1_RetVal,
CDT := #DateTime);

LAR1 P##DateTime;

L B [AR1,P#0.0];
BTI ;
T #Year;

L B [AR1,P#1.0];
BTI ;
T #Month;

L B [AR1,P#2.0];
BTI ;
T #Day;

L B [AR1,P#3.0];
BTI ;
T #Hour;

L B [AR1,P#4.0];
BTI ;
T #Minute;

L B [AR1,P#5.0];
BTI ;
T #Second;

L W [AR1,P#6.0];
SRW 4;
BTI ;
T #mS;

L B [AR1,P#7.0];
SLW 12;
SRW 12;
T #DayOfWeek;

//Set ENO & exit
SET ;
SAVE ;

END_FUNCTION
ALL CREDITS FOR THE CODE GO TO krk
so there is:
L B [AR1,P#7.0];
SLW 12;
SRW 12;
T #DayOfWeek;

but i work only in SCL so i don't understant it.
how can i translate it into SCL? can someone please help me?
 
Last edited:
svoicum said:
but i work only in SCL so i don't understant it.
how can i translate it into SCL? can someone please help me?

Rather than try to translate it to SCL you could have just compiled the FC as it is, used the component(s) you required and ignored the rest.
.
.
 
Last edited:

Similar Topics

HI i would like to know how to get a variable that will store the amount of times a program has been executed. The issue is I have 3 DBs for 1 FB...
Replies
2
Views
84
Hi, I have an intermediate-advance knowledge of programming with TIA Porta in Ladder, would you recommend me to start learning SCL for it to...
Replies
11
Views
568
Hello nice to meet you, im new in here, I'm currently trying to convert code written in STL for a S7-400 to SCL for an S7-1500, because when i run...
Replies
5
Views
335
Hi everyone, I am new to this amazing world of PLC, well... I mean, in practice, since I already knew electronics, programming languages, IT, and...
Replies
7
Views
656
Hi all, This is my first post; I am new to PLC Controls stuff and English is not my native language, so I apologize in advance if something is...
Replies
4
Views
514
Back
Top Bottom