[co7io] Industrial integrations with Beckhoff ADS/Siemens S7

Hello together,

I’m new in Openhab and try to connect my Beckhoff CP6606 (TwinCat 3) with Openhab.

I search tutorials in google and find this site.

I download the snapshot and install the Version 2.5.0 into my Openhab.

But now I’m not sure how to continue…

is there anywhere a tutorial for me?

Greetings

Thomas

After installation of binding you should be able to add new ADS connection via Inbox > Add (plus button) or Configuration > Things > Add (plus button). There is no support for discovery and because of routing Beckhoff binding generally speaking doesn’t work unless you setup routing properly (Ams source/target id).

Thank you for your fast answer.

I did it, but is it right, that I can only add three types of channel?
On/Off Switch - Open/Closed Contact - Numeric value

Are there no more possibilitys?

Greetings

Thomas

You are right. Currently there are just three kinds of channels supported, but adding additional ones is not a problem. What data types from PLC do you currently miss?

Maybe all of them? :slight_smile:

You’re right there is nothing holding us to get all of them, but not all of these types are relevant on OH, or can be directly expressed on its side. Many of these types are numbers with different range, precision and/or memory allocation. It would be great if we could do 1:1 mapping, however Java and openHAB type matrix is much shorter than that. In terms of OH we have:

  • Number
  • String
  • Switch / Contact (reflects an boolean)
  • Date Time
  • Quantity (ie. if we have seconds, minutes or hours)
  • Point
  • HSBC (color)
  • List (however it is not used widely)

I believe most of ADS types which can be read can be mapped to above, however some of them which have a variable length could be problematic. Currently you can read any of above ADS types (int8-64, uint8-64) while specifying PLC field. They will simply get mapped to a Number on OH side.

Best,
Łukasz

FYI - I narrowed the issue with Beckhoff/ADS devices. Thanks to direct commitment of @Tho-Gra and his help with simulator setup I could test integration and debug it. Your observations were valid - there was a bug in binding and not in plc4x itself. It was, in fact, my fault in use of library.

Because binding was making two connections to Beckhoff the same time PLC was terminating one of them. Not sure which one, but final result was that communication did not leave openhab. PLC on other hand was sending back Read Device Info commands, but no answer or other read request could be submitted.

During my debugging I’ve implemented additional functionality which allows to setup routes for Beckhoff devices automatically. Thanks to that even under experienced users will be able to run integration (you still need to know plc user and password). I will prepare new release soon with a bit more detailed information what was updated and (hopefully) with config example. I still have some resource leaks to handle.

Thank you very much for testing, reports and patience!
Good night!

I’ve uploaded new version of bindings - the ADS one received major update which should let it work now.

Please download it using links and coupons listed in first posts. You decide if you want to pay anything, or nothing at all, by picking up 100% discount code.

I tried downloading a test-version via your webshop, but I only managed to download a “view” file (no extension) of 69kb instead of the .kar file (02-01 version was 5750kb). I think something is wrong with the webshop. I tried it in different browsers :slight_smile:

Today I’ve installed beckhoff-2.5.1.M1-20200504 on a windows Openhab.
Installing the binding was no problem, when I want to install the thing there is an error 409: conflict.
What can I else try

You don’t install Things, you create them. Assuming you are using PaperUI, 409 usually means you already have a Thing with that name. That might be because the binding has auto-discovered a Thing in your inbox.

correct, create not install.
I’ve switched the test environment from windows to linux, all went fine and used the above example.
Everything looks good and online:
image
However, I cannot control the variable, when I change the status on the PLC, nothing happens in OH.

Hey @marchano,
In case of Beckhoff there is additional “virtual” network layer built-into PLC called AMS. In order to get it working you need to have AMS routes set up. If route is wrong or missing then you will see “online” status which indicates that TCP connection is fine, but you won’t be able to see any data cause its lost in AMS layer.
Please check if binding created route for you using Beckhoff tools. Symptom which you describe might be either caused by lack of route or missing variable. In case of variables - not all registers are visible to binding. Are you cable to control/manage PLC with twincat stuff?

Best,
Łukasz

@splatch thank you for the fast response.
these are the settings done in the controller:image

and a lot of error’s in the log file:
08:24:04.705 [WARN ] [ng.plc4x.shared.handler.task.ReadTask] - Could not fetch field gTestPLC4XBOOL:BOOL from PLC

@splatch

thank you again for the support yesterday, it was very enlightening for a noob like me.

however, it was no success, afterwards, I cleaned up the routes in the PLC and started all over, to avoid conflicting AMS net Id’s, without success…

I’m suspecting the Field entry of the channel is not correct.
Can I get some info about the field format and how to translate this to the global variables in the CX?
How to translate the global variable to indexGroup.indexOffset? And in decimal?
Is there an ads analyser available for download to test it without openHAB?

There is official tool from Beckhoff whcih allows to tap AMS/ADS messages:
https://infosys.beckhoff.com/english.php?content=../content/1033/tcadsamsspec/html/tcadsamsspec_tcadsamsdebugger.htm&id=

Not sure how it looks between different versions, I’ve ran it on windows with TwinCAT PLC simulator where it worked just fine. The field entry comes from symbol you assign.
Not all symbols are available to be read. I don’t know exact rule, one which I was able read are shown in the screenshot below. Please compare it with your syntax. For me field syntax in the binding was:
Main.PLCBoolVar:BOOL.

hello again,

I have tested the ads connection to the plc with this library: https://github.com/Beckhoff/ADS
from the same device as openhab is installed on.
everything works as expected. I can rule out a configuration error on the PLC.

From openhab, there are the same errors in the log as mentioned by @seimenb.
any progress on this?

If you talk about this error:

then it was fixed after debugging session with @Tho-Gra:

The 20200504 release should be free of this bug. The only situation where you sill might encounter this issue is making two network bridges using same ams network active at the same time.
I don’t think this is the case, cause you probably noticed errors with first run.

Are you able to conduct quick wireshark/pcap dump and check how many times openhab opens connection to PLC? There is a filter tcp.flags.syn==1 && tcp.flags.ack==0 which should let you identify beginning of connections between hosts (it is taken from this answer Wireshark Q&A filter).

I have double checked, its another issue I think:

15:11:37.308 [WARN ] [ommon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception:
java.lang.NullPointerException: null
at org.apache.plc4x.java.ads.connection.AdsAbstractPlcConnection.read(AdsAbstractPlcConnection.java:105) ~[?:?]
at org.apache.plc4x.java.base.messages.DefaultPlcReadRequest.execute(DefaultPlcReadRequest.java:44) ~[?:?]
at org.connectorio.binding.plc4x.shared.handler.task.ReadTask.run(ReadTask.java:66) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_222]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) ~[?:1.8.0_222]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) ~[?:1.8.0_222]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) ~[?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
15:11:37.331 [INFO ] [smarthome.event.ThingUpdatedEvent ] - Thing ‘co7io-plc4x-ads:ads:8e06fe93’ has been updated.
15:11:37.309 [WARN ] [ommon.WrappedScheduledExecutorService] - Scheduled runnable ended with an exception:
java.lang.NullPointerException: null
at org.apache.plc4x.java.ads.connection.AdsAbstractPlcConnection.read(AdsAbstractPlcConnection.java:105) ~[?:?]
at org.apache.plc4x.java.base.messages.DefaultPlcReadRequest.execute(DefaultPlcReadRequest.java:44) ~[?:?]
at org.connectorio.binding.plc4x.shared.handler.task.ReadTask.run(ReadTask.java:66) ~[?:?]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:1.8.0_222]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) ~[?:1.8.0_222]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) ~[?:1.8.0_222]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) ~[?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

major breakthrough: I had 2 things created linked to the same variable on the beckhoff.
just removing one of them alone was not the solution, i needed to restart openhab: is there a workaround for this, so in case I made an error, I should not restart the system.

2nd question: how can I read a numeric value from the beckhoff?