PLCnext on Instagram  PLCnext on YouTube Github PLCnext CommunityStore PLCnext Community


 How to create a Blog Entry

VDI 3813 Stairwell FB with PLCnext Engineer

The following Makers Blog consists of the Stairwell Light functionality as stated in the VDI 3813 directive


This directive consists of descriptions, ways to do room automation in order to increase the energy efficiency of a building.


Stairwell Light FB

Functionality of this block is as the title already gives a hint, to regulate lights in stairwells of your building. 

Depending on an input trigger to turn the lights on, these will be ON at your wanted Dimming Value.

After x amount of time when no longer in need of light, the lights will switch OFF.

With this additional feature that you can send a 1-time blinking of the lights, to warn the people that in x amount of seconds/minutes the lights in the stairwell will be switched off. 

This gives the user an indication to push the nearest light switch again so the light doesn't turn off , while they are still present in the stairwell.

PLCnext Engineer Function Block:


INPUTS explained:


This will start the Function Block and Send the rDim Value to the Output


The wanted dimming value for the Stairwell (0-100%)


Holding Time before definitely turning OFF the light ( if xStart does not get re-triggered )


Warning Time, is the amount of seconds/minutes before he definitely turning OFF of the lights when you want the light to blink 1 time to warn the people in the stairwell that soon the lights will turn OFF if no re-trigger is performed.

OUTPUTS explained:

rDimOutValue: This is the dimming value sended to the Lights in the stairwell


PLCnext Engineering Structure Text Code of the FB_Stairwell-Vdi3813:

// Function Block for Stairwell lighting following the VDI 3813 Directives for building Automation

// Trigger Start
R_TRIG_Start(CLK := xstart);


// Initiate FB after Start Trigger


iCnt := Int#0 ;
xStartWarningTimer := FALSE ;
xStartHoldingTimer := FALSE ;
xBlinkedDone := FALSE ;
xWait := TRUE ;


// Additional waiting step

iStairwell := INT#1;

CASE iStairwell OF

0: // Initiate values
iCnt := Int#0 ;
rDimOutValue := REAL#0.0 ;
xStartWarningTimer := FALSE ;
xStartHoldingTimer := FALSE ;
xBlinkedDone := FALSE ;

1: // wait for Activation trigger to write the dim value to the output and start the Holding Timer
xWait := FALSE ;
xStartWarningTimer := TRUE ;
xStartHoldingTimer := TRUE ;
iStairwell := Int#2 ;


2: // Holding Timer is started and waiting for the Warning Timer to turn active and give a 1 time blink at the output
IF NOT TON_HoldingTimer.Q THEN

rDimOutValue := rDimValueChosen ;

IF TON_WarningTimer.Q AND NOT xBlinkedDone THEN

iStairwell := Int#3;


ELSE iStairwell := Int#0 ;

3: // Blink Output once and return to Holding Timer

rDimOutValue := REAL#0.0 ;
iCnt := iCnt + Int#1 ;

IF iCnt >= Int#10 THEN

xBlinkedDone := TRUE ;
iStairwell := Int#2 ;



(************************** Instances **************************)


// Timers

// Determination if inputs tHoldingTime & tWarningTime are valid

IF (tHoldingTime > tWarningTime) AND (tHoldingTime > T#6s) THEN
xInitValueValidTimers := TRUE ;
ELSE xInitValueValidTimers := FALSE;

IF xInitValueValidTimers THEN

tHoldingTimerTime := tHoldingTime ;
tWarningTimerTime := SUB_TIME( tHoldingTime , tWarningTime );

ELSIF NOT xInitValueValidTimers AND (tHoldingTimerTime >= T#5s) THEN

tHoldingTimerTime := tHoldingTime ;
tWarningTimerTime := SUB_TIME( tHoldingTime , T#5s );


// Determination if input Dim level is a valid value between 0-100%

IF rDimSetValue > Real#100.0 THEN
rDimValueChosen := Real#100.0 ;

ELSIF rDimSetValue < Real#0.0 THEN

rDimValueChosen := Real#0.0 ;

ElSE rDimValueChosen := rDimSetValue ;
// Warning Time= Moment when the output should blink 1 time to indicate turning off Output Value
TON_WarningTimer(IN := xStartWarningTimer, PT := tWarningTimerTime, ET => tElapseWarning );

// Holding Time = Duration until the timer should stop, switch off Output
TON_HoldingTimer(IN := xStartHoldingTimer, PT := tHoldingTimerTime , ET => tElapseHolding);

// Wait Timer
TON_Wait(IN := xWait, PT := T#1s );


If you would like to have this FB, feel free to contact me at This email address is being protected from spambots. You need JavaScript enabled to view it.