Rollershutter Reloaded!
Here comes a rollershutter solution that leaves no wishes open (I hope).
Example / Functionality / Operation:
- short Down-button: Q2 drives down for 5s / press again, drives down for the same time
- long Down-button: Q2 drives down for 10s
- short Up-button: Q1 drives up for 15s
- short press any button any time stops motor
- 500ms delay between changing motor direction
- long press opposite button changes motor direction
- continue or change direction at any time
- emergency stop down (for door open sensor), normally LOW
- updates Position (0% - 100%) correctly for up/down direction
- Feature: slow update of Position (at 1s or more) good enough for polling Logo by openHAB
FInd the UDF for Logo8 and a Logo test-program here (rename to zip):
Rollershutter_L8.zip.pdf (31.7 KB)
The test-program looks like this:
Do not forget to configure the VM for the âPositionâ:
![Rollershutter_LogoSoft_VM-Config](//community-openhab-org.s3.dualstack.eu-central-1.amazonaws.com/original/3X/4/d/4d88fb393f95f15e49ac2edd172318b01576535b.jpeg)
Things
Bridge plclogo:device:Logo8 "Logo8 PLC" [ address="192.168.xxx.yyy", family="0BA8", localTSAP="0x2700", remoteTSAP="0x0300", refresh=1000 ]
{
Thing digital Inputs "Logo8 Inputs" [ kind="I" ]
Thing digital Outputs "Logo8 Outputs" [ kind="Q" ]
// Rollo1
Thing memory VW0 "Logo8 VW0" [ block="VW0"] // rollo position memory value-word
Thing memory NI1_VB100_0 "Rollo1 ButtonUp" [ block="VB100.0", force=false ] // NI1 rollo control-bit memory button up
Thing memory NI2_VB100_1 "Rollo1 ButtonDown" [ block="VB100.1", force=false ] // NI2 rollo control-bit memory button down
}
Items
// Rollo1
Number Rollo1_Position "Rollo1 Position" { channel="plclogo:memory:Logo8:VW0:value" } // rollo's position (0% for completely open, 100% completely closed)
Switch Rollo1_ButtonUp { channel="plclogo:memory:Logo8:NI1_VB100_0:state" } // for button up
Switch Rollo1_ButtonDown { channel="plclogo:memory:Logo8:NI2_VB100_1:state" } // for button down
Switch Rollo1_goingUp "Q5" { channel="plclogo:digital:Logo8:Outputs:Q5" } // Logo relay for motor up
Switch Rollo1_goingDown "Q6" { channel="plclogo:digital:Logo8:Outputs:Q6" } // Logo relay for motor down
Rollershutter Rollo1 "Rollo Room1" <rollershutter>
Rules
// 3 imports otherwise error in the line with 'Direction == UP' (ref. openHAB log)
import org.eclipse.smarthome.core.types.Command
// import org.eclipse.smarthome.core.types.RefreshType
import org.eclipse.xtext.xbase.lib.Procedures
// you need this routine only once (for multiple rollerhuttrs)
val Procedures$Procedure4<Command, SwitchItem, SwitchItem, Command>
LogoRolloLogic = [ Command ReceivedCommand, SwitchItem Up, SwitchItem Down, Command Direction |
switch(ReceivedCommand) {
case UP: {
Up.sendCommand(OnOffType.ON)
Thread::sleep(100) // create pulse
Up.sendCommand(OnOffType.OFF)
logInfo("LogoRolloLogic", "Direction: " + Direction + ". UP received.")
}
case DOWN: {
Down.sendCommand(OnOffType.ON)
Thread::sleep(100) // create pulse
Down.sendCommand(OnOffType.OFF)
logInfo("LogoRolloLogic", "Direction: " + Direction + ". DOWN received.")
}
case STOP: { // depending on driving up or down, push the corresponding button (may avoids immediate direction change, if pulse is too long)
logInfo("LogoRolloLogic", "Direction: " + Direction + ". STOP received.")
if (Direction == UP) {
Up.sendCommand(OnOffType.ON) // perform stop by sending Up-command if going up
Thread::sleep(100) // create pulse
Up.sendCommand(OnOffType.OFF)
} else if (Direction == DOWN) {
Down.sendCommand(OnOffType.ON) // perform stop by sending Down-command if going down
Thread::sleep(100) // create pulse
Down.sendCommand(OnOffType.OFF)
} else if (Direction != STOP) { // do not send an up/down command if already stopped
logDebug("LogoRolloLogic", "Direction " + Direction + " is not supported.")
}
}
}
]
// repeat the following 2 rules for each additional rollerhutter
// Rollo1
rule "Rollo1PosChanged"
when
Item Rollo1_Position changed
then
var Number value = Rollo1_Position.state as Number
Rollo1.postUpdate(value.intValue) // return Position
end
rule "Rollo1Drive" // set direction and start driving up/down
when
Item Rollo1 received command
then
var Command dir = STOP
if (Rollo1_goingUp.state == OnOffType.ON) { dir = UP }
else if (Rollo1_goingDown.state == OnOffType.ON) { dir = DOWN }
LogoRolloLogic.apply(receivedCommand, Rollo1_ButtonUp, Rollo1_ButtonDown, dir)
end
// start_up rule will be added later
Sitemap
sitemap default label="Haus" {
Frame label="Rollershutters" {
// debug info
Text item=Rollo1_ButtonUp label="Rollo1_NI1_ButtonUp [%s]" valuecolor=[OFF="red", ON="green"] icon=switch // this hides the switcher-control
Text item=Rollo1_ButtonDown label="Rollo1_NI2_ButtonDown [%s]" valuecolor=[OFF="red", ON="green"] icon=switch
Text item=Rollo1_goingUp label="Rollo1_Q5_goingUp [%s]" valuecolor=[OFF="red", ON="green"] icon=switch
Text item=Rollo1_goingDown label="Rollo1_Q6_goingDown [%s]" valuecolor=[OFF="red", ON="green"] icon=switch
Default item=Rollo1_Position
// debug info
Switch item=Rollo1
}
}
Here is what you get (sitemap):
This is considered perfect now (does not use pulse-thing). No flaws, no issues.
Please check and feedback before I post it in âSolutions, Tutorialsâ.
Arnd