SwitchTimeS (FB)

FUNCTION_BLOCK SwitchTimeS

Short Description

Timer with 5 adjustable time periods and binary output
Each time period is defined by a switch-on/ switch-off time and a date

Portrayal

../_images/SwitchTimeS_FB.png

Interfaces

Inputs

Name

Datatype

Range

Init-Value

Function

xEn BOOL    

Enable input

Outputs

Name

Datatype

Range

Init-Value

Function

xActive BOOL    

Active time periods

todActivatedFrom TOD    

Switch-on time of the last active time period for the current day

todActivatedTo TOD    

Switch off time of the last active time period for the current day

Setpoints / Parameters

Name

Datatype

Range

Init-Value

Function

datCH1_Date DATE   DATE#2017-01-01

Date of the Time period 1

todCH1_TimeFrom TOD   TOD#07:00

Switch-on time of the time period 1

todCH1_TimeTo TOD   TOD#12:00

Switch-off time of the time period 1

xCH1_Mode BOOL   TRUE

Mode of display for time period 1

sCH1_Notice STRING  

‘Custom note - click to change.’

Text for time period 1

datCH2_Date DATE   DATE#2017-01-01

Date of the time period 2

todCH2_TimeFrom TOD   TOD#07:00

Switch-on time of the time period 2

todCH2_TimeTo TOD   TOD#12:00

Switch-off time of the time period 2

xCH2_Mode BOOL   TRUE

Mode of display for time period 2

sCH2_Notice STRING  

‘Custom note - click to change.’

Text for time period 2

datCH3_Date DATE   DATE#2017-01-01

Date of the time period 3

todCH3_TimeFrom TOD   TOD#07:00

Switch-on time of the time period 3

todCH3_TimeTo TOD   TOD#12:00

Switch-off time of the time period 3

xCH3_Mode BOOL   TRUE

Mode of display for the time period 3

sCH3_Notice STRING  

‘Custom note - click to change.’

Text for time period 3

datCH4_Date DATE   DATE#2017-01-01

Date of the time period 4

todCH4_TimeFrom TOD   TOD#07:00

Switch-on time of the time period 4

todCH4_TimeTo TOD   TOD#12:00

Switch-off time of the time period 4

xCH4_Mode BOOL   TRUE

Mode of display for the time period 4

sCH4_Notice STRING  

‘Custom note - click to change.’

Text for time period 4

datCH5_Date DATE   DATE#2017-01-01

Date of the time period 5

todCH5_TimeFrom TOD   TOD#07:00

Switch-on time of the time period 5

todCH5_TimeTo TOD   TOD#12:00 Ausschaltzeitpunkt der Zeitperiode 5
xCH5_Mode BOOL   TRUE

Mode of display for the time period 5

sCH5_Notice STRING  

‘Custom note - click to change.’

Text for the time period 5

Functional Description

General

The current point in time (date / time) is permanently compared with the 5 defined time periods.
The xActive display output assumes the TRUE status if at least one of the 5 time periods is active when the enable input (xEn = TRUE) is active.

Enabling input xEN

xEn xActive todActivatedFrom todActivatedTo

Notes

FALSE FALSE

unchanged

unchanged

FB deactivated

TRUE

Status depending on the 5 time periods

Switch-on time of the last active time period for the current day

Switch off time of the last active time period for the current day

FB activated

Display output xActive

The display output assumes the TRUE status if at least one of the 5 time periods is active when the enable input (xEn = TRUE) is active.
xActive xEn

Time period 1

Time period 2

Time period 3

Time period 4

Time period 5

Notes

FALSE FALSE X X X X X

FB deactivated

FALSE TRUE FALSE FALSE FALSE FALSE FALSE

No time period is active

TRUE TRUE FALSE FALSE TRUE FALSE FALSE

At least one time period active

Switch-on point in time of the last active time period of the todActivatedFrom the current day

This display output assumes the value of the switch-on point in time of the last active time period, if, when enable input is active (xEn = TRUE), the date of the
current time coincides with the date of the time period.

Switch-off point in time of the last active time period of the todActivated from the current day

This display output assumes the value of the switch-off point in time of the last active time period, if, when enable input is active (xEn = TRUE), the date of the
current time coincides with the date of the time period. It is not changed in all other situations.

Time periods 1 - 5 (X = 1 ..5)

Each time period is defined by configurable data ( todCHX_TimeFrom switch-on point in time, todCHX_TimeTo switch-off point in time and datCHX_Date date )
In addition, an operating mode ( xCHX_Mode ) as well as a descriptive text ( sCHX_Notice ) can be specified.
If the switch-off point in time is before the switch-on point in time, then the switch-off point in time is set to the value of the switch-on point in time for the test.
A time period is active if the current date matches the date of the time period and the time is within the time period (xCHX_Mode = TRUE).
A time period is active if the current date matches the date of the time period and the time is outside the time period (xCHX_Mode = FALSE).

Visualization




Information

Element

Authors

Date

Version

Notes

Function

Adam Bartod 09.2016 1.0

Initial version

Programming

Adam Bartod 09.2016 1.0

Initial version

Test Jochen Reu 09.2017 1.0

Initial version

Documentation

Jochen Reu 10.2017 1.0

Initial version

Codesys

InOut:
Scope Name Type Initial Comment
Input xEn BOOL  

Enable input

datCH1_Date DATE DATE#2017-1-1

Date of the Time period 1

todCH1_TimeFrom TOD TIME_OF_DAY#7:0

Switch-on time of the time period 1

todCH1_TimeTo TOD TIME_OF_DAY#12:0

Switch-off time of the time period 1

xCH1_Mode BOOL TRUE

Mode of display for time period 1

sCH1_Notice STRING

‘Custom note - click to change.’

 
datCH2_Date DATE DATE#2017-1-1

Date of the time period 2

todCH2_TimeFrom TOD TIME_OF_DAY#7:0

Switch-on time of the time period 2

todCH2_TimeTo TOD TIME_OF_DAY#12:0

Switch-off time of the time period 2

xCH2_Mode BOOL TRUE

Mode of display for time period 2

sCH2_Notice STRING

‘Custom note - click to change.’

 
datCH3_Date DATE DATE#2017-1-1

Date of the time period 3

todCH3_TimeFrom TOD TIME_OF_DAY#7:0

Switch-on time of the time period 3

todCH3_TimeTo TOD TIME_OF_DAY#12:0

Switch-off time of the time period 3

xCH3_Mode BOOL TRUE

Mode of display for the time period 3

sCH3_Notice STRING

‘Custom note - click to change.’

 
datCH4_Date DATE DATE#2017-1-1

Date of the time period 4

todCH4_TimeFrom TOD TIME_OF_DAY#7:0

Switch-on time of the time period 4

todCH4_TimeTo TOD TIME_OF_DAY#12:0

Switch-off time of the time period 4

xCH4_Mode BOOL TRUE

Mode of display for the time period 4

sCH4_Notice STRING

‘Custom note - click to change.’

 
datCH5_Date DATE DATE#2017-1-1

Date of the time period 5

todCH5_TimeFrom TOD TIME_OF_DAY#7:0

Switch-on time of the time period 5

todCH5_TimeTo TOD TIME_OF_DAY#12:0 Ausschaltzeitpunkt der Zeitperiode 5
xCH5_Mode BOOL TRUE

Mode of display for the time period 5

sCH5_Notice STRING

‘Custom note - click to change.’

 
Output xActive BOOL  

Active time periods

todActivatedFrom TOD  

Switch-on time of the last active time period for the current day

todActivatedTo TOD  

Switch off time of the last active time period for the current day