Wochentag

T

TedescoA

Guest
Zuviel Werbung?
-> Hier kostenlos registrieren
Kann mir jemanden in der FUP-Sprache zeigen, wie man den Wochentag berechnet.
Wie die Umschaltung von Sommer und Winterzeit erfolgt und
wie man die Schaltjahre berechnet( Schaltjahre "ja" dann 29.Februar wenn "nein" dann 28.Februar).

Danke für Hilfe
 
Zuletzt bearbeitet:
Die SPS-Systemuhr kann mit dem SFC1 ausgelesen werden.
Am besten eine Temp-Variable vom Typ Date_and_Time anlegen (in meinem Beispiel "ZEIT" ab Adresse 0.0).

CALL SFC 1
RET_VAL:=#Rueckgabe_Fehler
CDT :=#ZEIT

//Stunde
L LB 3
BTI
T DB51.DBW 2

//Minute
L LB 4
BTI
T DB51.DBW 4

//Sekunde
L LB 5
BTI
T DB51.DBW 6

//Tag
L LB 2
BTI
T DB51.DBW 8

//Monat
L LB 1
BTI
T DB51.DBW 10

//Jahr
L LB 0
BTI
T DB51.DBW 12

//Wochentag
L LW 7
SLW 4
SRW 4
T LW 7
L LB 7
BTI
T DB51.DBW 14

Der Wochentag wird in meinem Beispiel im DB51.DBW14 gespeichert (So=1, Mo=2.....Sa=7)

Eine Sommer-/Winterzeitumschaltung sollte danach auch kein Problem mehr sein (wenn Wochentag, Monat, Stunde == Zeitpunkt für Umschaltung => Stunde mit dem SFC0 vor- bzw zurückstellen).

Die Schaltjahre werden glaube ich bei der CPU-Sytemuhr berücksichtigt. Bin mir aber nicht 100-prozentig sicher.
 
Zuletzt bearbeitet:
der wochentag steht im ob1 im LB19
oder mit fc7 aus den iec den wt aus dt rausziehen.

suche hier im forum nach sommerzeit. hatten wir schon

warum nutzt ihr nicht die suchfunktion. faule bande. :twisted:
 
Zuviel Werbung?
-> Hier kostenlos registrieren
Arbeitsfreie Tage

Hallo,

zur Ermittlung des Osterdatums kann dieser Baustein einmal täglich aufgerufen werden. Die ersten beiden Netzwerke sind übler Spagetticode, sehen aber in KOP auch nicht besser aus. Beim Ausprobieren beachten: Nach Zurückstellen der CPU-Zeit wird der OB nicht neu aufgerufen!

Code:
[FONT=Arial]ORGANIZATION_BLOCK [/FONT][FONT=Arial]OB[/FONT][FONT=Arial] 11[/FONT]
[FONT=Arial]TITLE = "Time of Day Interrupt"[/FONT]
[FONT=Arial]VERSION : 0.1[/FONT]
 
 
[FONT=Arial]VAR_TEMP[/FONT]
[FONT=Arial]OB11_EV_CLASS : BYTE ;    //Bits 0-3 = 1 (Coming event), Bits 4-7 = 1 (Event class 1)[/FONT]
[FONT=Arial]OB11_STRT_INFO : BYTE ;   //16#12 ([/FONT][FONT=Arial]OB[/FONT][FONT=Arial] 11 has started)[/FONT]
[FONT=Arial]OB11_PRIORITY : BYTE ;    //Priority of OB Execution[/FONT]
[FONT=Arial]OB11_OB_NUMBR : BYTE ;    //11 (Organization block 11, OB11)[/FONT]
[FONT=Arial]OB11_RESERVED_1 : BYTE ;  //Reserved for system[/FONT]
[FONT=Arial]OB11_RESERVED_2 : BYTE ;  //Reserved for system[/FONT]
[FONT=Arial]OB11_PERIOD_EXE : WORD ;  //Period of execution (once, per minute/hour/day/week/month/year)[/FONT]
[FONT=Arial]OB11_RESERVED_3 : INT ;   //Reserved for system[/FONT]
[FONT=Arial]OB11_RESERVED_4 : INT ;   //Reserved for system[/FONT]
[FONT=Arial]OB11_DATE_TIME : DATE_AND_TIME ;  //Date and time OB11 started[/FONT]
[FONT=Arial]Oster_Date_Time : DATE_AND_TIME ; [/FONT]
[FONT=Arial]Oster_Datum : DATE ;  [/FONT]
[FONT=Arial]Aktuell_Datum : DATE ;    [/FONT]
[FONT=Arial]a : DINT ;    [/FONT]
[FONT=Arial]b : DINT ;    [/FONT]
[FONT=Arial]c : DINT ;    [/FONT]
[FONT=Arial]d : DINT ;    [/FONT]
[FONT=Arial]e : DINT ;    [/FONT]
[FONT=Arial]END_VAR[/FONT]
[FONT=Arial]BEGIN[/FONT]
[FONT=Arial]NETWORK[/FONT]
[FONT=Arial]TITLE =Datum für Ostersonntag nach Gauss bis 2089[/FONT]
 
[FONT=Arial]  L     LB    12; [/FONT]
[FONT=Arial]  BTI   ; [/FONT]
[FONT=Arial]  L     L#2000; [/FONT]
[FONT=Arial]  +D    ; [/FONT]
[FONT=Arial]  T     #d; [/FONT]
[FONT=Arial]L     L#19; [/FONT]
[FONT=Arial]  MOD   ; [/FONT]
[FONT=Arial]  T     #a; [/FONT]
[FONT=Arial]  L     #d; [/FONT]
[FONT=Arial]  L     L#4; [/FONT]
[FONT=Arial]MOD   ; [/FONT]
[FONT=Arial]  T     #b; [/FONT]
[FONT=Arial]  L     #d; [/FONT]
[FONT=Arial]  L     L#7; [/FONT]
[FONT=Arial]  MOD   ; [/FONT]
[FONT=Arial]T     #c; [/FONT]
[FONT=Arial]  L     #a; [/FONT]
[FONT=Arial]  L     L#19; [/FONT]
[FONT=Arial]  *D    ; [/FONT]
[FONT=Arial]  L     L#24; [/FONT]
[FONT=Arial]  +D    ; [/FONT]
[FONT=Arial]  L     L#30; [/FONT]
[FONT=Arial]  MOD   ; [/FONT]
[FONT=Arial]T     #d; [/FONT]
[FONT=Arial]  L     #b; [/FONT]
[FONT=Arial]  L     #b; [/FONT]
[FONT=Arial]  +D    ; [/FONT]
[FONT=Arial]  T     #b; [/FONT]
[FONT=Arial]  L     #c; [/FONT]
[FONT=Arial]  L     L#4; [/FONT]
[FONT=Arial]  *D    ; [/FONT]
[FONT=Arial]  T     #c; [/FONT]
[FONT=Arial]  L     #b; [/FONT]
[FONT=Arial]  L     #c; [/FONT]
[FONT=Arial]  +D    ; [/FONT]
[FONT=Arial]  T     #b; [/FONT]
[FONT=Arial]  L     #d; [/FONT]
[FONT=Arial]  L     L#6; [/FONT]
[FONT=Arial]  *D    ; [/FONT]
[FONT=Arial]  T     #e; [/FONT]
[FONT=Arial]  L     #b; [/FONT]
[FONT=Arial]  L     #e; [/FONT]
[FONT=Arial]  +D    ; [/FONT]
[FONT=Arial]  L     L#5; [/FONT]
[FONT=Arial]  +D    ; [/FONT]
[FONT=Arial]  L     L#7; [/FONT]
[FONT=Arial]  MOD   ; [/FONT]
[FONT=Arial]  T     #e; [/FONT]
[FONT=Arial]  L     #d; [/FONT]
[FONT=Arial]  +D    ; [/FONT]
[FONT=Arial]  T     #b; [/FONT]
 
[FONT=Arial]NETWORK[/FONT]
[FONT=Arial]TITLE =Ostertermin als Date_and_Time zwischenspeichern[/FONT]
 
[FONT=Arial]O(    ; [/FONT]
[FONT=Arial]  L     #b; [/FONT]
[FONT=Arial]  L     L#35; [/FONT]
[FONT=Arial]  ==D   ; [/FONT]
[FONT=Arial]  )     ; [/FONT]
[FONT=Arial]  O     ; [/FONT]
[FONT=Arial]  U(    ; [/FONT]
[FONT=Arial]  L     #d; [/FONT]
[FONT=Arial]L     L#28; [/FONT]
[FONT=Arial]  ==D   ; [/FONT]
[FONT=Arial]  )     ; [/FONT]
[FONT=Arial]  U(    ; [/FONT]
[FONT=Arial]  L     #e; [/FONT]
[FONT=Arial]  L     L#6; [/FONT]
[FONT=Arial]  ==D   ; [/FONT]
[FONT=Arial]  )     ; [/FONT]
[FONT=Arial]  U(    ; [/FONT]
[FONT=Arial]L     #a; [/FONT]
[FONT=Arial]  L     L#10; [/FONT]
[FONT=Arial]  >D    ; [/FONT]
[FONT=Arial]  )     ; [/FONT]
[FONT=Arial]  L     #b; [/FONT]
[FONT=Arial]  L     L#16; [/FONT]
[FONT=Arial]  -D    ; [/FONT]
[FONT=Arial]ITB   ; [/FONT]
[FONT=Arial]  T     LB    22; [/FONT]
[FONT=Arial]  L     4; [/FONT]
[FONT=Arial]  T     LB    21; [/FONT]
[FONT=Arial]  SPB   M_00; [/FONT]
[FONT=Arial]  L     #b; [/FONT]
[FONT=Arial]  L     L#9; [/FONT]
[FONT=Arial]  -D    ; [/FONT]
[FONT=Arial]  ITB   ; [/FONT]
[FONT=Arial]  T     LB    22; [/FONT]
[FONT=Arial]  L     #b; [/FONT]
[FONT=Arial]  L     L#9; [/FONT]
[FONT=Arial]  >D    ; [/FONT]
[FONT=Arial]  SPB   M_00; [/FONT]
[FONT=Arial]  L     #b; [/FONT]
[FONT=Arial]  L     L#22; [/FONT]
[FONT=Arial]  +D    ; [/FONT]
[FONT=Arial]  ITB   ; [/FONT]
[FONT=Arial]  T     LB    22; [/FONT]
[FONT=Arial]  L     3; [/FONT]
[FONT=Arial]  T     LB    21; [/FONT]
[FONT=Arial]M_00: L     LB    12; [/FONT]
[FONT=Arial]  T     LB    20; [/FONT]
[FONT=Arial]NETWORK[/FONT]
[FONT=Arial]TITLE =Bewegliche Feiertage ermitteln für Bundesland Hessen[/FONT]
[FONT=Arial]// Standard Library, IEC Function Blocks, FC 6 DT_DATE IEC[/FONT]
[FONT=Arial]  CALL "DT_DATE" ([/FONT]
[FONT=Arial]       IN                       := #Oster_Date_Time,[/FONT]
[FONT=Arial]       RET_VAL                  := #Oster_Datum);[/FONT]
[FONT=Arial]  CALL "DT_DATE" ([/FONT]
[FONT=Arial]IN                       := #OB11_DATE_TIME,[/FONT]
[FONT=Arial]       RET_VAL                  := #Aktuell_Datum);[/FONT]
 
[FONT=Arial]  R     "Arbeitsfreie Feiertage"; //Platzhalter[/FONT]
[FONT=Arial]  L     #Aktuell_Datum; [/FONT]
[FONT=Arial]  L     #Oster_Datum; [/FONT]
[FONT=Arial]  -I    ; [/FONT]
[FONT=Arial]  L     -2; [/FONT]
[FONT=Arial]  ==I   ; [/FONT]
[FONT=Arial]  S     "Arbeitsfreie Feiertage"; //Karfreitag[/FONT]
[FONT=Arial]  TAK   ; [/FONT]
[FONT=Arial]  L     0; [/FONT]
[FONT=Arial]  ==I   ; [/FONT]
[FONT=Arial]  S     "Arbeitsfreie Feiertage"; //Ostern[/FONT]
[FONT=Arial]  TAK   ; [/FONT]
[FONT=Arial]  L     1; [/FONT]
[FONT=Arial]  ==I   ; [/FONT]
[FONT=Arial]  S     "Arbeitsfreie Feiertage"; //Ostermontag[/FONT]
[FONT=Arial]  TAK   ; [/FONT]
[FONT=Arial]  L     39; [/FONT]
[FONT=Arial]  ==I   ; [/FONT]
[FONT=Arial]  S     "Arbeitsfreie Feiertage"; //Himmelfahrt[/FONT]
[FONT=Arial]  TAK   ; [/FONT]
[FONT=Arial]  L     49; [/FONT]
[FONT=Arial]  ==I   ; [/FONT]
[FONT=Arial]  S     "Arbeitsfreie Feiertage"; //Pfingsten[/FONT]
[FONT=Arial]  TAK   ; [/FONT]
[FONT=Arial]  L     50; [/FONT]
[FONT=Arial]  ==I   ; [/FONT]
[FONT=Arial]  S     "Arbeitsfreie Feiertage"; //Pfingstmontag[/FONT]
[FONT=Arial]  TAK   ; [/FONT]
[FONT=Arial]  L     60; [/FONT]
[FONT=Arial]  ==I   ; [/FONT]
[FONT=Arial]  S     "Arbeitsfreie Feiertage"; //Fronleichnam[/FONT]
[FONT=Arial]NETWORK[/FONT]
[FONT=Arial]TITLE =Fest datierte Feiertage und sonstige arbeitfreie Tage[/FONT]
 
 
[FONT=Arial]  L     LW    13; [/FONT]
[FONT=Arial]  L     W#16#101; [/FONT]
[FONT=Arial]  ==I   ; [/FONT]
[FONT=Arial]  S     "Arbeitsfreie Feiertage"; //Neujahr[/FONT]
[FONT=Arial]  TAK   ; [/FONT]
[FONT=Arial]  L     W#16#501;[/FONT]
[FONT=Arial]  ==I   ; [/FONT]
[FONT=Arial]  S     "Arbeitsfreie Feiertage"; //1.Mai[/FONT]
[FONT=Arial]  TAK   ; [/FONT]
[FONT=Arial]  L     W#16#1003; [/FONT]
[FONT=Arial]  ==I   ; [/FONT]
[FONT=Arial]  S     "Arbeitsfreie Feiertage"; //3.Oktober[/FONT]
[FONT=Arial]  TAK   ; [/FONT]
[FONT=Arial]  L     W#16#1224; [/FONT]
[FONT=Arial]  ==I   ; [/FONT]
[FONT=Arial]  S     "Arbeitsfreie Feiertage"; //Heiligabend[/FONT]
[FONT=Arial]  TAK   ; [/FONT]
[FONT=Arial]  L     W#16#1225; [/FONT]
[FONT=Arial]  ==I   ; [/FONT]
[FONT=Arial]  S     "Arbeitsfreie Feiertage"; //Weihnachten[/FONT]
[FONT=Arial]  TAK   ; [/FONT]
[FONT=Arial]  L     W#16#1226; [/FONT]
[FONT=Arial]  ==I   ; [/FONT]
[FONT=Arial]  S     "Arbeitsfreie Feiertage"; //2.Weihnachtstag[/FONT]
[FONT=Arial]  TAK   ; [/FONT]
[FONT=Arial]  L     W#16#1231; [/FONT]
[FONT=Arial]  ==I   ; [/FONT]
[FONT=Arial]  S     "Arbeitsfreie Feiertage"; //Sylvester[/FONT]
 
 
[FONT=Arial]END_ORGANIZATION_BLOCK[/FONT]
 
Zuletzt bearbeitet:
Zurück
Oben