(please read first the previous article. It describes the basics)
The possibility of controlling the power sockets, although it is not used as often as controlling the lights, is very handy:
1. When going to bed I press one button to switch off the power in the socets used by the stereo, PC, TV etc. The analysis of the power consumption has shown that the at standby all these appliances use electric energy. Shutting the power of at night takes a bit off the energy bill.
I use the function block Fb_LatchingRelay – the same as for the lights. The difference is – it works in the opposite direction: turning it on (xAxtuator=TRUE) means cutting the power off. IT means that the power is normally – while the relay is neutral – on.
Here is the code:
SOCKET1(xCentON:=IN1, xCentOFF:=(Timers.SOCKET1_ONsignal AND NOT ON_HOLIDAY) OR IN2);
When the button connected to IN1 is pressed, the SOCKET1 function block returns TRUE and the power is cut off. The current comes back (the Fb is off) after receiving a signal from SOCKET1_ONsignal – a timer from a separate process – if we are not on holiday i.e. the variable ON_HOLIDAY is FALSE. The socket can also be switched on manually by the button connected to IN2.
2. My bathroom has many Windows and a partially glass-roof. In the winter we use an electric heater to bring the temperature slightly up. To have it already higher when walking into the bathroom in the morning, the heater is controlled by a clock closing the circuit 20 minutes before the first visitor comes it. The heater can also be turned on manually. The power will automatically go off after 10 minutes unless there is no light in the room, in which case the turning of the last light off, turns the heater off as well.
SOCKET1_DELAY(xInput:=OUT1, dwTon_10tel_s:=6000, dwToff_10tel_s:=1);
SIGNAL_LIGHTS_OFF(CLK:=OUT2 OR OUT3 OR OUT4); (*OUT2-4 światła w łazience*)
SOCKET1(xSwitch:= IN1 OR VIS_SOCKET1, xCentON:=Timers.SOCKET1_ONsignal, xCentOFF:=SIGNAL_LIGHTS_OFF.Q OR (SOCKET1_DELAY.xOutput AND NOT (OUT2 OR OUT3 OR OUT4)) OR Timers.SOCKET1_OFFsignal);
The heater will be on after receiving a signal from IN1 or visualization (VIS_SOCKET1) or a timer SOCKET1_ONsignal from the Timers process. The central powering off will happen after receiving a signal of the last light going off (SIGNAL_LIGHTS_OFF) or the timer SOCKET1_DELAY clicks after 10 minutes (but only if there are no lights on) or after receiving a signal from SOCKET1_OFFsignal from the Timers process.