Setting and hardware
In one of the rooms there are windows on the Southern and Western walls. They can be covered with blinds (Blind 1 controlled through OUT1 and OUT2, Blind 2 controlled through OUT3 and OUT4). On the Western wall there is a 2-button bell-switch (Buttons 1 and 2 connected to IN1 and IN2). On the opposite, Eastern wall there is also a 2-button bell-switch (Buttons 11 and 12 connected to IN11 and IN22).
There is also a light sensor using 24VDC powered through OUT10 and if light intensity exceeds the given level, returning a signal to IN10.
Functionality
The switch on the Western wall (near one of the windows) is used to 'traditionally' control the blinds. A short press on a button (1) triggers a movement up of a blind. Another short click during a movement stops it. A long press triggers a downward movement.
The button on the opposite wall near the door is used to control the lights. Additionally a long press of the button 11 moves both blinds down to a preset position. A long press of button 22 moves both blinds up.
The possibility of moving the blinds to a 'preset position' is worth considering because it enables a quick:
- moving blind to (for example) the middle of the windows to make same shade on a sunny day,
- moving blinds to an 'almost closed' position, i.e. when the bits are not tightly closed but there are spaces between them letting some light in. We use it when the kids have a mid-day nap.
With the use of buttons 11 and 22 I have the possibility to - depending on the time of the year and the configured 'preset position' - to set 'scenes' or to open both blinds instantly without the need of even entering the room too far.
Additionally there is a possibility of moving the blinds up or down according to sun rise/set. Usually in the winter period the blinds move down at the sunset and move up at 07:00.
Moreover the blinds move automatically to a 'shade' position if during summer the sun is in a given position, the light senor detect intense light and the temperature in the room is higher the preset maximum.
The code in variable definitions:
VAR Shade_TemperatureTOF : TOF:=(PT:=T#1h); Shade_Flag : BOOL; Shade_Enabled, WINTER : BOOL; SunSignal : BOOL; SunRise : F_TRIG; SunSet : F_TRIG; Blind_Room1_S_1, Blind_Room1_S_2: FbScheduleWeekly; Blind_R1_Timer_On : R_TRIG; Blind_R1_Timer_Off : F_TRIG; SWITCH_IN1, SWITCH_IN2 : Fb_ShortLong:=(uiTS_10tel_s:=1, uiTL_10tel_s:=1, uiT_10tel_s:=5); SWITCH_IN11, SWITCH_IN22 : Fb_ShortLong:=(uiTS_10tel_s:=1, uiTL_10tel_s:=1, uiT_10tel_s:=10); BLIND_ROOM1_UP, BLIND_ROOM1_DOWN : BOOL; END_VAR VAR RETAIN PERSISTENT Shade_MinTemp: BYTE:=21; Blind_R1_Data1, Blind_R1_Data2: typScheduleWeekly; Blind_Room1_1_Input : BLIND_INPUT:=(PI:=150, MAX_RUNTIME:=T#25s, MANUAL_TIMEOUT:=t#60m, MASTER_MODE:=TRUE); Blind_Room1_1_Shade : BLIND_SHADE_S:=(HORZ1:=100, HORZ2:=215, SHADE_POS:=150, SHADE_DELAY:=T#5m); Blind_Room1_1_Control : BLIND_CONTROL_S:=(T_UP:=T#23s, T_DN:=T#22s); Blind_Room1_2_Input :BLIND_INPUT:=(PI:=150, MAX_RUNTIME:=T#25s, MANUAL_TIMEOUT:=t#60m, MASTER_MODE:=TRUE); Blind_Room1_2_Shade : BLIND_SHADE_S:=(HORZ1:=160, HORZ2:=280, SHADE_POS:=150, SHADE_DELAY:=T#5m); Blind_Room1_2_Control : BLIND_CONTROL_S:=(T_UP:=T#23s, T_DN:=T#22s); END_VAR
Where:
The code in the program:
(*Temerature test and Sunlight sensor*) Shade_TemperatureTOF(IN:=SensorReader.TEMPERATURE_ROOM1/10>Shade_MinTemp); Shade_Flag:=Shade_Enabled AND Shade_TemperatureTOF.Q AND NOT WINTER; OUT10:=Shade_Flag; SunSignal:=IN10; (*Sunrise and Sunset definition*) SunRise(CLK:=ReadClock.Calendar.SUN_VER<ReadClock.SunRise_Angle); SunSet(CLK:=ReadClock.Calendar.SUN_VER>ReadClock.SunSet_Angle); (*Schedulers*) Blind_Room1_S_1(xEnable:=TRUE, dtActualTime:=CURRENT_TIME, typScheduleWeekly:=Blind_R1_Data1); Blind_Room1_S_2(xEnable:=TRUE, dtActualTime:=CURRENT_TIME, typScheduleWeekly:=Blind_R1_Data2); (*Triggers for Schedulers*) Blind_R1_Timer_On (CLK:=Blind_Rom1_S_1.xSwitchChannel OR Blind_Room1_S_2.xSwitchChannel); Blind_R1_Timer_Off(CLK:=Blind_Room1_S_1.xSwitchChannel OR Blind_Room1_S_2.xSwitchChannel); (*Short/Long Swittches*) SWITCH_IN1(xSwitch:=IN1); SWITCH_IN2(xSwitch:=IN2); SWITCH_IN11(xSwitch:=IN11); SWITCH_IN22(xSwitch:=IN22); (*Handling of Schedulers and central switches*) BLIND_ROOM1_UP:=SWITCH_IN22.xLong OR Blind_R1_Timer_On.Q AND VIS_Management.LightButtons[0,0]) OR SunRise.Q AND VIS_Management.LightButtons[0,1]); BLIND_S_DOWN:=(Blind_R1_Timer_Off.Q AND VIS_Management.LightButtons[1,0]) OR SunSet.Q AND VIS_Management.LightButtons[1,1]); (*Blind in Room1 from the South*) Blind_Room1_1_Input( S1:=SWITCH_IN1.xShort OR VIS_B_R1_1_UP OR BLIND_ROOM1_UP, S2:=SWITCH_IN1.xLong OR VIS_B_R1_1_DOWN OR BLIND_ROOM1_DOWN, IN:=SWITCH_IN11.xLong OR VIS_B_R1_1_POS, POS:=Blind_Room1_1_Control.POS ); Blind_Room1_1_Shade( UP:=Blind_Room1_1_Input.QU, DN:=Blind_Room1_1_Input.QD, S_IN:=Blind_Room1_1_Input.STATUS, pi:=Blind_Room1_1_Input.PO, ENABLE:=Shade_Flag, SUN:=SunSignal, CX:=ReadClock.Calendar ); Blind_Room1_1_Control( UP:=Blind_Room1_1_Shade.QU, DN:=Blind_Room1_1_Shade.QD, S_IN:=Blind_Room1_1_Shade.STATUS, pi:=Blind_Room1_1_Shade.PO ); OUT1:=Blind_Room1_1_Control.MU; OUT2:=Blind_Room1_1_Control.MD; (*Blind in Room1 from the West*) Blind_Room1_2_Input( S1:=SWITCH_IN2.xShort OR VIS_B_R1_2_UP OR BLIND_ROOM1_UP, S2:=SWITCH_IN2.xLong OR VIS_B_R1_2_DOWN OR BLIND_ROOM1_DOWN, IN:=SWITCH_IN11.xLong OR VIS_B_R1_2_POS, POS:=Blind_Room1_2_Control.POS ); Blind_Room1_2_Shade( UP:=Blind_Room1_2_Input.QU, DN:=Blind_Room1_2_Input.QD, S_IN:=Blind_Room1_2_Input.STATUS, pi:=Blind_Room1_2_Input.PO, ENABLE:=Shade_Flag, SUN:=SunSignal, CX:=ReadClock.Calendar ); Blind_Room1_2_Control( UP:=Blind_Room1_2_Shade.QU, DN:=Blind_Room1_2_Shade.QD, S_IN:=Blind_Room1_2_Shade.STATUS, pi:=Blind_Room1_2_Shade.PO ); OUT3:=Blind_Room1_2_Control.MU; OUT4:=Blind_Room1_2_Control.MD;
Where:
Example of visualizations: