fbarresi / BeckhoffS7Client

Unofficial TwinCAT function for S7 Communication
MIT License
34 stars 6 forks source link

Is twincat 2 version technical possible? #1

Open Dunkelicht opened 2 years ago

Dunkelicht commented 2 years ago

Thanks for this s7 protocol, I use PROFINET to exchange data between S7 and twincat2. S7 is maybe a better choice for non-realtime variables, is there any possibility to implement this into twincat 2 ?

Many thanks and stay safe!

fbarresi commented 2 years ago

Hi! I fear this request might have the same end like this other issue 😿 .

This software is a dotnet core 3.1 service. It just need the runtime installed in order to run. The problem: twincat2 plcs are, as far as I know, windows ce based and microsoft don't support it any more. That means there is no way to compile this software in order to run within a twincat2 plc.

I really regret to tell you, I actually don't see any future work in this direction.

But, which alternative do you have?

The newest twincat driver also works under linux: if you would give a try I would be happy to support you updating this software. It would work on every os and architecture, from Raspberry Pi to VM.

Best regards, FB

Dunkelicht commented 2 years ago

Wow, thanks a lot for this detailed reply.

Microsoft has gave up WinCE and no support for dot net core, it is OK for me as I use twincat 2 in Win10 LTSC IoT 32 bit version.

TwinCAT 2 is reliable on Win10 LTSC IoT version like CX51xx and future AMD version IPC, Beckhoff has told us as least twincat 2 will be offered as least before year 2030.

I am now at site now and no time for checking details of code, I think it is TwinCAT 2 data exchange between TFU002 is Ads or memory swap, then TFU002 will do the communication with S7, like other Beckhoff supplement. If my statement is right, working with twincat 2 is technology possible.

Even with your sharp7/ snap7 server, you could do a s7 server, so the S7-1500 will do the s7 client, this will help as S7-1500 could use optimized DB.

Moreover I am also trying to use TS6310 to do so or to do some customized telegram to sync data, but they are too complicated.

Sorry I did not check old issues, next time I will do some research before, I just too excited about s7 support.

Thanks a lot! Stay safe!

Dunkelicht commented 2 years ago

http://snap7.sourceforge.net/snap7_server.html

This snap7 server, with this you could make a "fake" S7 315-2PN/DP and put variables into it. So

Of course this will make this into a S7 Server rather than S7 client. This will help someone who do not know much about ADS.

Just a thought, detailed work will be very difficult and this is information only and not a request for this moment.

fbarresi commented 2 years ago

Hi! Ok, if your are running windows 10 (LTSC) there is surely no problem with dotnet core software! 👍 Twincat 2 fully supports variables attributes, so I think it will work.

You may want to give a try to my other project softplc. It is also based on sharp7/snap7 and let you start a virtual s7 as docker or just as a software with an API for manual create or set content dynamically.

Dunkelicht commented 2 years ago

Hi! Ok, if your are running windows 10 (LTSC) there is surely no problem with dotnet core software! +1 Twincat 2 fully supports variables attributes, so I think it will work.

You may want to give a try to my other project softplc. It is also based on sharp7/snap7 and let you start a virtual s7 as docker or just as a software with an API for manual create or set content dynamically.

Thanks again, but I failed to build with x32 bit version, I will try it later, install VS2019 into IPC is too heavy. I will try softplc later, I use vmware to simulate twincat 2 and winac, it works only in simulation.

fbarresi commented 2 years ago

Sorry, I don't understand what do you need to build. The software is compiled for any-CPU.

Dunkelicht commented 2 years ago

Sorry, I don't understand what do you need to build. The software is compiled for any-CPU.

It cannot run on x32 bit windows, I have tested it on x32 win7 and win10 iot x32. TFU002.Service is 64 bit exe. So I try to build a x32/86 version.

Dunkelicht commented 2 years ago

Snipaste_2021-11-18_14-37-52

fbarresi commented 2 years ago

You normally just need to change the runtime identifier during the build. Did you installed the runtime on the target system? Otherwise you can compile the software as a self contained application.

Dunkelicht commented 2 years ago

You normally just need to change the runtime identifier during the build. Did you installed the runtime on the target system? Otherwise you can compile the software as a self contained application.

Yes I installed both x32 and x64 sdk, I need find a way to build x32 bit. Thanks for the info again.

Dunkelicht commented 2 years ago

Thanks again for update, it is now running at x32 bit windows.

But it is not able to connect to TwinCAT 2.11.2305,

" Twincat 2 fully supports variables attributes, so I think it will work." could you please give some info about this?

Error log is below, connecting to Siemens is OK.

https://github.com/fbarresi/BeckhoffS7Client/blob/5efb2962c14f653eff26df55a9bad08d67f9a1af/TFU002/TFU002.Interfaces/Models/BeckhoffSettings.cs

public int Port { get; set; } = 851;

I changed port from 851 to 801. Please do not blame me as I am a new C# learner.

Please stay safe!

2021-12-16 14:59:53.322 +08:00 [DBG] Hosting starting 2021-12-16 14:59:53.521 +08:00 [DBG] Actual path: C:\Users\TFUServiceUser\AppData\Local\Temp.net\TFU002.Service\unka2gfn.abt 2021-12-16 14:59:53.564 +08:00 [INF] Looking for application settings into C:\TwinCAT\Functions\Unofficial\BeckhoffS7Client\TFU002.settings.json 2021-12-16 14:59:54.159 +08:00 [INF] Application settings successfully loaded! 2021-12-16 14:59:55.539 +08:00 [INF] Staring initialization for IBeckhoffService... 2021-12-16 14:59:55.544 +08:00 [INF] Connecting with Beckhoff at '192.168.10.105.1.1:801'... 2021-12-16 14:59:55.857 +08:00 [ERR] Error while initializing beckhoff TwinCAT.AdsException: Cannot register Port '0' at TwinCAT.Ads.Server.AmsServerNet.AmsConnect(UInt16 port, String portName) at TwinCAT.Ads.Server.AmsServer.ConnectServer() at TwinCAT.Ads.Server.AdsServer.ConnectServer() at TwinCAT.Ads.AdsClient.Connect(AmsAddress address) at TwinCAT.Ads.AdsClient.Connect(AmsNetId netId, Int32 port) at TwinCAT.Ads.AdsClient.Connect(String netId, Int32 port) at TFU002.Logic.Services.BeckhoffService.InitializeBeckhoff(BeckhoffSettings setting) at TFU002.Logic.Services.BeckhoffService.Initialize() 2021-12-16 14:59:55.952 +08:00 [DBG] Connection state changed to 'None' 2021-12-16 14:59:55.975 +08:00 [DBG] Ads state changed to 'Init' 2021-12-16 14:59:55.976 +08:00 [DBG] Deleting symbols on beckhoff state change to Init 2021-12-16 14:59:55.980 +08:00 [INF] Initialization of IBeckhoffService completed with result: True 2021-12-16 14:59:55.980 +08:00 [INF] Staring initialization for IPlcProvider... 2021-12-16 14:59:56.212 +08:00 [DBG] PLC 's7-1500' state changed to 'Initial' 2021-12-16 14:59:56.214 +08:00 [INF] Initialization of IPlcProvider completed with result: True 2021-12-16 14:59:56.218 +08:00 [DBG] PLC 's7-1500' state changed to 'Connected' 2021-12-16 14:59:56.294 +08:00 [INF] Application started. Hosting environment: Production; Content root path: C:\Users\TFUSER~1\AppData\Local\Temp.net\TFU002.Service\unka2gfn.abt\ 2021-12-16 14:59:56.297 +08:00 [DBG] Hosting started 2021-12-16 14:59:56.964 +08:00 [DBG] Connection state changed to 'Lost' 2021-12-16 14:59:56.967 +08:00 [DBG] Ads state changed to 'Invalid' 2021-12-16 14:59:56.967 +08:00 [DBG] Deleting symbols on beckhoff state change to Invalid

fbarresi commented 2 years ago

Hi! The log file is trying to tell you that your connection parameters are wrong. You don't need to change anything in code, but in your local settings. Did you setup a route for getting connected with your plc? I'm not confident with twincat 2, but I guess ads works in the same way. Wich version of ads do you use? Best regards, FB

Dunkelicht commented 2 years ago

I am using 2.11.2305, I am now at site, I need back to office to test TC2. Thanks!