This is a wiki article and can be improved by everyone. Please do!
Problem Statement
How to control roller shutters / roller blinds / sun-blinds from Logo using wall-switches and in parallel from openHAB?
Concept
Assuming the roller shutter drive (motor) can be controlled from 2 relay-outputs of Logo. One Logo-output controls the upwards-direction, the other controls the downwards-direction. Simple roller shutters do not provide any information of the current position, but have end-switches that assure the shutter stops at the top/bottom endpoints.
Solution
Here is a screenshot of what the result looks like.
LOGO! Configuration (LOGO! SoftComfort Diagram Editor)
To control one rollo shutter the following UDF (user defined function) shall be used in your logo program.
Find the UDF for Logo7 attached RolladenMotor_L7.pdf (3.8 KB) Rename pdf to zip!
The UDF for Logo8: RolladenMotor.pdf Rename pdf to zip!
Pulse on input I_UP drives the rollo high, pulse on I_DO drives the rollo down. The time rollo must be driven, are given by UDF parameters T_UP and T_DO respectively.
As long as output O_UP is high, the rollo drives up.
O_UP goes low for the 2 following conditions:
- After the time T_UP has passed or
- O_UP is high AND new pulse is send to I_UP (manual stop).
Output IS_UP is set high, if pulse was send to I_UP and time T_UP has passed.
This works equivalent for I_DO, O_DO and IS_DO.
Additionally the UDF calculates the rollo’s position between 0 and 100 percent, as required by openHAB. Some safety is given too: It is not possible to set O_UP and O_DO high at the same time. Remember this is a software lock only. It is much better to lock the hardware additionally.
The scaling factor is not really self-explanatory. I set it to max(T_Up, T_Do) * 100. Example: If T_Up is 17 seconds and T_Do 15 seconds, then T_Sc will be 1700. That’s right: Counting is more or less precise for one direction only.
Some like, that rollos must be opened completely and closed with some gaps. Knowing each motor has physical endpoints: driving up long enough will certainly reach the upper end-point. But for driving down, the time must be measured to stop the rollo at the desired position.
In your Logo program connect the UDF like this:
The UDF (here Block U001) exposes a value named ‘Pos’, which is the current position of the rollo shutter (position is simulated and actually derived and calculated from timers).
Create a VM (variable memory) for the Pos-value, a word-value with the address 34 (as an example).
Things
Bridge plclogo:device:Logo7 "Logo7 PLC" [ address="192.168.xxx.yyy", family="0BA7", localTSAP="0x0200", remoteTSAP="0x0200", refresh=1000 ]
{
Thing digital Inputs "Logo7 Inputs" [ kind="I" ]
Thing digital Outputs "Logo7 Outputs" [ kind="Q" ]
// Rollo1
Thing pulse VB101_0 [ block="VB101.0", observe="VB101.0", pulse=500 ] // NI1 rollo control-bit pulse up
Thing pulse VB101_1 [ block="VB101.1", observe="VB101.1", pulse=500 ] // NI2 rollo control-bit pulse down
Thing memory VW34 [ block="VW34"] // rollo position memory value-word
}
Items
Switch RolloHi { channel="plclogo:pulse:Logo7:VB101_0:state" } // pulse to start Rollo up
Switch RolloDo { channel="plclogo:pulse:Logo7:VB101_1:state" } // pulse to start Rollo down
Switch RolloHiActive { channel="plclogo:digital:Logo7:Outputs:Q1" } // Logo relay for motor up
Switch RolloDoActive { channel="plclogo:digital:Logo7:Outputs:Q2" } // Logo relay for motor down
Number RolloPosition { channel="plclogo:memory:Logo7:VW34:value" } // rollo's position (0% for completely open, 100% completely closed)
Rollershutter Rollo "Rollo XY" <rollershutter>
Sitemap (default.sitemap)
sitemap default label="Home" {
Frame label="Rolloshutters" icon="attic" {
//Default item=RolloHi
//Default item=RolloDo
//Default item=RolloHiActive
//Default item=RolloDoActive
//Default item=RolloPosition
Switch item=Rollo
}
}
Rules (logo_rollo.rules)
// you may need these imports
import org.eclipse.smarthome.core.types.Command
//import org.eclipse.smarthome.core.types.RefreshType
import org.eclipse.xtext.xbase.lib.Procedures
val Procedures$Procedure4<Command, SwitchItem, SwitchItem, Command>
LogoRolloLogic = [ Command ReceivedCommand, SwitchItem Up, SwitchItem Down, Command Direction |
switch(ReceivedCommand) {
case UP: {
Up.sendCommand(OnOffType.ON)
}
case DOWN: {
Down.sendCommand(OnOffType.ON)
}
case STOP: {
if (Direction == UP) {
Up.sendCommand(OnOffType.ON)
} else if (Direction == DOWN) {
Down.sendCommand(OnOffType.ON)
} else if (Direction != STOP) {
logDebug("LogoRolloLogic", "Direction " + Direction + " is not supported.")
}
}
}
]
rule "RolloPosChanged"
when
Item RolloPosition changed
then
var Number value = RolloPosition.state as Number
Rollo.postUpdate(Math.max(Math.min(value.intValue, 100), 0)) // return a number in the range of 0 to 100.
end
rule "RolloDrive"
when
Item Rollo received command
then
var Command dir = STOP
if (RolloHiActive.state == OnOffType.ON) { dir = UP }
else if (RolloDoActive.state == OnOffType.ON) { dir = DOWN }
LogoRolloLogic.apply(receivedCommand, RolloHi, RolloDo, dir)
end
Revision History
- March 2019: original post for openHAB version 2.4 with Logo 0BA7
Troubleshooting
- Rollo shutter Position behaves somehow funny.
Next Ideas
- Hardware-Lock for outputs: One relay controls the direction and another switches power (230V) on or off.
- The program could be extended to calculate rest time when driving from a current (known) position.