Integrate Siemens Logo (plclogo) in OpenHAB 2

Hi @eXact,

you need memory thing for each network input. On example for NI1

  Thing memory VB30_0 [ block="VB30.0" ]

EDIT: Inputs are contacts, output are switches. Please, fix the *.items

Kind regards,

Alexander

1 Like

Hi @skazi,

good idea! I’l take a look as my time allows.

Kind regards,

Alexander

Hi @Euphi,

if “1” is written to memory address V2.6, then NI23 will change.

Kind regards,

Alexander

Yeah, but documentation states that

If observe is set and differ from block , binding will wait for value change on observe and send then a pulse with length pulse milliseconds to block.

However, this is obviosly not, what a Pulse thing really does.

@falkena Trying to reproduce your rollershutter example.
I saved your UDF to be compatible with Logo7.


RolladenMotor_L7.pdf (3.8 KB) Find the UDF attached. Rename pdf to zip!

In addition I included an emergency-stop flag - hoping this is at the optimal position to keep the UDF intact. The 3rd input is connected to a magnetic door-switch which is normally-ON (input is ‘high’ when door is closed).

Works in Logo, but so far does not work in openHAB:

  • Could you provide the corresponding sitemap-config?
  • How to determine the scaling-factor (?) T_Sc?
  • I can read the memory value (0=up…100=down), counting is optimal for 1 direction only.

Logo7 does not support reading NI (network inputs) directly, this might be a problem?

  Thing pulse VB2_6  [ block="VB2.6", observe="NI23", pulse=500 ]
  Thing pulse VB2_7  [ block="VB2.7", observe="NI24", pulse=500 ]

Or can I replaces this with:

  Thing pulse VB2_6  [ block="VB2.6", observe="VB2.6", pulse=500 ]
  Thing pulse VB2_7  [ block="VB2.7", observe="VB2.7", pulse=500 ]

(Pulse thing is still a bit mysterious to me).

Thanks,
Arnd

FYI, I have updated the 2 PLCLogo tutorials, these are fool-proof now (or mention issues).

@falkena, could you provide the sitemap for your rollershutter example?
Apologies, had no time to check your latest binding update (with pulse fixes).

Hi @tv-arnd,
sorry about late reply, i was quite busy last days. Regarding your questions
My sitemap is very simple:

Switch item=Rollo 

The scaling factor is not really self-explained. I set it to max(T_Up, T_Do) * 100. Example: If T_Up is 17seconds and T_Do 15seconds, then T_Sc will be 1700. That’s right: Counting is more or less precise for one direction only. My wife told me, that rollos must be opened completely and closed with some gaps :roll_eyes: It was a time to think really hard: Each motor has physical endpoints. Means, i can drive high as long i will. But down i must measure the time the rollo will stop: i was simply too lazy to setup motor endpoints with a screwdriver :slight_smile: The program can be extended to calculate rest time to drive dependend on current position. My Logo program for Easter calculation is meanwhile done, so why not take a look :slight_smile:
And yes, you can use

Thing pulse VB2_6  [ block="VB2.6", observe="VB2.6", pulse=500 ]

instead of

Thing pulse VB2_6  [ block="VB2.6", observe="NI23", pulse=500 ]

BTW: I would couple emergency signal with both directions and wire them to R trigger input

Kind regards,

Alexander

Ok, Rollo goes up & down controlled via the UI up/down-buttons. Rollo stops using the UI’s up/down-buttons. Rollo STOP does not work using the UI’s X-button.
Error in Log: [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘RolloDrive’: Unknown variable or command ‘==’; line 11, column 11, length 15
Something is wrong with the code line

      if (Direction == UP) {

Hi @tv-arnd.
try to add follow lines at top of the rule file:

import org.eclipse.smarthome.core.types.Command
import org.eclipse.smarthome.core.types.RefreshType
import org.eclipse.xtext.xbase.lib.Procedures

Kind regrads,

Alexander

Hello everybody,

again update in binary repository: Hardening pulse thing on slow network.

Kind regards,

Alexander

1 Like

@falkena, allright with the 3 'import’s it works.
I do not see any button-activity (e.g. color change, when button is pressed - would by nice to see the ‘down’-button highlighted when rollo goes down).
RolloShutter_sitemap

The following one gave me a hard time :wink:

Contact RolloIsHi     { channel="plclogo:pulse:LogoController:VB2_6:observed" }
Contact RolloIsDo     { channel="plclogo:pulse:LogoController:VB2_7:observed" }

Actually, these are not used at all?
Tutorial is in the making.

@falkena I have intalled the new binding version 2.5.0.
I can still ‘create’ hanging pulse things (i.e. NI stays ON forever, Logo flashing required). Can be reproduced with the 2nd example in
https://community.openhab.org/t/plclogo-solution-logo-output-switching/64264/2
This happens if the Logo-refresh time is longer than the pulse-length!! I think it is a good design guideline to make a pulse at least twice as long as the Logo-refresh time.

@All Just try the new binding:

  1. de-install Logo-binding with Paper UI
  2. download and copy *.jar to openhab2-addons directory
  3. (may re-start openHAB). New PLClogo binding does not appear in Paper UI ,but works :slight_smile:

Regards,
Arnd

Hi @tv-arnd,

Ok. This case i haven’t tested :slight_smile: Is the case, if pulse is longer than refresh time, work now without issues? If yes, then i’ll raise PR and add hint to documentation.

Thanks and kind regards,

Alexander

@tv-arnd @falkena I think I’ve just hit the “stuck NI” problem. I had pulse=200 with refresh=100. What I did was a “double click” in habpanel. This triggered the pulse command too quickly and left the item in ON state. After that, the habpanel button didn’t work as expected (sending ON to item which is ON), but in paperui I was able to still trigger the pulse on the NI item but it was “reversed”. Most of the time the item was ON but when I clicked it in paperui it got OFF for a short time and then returned to ON. This correctly toggled the output in LOGO. Maybe this will help debug this problem.

BR,
Jacek

Hi All,

Find below a proposal for light-switching with Logo’s comfort-switch. Very deterministic, because no proxy-switch, no pulse, simple rule.

I have created a new comfort-switch (UDF) - may could be optimised. The principle is that parallel operation of a physical wall-switch and a NI (network input) shall be possible. NI is an on/off switch (can be triggered by openHAB, displays the light’s status and follows the light’s Q per rule)

OH_Logo_Comfort-Switch

Cases:

  1. classical switching on/off Q from wall-switch (permanent or with auto-off)
  2. on/off switching Q from NI network-switch (permanent)
  3. switching on Q from wall-switch by a long press, switching off by NI
  4. switching on Q from NI, switching off by wall-switch

@falkena

Problem with 3: when light Q is switched permanently ON by wall-switch, openHAB’s NI follows, but switching NI off does not work (requires NI to go off, then on, then off). All logged fine. In other words, NI going off does not trigger Logo Q to go off.

Problem with 4: when light Q is switched permanently ON by NI, Q can be switched of by wall-switch. But cannot be switched on again by wall-switch

This works fine in the Logo simulation.

Find the UDF here (rename pdf to zip): OH_Logo_Comfort-Switch.pdf (35.5 KB)

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" ]
  Thing memory   VB100_4   [ block="VB100.4", observe="NI5" ] // Light
}

Items

Switch  Logo7_Q8    "Q8"    { channel="plclogo:digital:Logo7:Outputs:Q8" }
Switch  Logo7_NI5   "NI5 Licht Wohnen L"  <light>  { channel="plclogo:memory:Logo7:VB100_4:state" }// Light

Anything wrong, how I turned a ‘memory’ into a ‘switch’? (there is no NI for Logo 0BA7 / state vs. observed?).

Sitemap

sitemap default label="Haus" {
Frame label="Light Switch"  {
    Switch item=Logo7_NI5 mappings=[OFF="AUS", ON="EIN"] // Light
   }
}

Rules (super simple, no proxy-switch required!!)

rule "Switch Light Wohnen L Logo"
when
    Item Logo7_Q8 changed                         // light changed
then
    Logo7_NI5.postUpdate(Logo7_Q8.state) // NI always follows Q
end

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

NI is written twice in some cases: NI manually switched off, Q goes of, NI follows to off (again). Problem?

Maybe I’m missing something obvious but is there some way to write to one-bit NI other than with pulse thing?
I want to implement “keep NI on as long as some openhab item is on logic” and can’t get it to work.

I tried:

  1. digital thing with block=“VBx.x” -> block is not supported (only general “kind” parameters)
  2. memory thing with block=“VBx.x” -> looking at the code here https://github.com/openhab/openhab2-addons/blob/master/bundles/org.openhab.binding.plclogo/src/main/java/org/openhab/binding/plclogo/internal/config/PLCMemoryConfiguration.java#L70 it seems that memory is only for reading outputs from LOGO not for writing inputs (compared to https://github.com/openhab/openhab2-addons/blob/master/bundles/org.openhab.binding.plclogo/src/main/java/org/openhab/binding/plclogo/internal/config/PLCPulseConfiguration.java#L58 in pulse thing)
  3. pulse thing -> this works but only for as long as the pulse and I want it to be on as long as the triggering item

@falkena any thoughts/ideas?

Hi @tv-arnd, @skazi,

It seems you catched a bug with writing into memory address. I’ll try to take a look this weekend.

Kind regrads,

Alexander

Is this version newer or older than 2.5.0.M1?

I use 2.5.0.M1 and have problems with hanging pulses, even if they are 600ms long (so several times longer than refresh time).

I still have problems with hanging pulses using the 2.5.0.201902182038 version of the PLCLogo-binding.

This can be triggered by “racing” commands (sending multiple commands during short time - or mabye a second command just at the right time). See https://github.com/falkena/openhab2-addons/issues/9 for details.

Maybe there could be a simple pulse thing that don’t use the observer at all?

I have had the same problem, so i used digital things an make my Pulses on the LOGO itself with falling and rising edge. Look at my Poste here:

@falkena is there a reason why NI can’t be used in digital switch things ?

1 Like