PLCLogo Solution: Logo Output Switching

binding
Tags: #<Tag:0x00007f51eb370480>

(tv-arnd) #1

This is a wiki article and can be improved by everyone. Please do!

Problem Statement

How to switch a Logo-output for lights or power outlets via openHAB and in parallel via a physical wall-switch which is directly connected to a Logo-input? The status of the Logo-output shall be correctly monitored.

Concept

A proxy-item is used for the UI to store the on/off state (for visualisation) and for user-interaction. UI-commands are sent to the NI-item (pulse) which toggles the Logo’s relay (Q-output). Events originating from Logo (physical wall-switch pressed causing relay changes) will update the proxy-item by the rule. A rule triggered once at openHAB startup initializes the proxi-item and writes the current relay status into it.

Solution

Here is a screenshot of what the result looks like.
Logo_light_switch_sitemap

LOGO! Configuration (LOGO! SoftComfort Diagram Editor)
Logo_light_switch

Things (logo7.things)
In this example, the IP address 192.168.xxx.yyy represents the Logo device’s address and must be adapted.The TSAP parameters must be adjusted as well.

Bridge plclogo:device:Logo7 "Logo7 PLC" [ address="192.168.xxx.yyy", family="0BA7", localTSAP="0x0200", remoteTSAP="0x0200", refresh=1000 ]
{
  Thing  digital Outputs [ kind="Q" ]
  Thing pulse     VB100_1  "Logo7 NI4"  [ block="VB100.1", observe="VB100.1", pulse=200  ]
}

Items (logo7.items)

Switch  Logo7_Q12   "Licht Wand [%s]" <light>    { channel="plclogo:digital:Logo7:Outputs:Q12" }
Switch  Logo7_NI4   "NI4"    { channel="plclogo:pulse:Logo7:VB100_1:state" }
Switch  Wall_Light_proxy "Light Wall" <light> (Wall_proxy, gLight)

Rules (logo7.rules)

rule "Switch Light Wall Logo"
when
    Item Logo7_Q12 changed or                         // light changed external
    Item Wall_Light_proxy received command            // light changed internal
then
    if(receivedCommand==ON || receivedCommand==OFF) { // ensure there was a received command, so second item triggered rule
        if (Logo7_Q12.state != receivedCommand) {     // only if state changed
            Logo7_NI4.sendCommand(ON)                 // send a pulse
        }
    }
    else {                                                // no trigger from proxy switch, so state changed externally
        if (Logo7_Q12.state != Wall_Light_proxy.state) {  // if state changed really
            Wall_Light_proxy.postUpdate(Logo7_Q12.state)  // update the state without triggering the rule
        }
    }
end

rule "Startup"
when
   System started
then
   // logInfo("StartUp", "System startup: Logo states flushed into proxy switches")
   Wall_Light_proxy.postUpdate(Logo7_Q12.state)  // update the state at startup
end

Sitemap (default.sitemap)

sitemap default label="Home" {
Frame label="Light Switch" icon="attic" {
        Switch item=Wall_Light_proxy mappings=[OFF="AUS", ON="EIN"]
        Switch item=Logo7_NI4 label="Debug NI4 (do not touch)"  // remove this line
   }
}

Revision History

  • Janaury 2019: original post for openHAB version 2.4 with Logo 0BA7
  • February 2019: completely re-edited, this works nicely.

Troubleshooting

  • none

Next Ideas

  • none

Integrate Siemens Logo (plclogo) in OpenHAB 2
(tv-arnd) #2

Problem Statement

How to switch a Logo-output for lights or power outlets via openHAB and in parallel via a physical wall-switch. Logo shall use the comfort-switch block.

Concept

Like with the physical wall-switch (I21) the light shall be triggered ON (but permanently) and triggered OFF. Therefore the network-input (NI1) creates a short pulse, which is extended to 600ms. This is equivalent to a long-press of the wall-switch.

Solution

Here is a screenshot of what the result looks like.

LOGO! Configuration (LOGO! SoftComfort Diagram Editor)
example_light_switch_logo
Comfort-Switch B003 switches Q7 permanently, if pulse us longer than 500ms. A short pulse switches-on Q7 only for 20s. B033 to assure that pulse from NI1 is longer than 500m (e.g. 600ms).

Things (logo7.things)
In this example, the IP address 192.168.xxx.yyy represents the Logo device’s address and must be adapted.The TSAP parameters must be adjusted as well.

Bridge plclogo:device:Logo7 "Logo7 PLC" [ address="192.168.xxx.yyy", family="0BA7", localTSAP="0x0200", remoteTSAP="0x0200", refresh=200 ]
{
  Thing digital Inputs "Logo7 Inputs"    [ kind="I" ]
  Thing digital Outputs "Logo7 Outputs"  [ kind="Q" ]
  Thing pulse     VB100_0  "Logo7 NI1"  [ block="VB100.0", observe="VB100.0", pulse=500  ]
}

Items (logo7.items)

Switch  Logo7_Q7    "Licht Essen [%s]" <light>         { channel="plclogo:digital:Logo7:Outputs:Q7" }
Switch  Logo7_NI1   "NI1"    { channel="plclogo:pulse:Logo7:VB100_0:state" }
// virtual Switch
Switch          FF_Dining_Light            "Licht"               <light>            (FF_Dining, gLight)

Rules (logo7.rules)

rule "Switch Light through Logo"
when
    Item Logo7_Q7 changed or                         // 1. light changed external
    Item FF_Dining_Light received command            // 2. light changed internal
then
    if(receivedCommand==ON || receivedCommand==OFF) { // ensure there was a received command, so second item triggered rule
        if (Logo7_Q7.state != receivedCommand) {      // only if state changed
            Logo7_NI1.sendCommand(ON)                 // send an ON
           // Logo7_NI1.sendCommand(OFF)                // send an OFF, maybe not required
        }
    }
    else {                                             // no trigger from proxy switch, so state changed externally
        if (Logo7_Q7.state != FF_Dining_Light.state) { // if state changed really
            FF_Dining_Light.postUpdate(Logo7_Q7.state) // update the state without triggering the rule
        }
    }
end

Sitemap (default.sitemap)

sitemap default label="Home" {
Frame label="Light Switch" icon="attic" {
        Default item=FF_Dining_Light label="Light (switch here)"
        Text  item=Logo7_Q7 label="Debug Q7"
        Default item=Logo7_NI1 label="Debug NI1 (do not touch)"
   }
}

Revision History

  • January 2019: original post for openHAB version 2.4 with Logo 0BA7
  • March 2019: openHAB version 2.4, PLClogo binding snapsot 2.5.0 with Logo 0BA7

Troubleshooting

  • Seems a bit shaky when toggling Light switch, esp. when toggling fast (status hicks up). NI might stay ON permanently (reset logo = stop logo, upload the config again, start logo). Likely solution: pulse time should be longer than Logo-refresh time (status of light = display as light-bulb from proxy-switch might not show correct status. Re-trigger with button-press, corrects this.)
  • It does not read the initial state (if logo-light was already on, and then starting up openHAB). Solution: take rule for ‘System started’ from 1st example.

Next Ideas

  • Rebuild own comfort-switch (UDF) not requiring a certain pulse-length for permanent ON and a reset-input.

Integrate Siemens Logo (plclogo) in OpenHAB 2
Integrate Siemens Logo (plclogo) in OpenHAB 2
(Rossko57) #3

I don’t know Logo and am not quite sure what your rule is doing, but offer a possible alternative approach.

I have lighting controlled by by pulse relay types. There are physical push-on, push-off buttons for manual control.
openHAB has an Item for a simulated pushbutton, and another Item monitoring the light circuit actual state (on or off).

I don’t use timers for simulated pushbutton release, it works like this -

UI or rules send command to “Light” Item (autoupdate is disabled).
A rule listens for commands and if command ON/OFF does not match current light state, issues a command to “pushbutton”

A rule listens for “Light” state changes.
If simulated “pushbutton” is pressed, release it and also do anything else that needs to be done, this was an automatic event.
If our “pushbutton” not pressed, it was a manual event and we can do whatever might be needed for that case.