Time and Date Operations for IEC

See also: IEC 61131 Language Editor Programming

See also: Project Toolbox for IEC

 

Topic Menu

 

Power Flow through the Element

When the current RTC time / day / date / month / year of OCS is between the input given, power is passed through the element to its output, which can be used to set or clear an indicator coil.

 

For example:

Element Inputs Given Power Flower
Time of Day

Start time: 11:45

End time : 16:45

The power will be passed when the RTC time in

the OCS is between 11:45 and 16:45 everyday.

Days of Week Monday, Wednesday and Friday

The power will be passed on Mondays, Wednesdays

and Fridays of every week.

Days of Month 5, 15 and 25 The power will be passed on 5th, 15th and 25th of every month.
Months of Year January, July

The power will be passed from 1st to 31st January

and 1st to 31st July of every year.

Start and End Year Start Year: 2019 End Year: 2021 The power will be passed from year 2019 to 2021.

 

 

Days of Month in IEC

Also called: DaysOfMonth

 

The Days of Month element compares the current date of the month with the input and passes power when the current date is one of the inputs. The values represent each date from 1 to 31st. In case of register type and offset, a 32 bit register is used for representing all dates with each bit of the register representing one date.

 

For example: 

  • BIT 1 - 1st of the month

  • BIT 31 - 31st of the month

 

ST Language

Q1:= DaysOfMonth (Days) ; (*UDINT*)

 

FBD Language

 

LD Language

 

IL Language

 

Return to the Top: Time and Date Operations for IEC

 

Days of Week in IEC

Also called: Days Of Week

 

The Days of week element compares the current day of the week with the input and passes power when the current day is one of the inputs. The values represent each day from Sunday (1) to Saturday (7). In case of register type and offset, a 16 bit register is used for representing all days with each bit of the register representing one day

 

For example:

  • BIT 1 - Sunday

  • BIT 7 – Saturday

 

ST Language

Q4:= DaysOfWeek (Days1); (*INT*)

 

FBD Language

 

LD Language

 

IL Language

 

Return to the Top: Time and Date Operations for IEC

 

Months of Year in IEC

Also called: MonthsOfYear

 

The Months of Year element compares the current month of the year with the input and passes power when the current month is one of the inputs. Each value represents a month from January (1) to December (12)In case of register type and offset, a 16 bit register is used for representing all months with each bit of the register representing one month.

 

For example:

  • BIT 1 - January

  • BIT 12 – December

 

ST Language

Q2:= MonthsOfYear (Months) ; (*INT*)

 

FBD Language

LD Language

 

 

IL Language

 

Return to the Top: Time and Date Operations for IEC

 

Year in IEC

Also called: STARTENDYEAR

 

The Start and End Year element compares the current year with the inputs and passes power when the current year is between the inputs. Start and end values can be directly entered. In case of register type and offset, a 32 bit register is used for specifying start and end year. The higher 16 bits represent end year and the lower 16 bits represent the start year.

 

ST Language

Q3:= StartEndYear (Years) ; (*DINT*)

 

FBD Language

 

LD Language

 

IL Language

 

Return to the Top: Time and Date Operations for IEC

 

Time of Day in IEC

Also called: TimeOfDay

 

The Time of Day element compares the current time with the start and end time values. If the current time is between the start time and end time, power is passed. The inputs can be fixed or can be entered using address registers.

 

ST Language

Q5:=TimeOfDay (StartHour (*INT*), StartMin (*INT*), EndHour (*INT*), EndMin (*INT*));

 

FBD Language

 

LD Language

 

IL Language

 

Return to the Top: Time and Date Operations for IEC

 

Set Clock in IEC

Also called: SetClk

 

Operator – Sets the clock, with the specified values.

 

Inputs

IN[ ] : Array of 6 elements, holds value in the form of SS MM HH, DD MM YYYY format. (TYPE : INT[])

 

Outputs

Q : This is set to TRUE if the operation of setting the clock is successful. (TYPE: BOOL)

 

ST Language

Q := SetClk (IN[]) ;

 

FBD Language

 

LD Language

 

 

IL Language

Not Supported

Return to the Top: Time and Date Operations for IEC

 

Get Sun Position in IEC

Also called: SONPOS

This block is only supported in Enhanced IEC Mode.

Operator - The solar azimuth and solar zenith express the position of the sun. The solar azimuth is the angle of the direction of the sun measured clockwise north from the horizon. The solar zenith is the angle measured from the local zenith and the line of sight of the sun.

The altitude and azimuth values are for the center of the apparent disk of the Sun or Moon.

The altitude values include the effect of standard atmospheric refraction when the object is above the horizon.

The azimuth values are computed with respect to true north (not magnetic).

Zenith and Azimuth Angle Calculation Based On Current Time

 

Inputs

YEAR: Input the values of Year (TYPE: INT)

MONTH: Input the values of Month (TYPE: INT)

DAY: Input the values of Day (TYPE: INT)

HOURS: Input the values of Hours (TYPE: INT)

MINUTES: Input the values of minutes (TYPE: INT)

SECONDS: Input the values of Seconds (TYPE: INT)

LATITUDE: Input the values of Latitude (TYPE: LREAL)

LONGITUDE: Input the values of Longitude (TYPE: LREAL)

 

Outputs

AZIMUTH: Input the values of Longitude (TYPE: LREAL)

ZENITH: Input the values of Longitude (TYPE: LREAL)

 

LD Language:

(* spb is a declared instance of SUNPOS function block *)

FBD Language:

IL Language:

ST Language:

Return to the Top: Time and Date Operations for IEC