Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » using OPC to control siemens PLC
using OPC to control siemens PLC [message #1761686] Thu, 11 May 2017 14:18 Go to next message
Jiahang Chen is currently offline Jiahang ChenFriend
Messages: 34
Registered: April 2017
Member
Hello everyone,
I'm now using KepServer to collect data from Siemens PLC and trying to connect it with my 4DIAC program. Because i can't upload the program, which in 4diac finished, to siemens s7 plc, so i try to build the communication via OPC. Then the program can run in PC and control the Siemens PLC via OPC

Have you guys ever done this before? Please help me!!! Thanks in advance!
Re: using OPC to control siemens PLC [message #1761917 is a reply to message #1761686] Thu, 11 May 2017 20:08 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 645
Registered: January 2014
Senior Member
Hi,

if you are on windows you can add a OPC DA client to FORTE. A documentation on how to do and use it can be found here https://www.eclipse.org/4diac/documentation/html/communication/opc.html
Re: using OPC to control siemens PLC [message #1763273 is a reply to message #1761917] Fri, 12 May 2017 10:19 Go to previous messageGo to next message
Jiahang Chen is currently offline Jiahang ChenFriend
Messages: 34
Registered: April 2017
Member
FORTE_COM_OPC_BOOST_ROOT - choose
FORTE_COM_OPC_LIB_ROOT - choose

its from the page. And i wanna ask you, why does that mean?
i have chosen the boost file which i downloaded from http://www.boost.org for the FORTE_COM_OPC_BOOST_ROOT.
And i have also chosen the file ProjectsInAutomation from https://sourceforge.net/projects/opcclient/ for FORTE_COM_OPC_LIB_ROOT

Problem is that i can't creat the Forte.exe
you can see all the error in the pic

would you be so kind to tell me, which step i have forgot?
  • Attachment: 1.PNG
    (Size: 100.46KB, Downloaded 73 times)
Re: using OPC to control siemens PLC [message #1763278 is a reply to message #1763273] Fri, 12 May 2017 10:43 Go to previous messageGo to next message
Kirill Dorofeev is currently offline Kirill DorofeevFriend
Messages: 38
Registered: February 2016
Member
have you also checked FORTE_COM_OPC?
Re: using OPC to control siemens PLC [message #1763279 is a reply to message #1763278] Fri, 12 May 2017 10:49 Go to previous messageGo to next message
Jiahang Chen is currently offline Jiahang ChenFriend
Messages: 34
Registered: April 2017
Member
of course i have checked it.

i have also creadted the folder structure, ProjectsInAutomation/OPC_DA_ClientSKD_0.4/include and put all the header file from OPCClientToolKit into

and ProjectsInAutomation/OPC_DA_ClientSKD_0.4/lib which include OPCClientToolKit.lib

  • Attachment: 2.PNG
    (Size: 73.33KB, Downloaded 70 times)
Re: using OPC to control siemens PLC [message #1763288 is a reply to message #1763279] Fri, 12 May 2017 11:33 Go to previous messageGo to next message
Kirill Dorofeev is currently offline Kirill DorofeevFriend
Messages: 38
Registered: February 2016
Member
my next guess would be that you're pointing into your /lib folder in FORTE_COM_OPC_LIB_ROOT (not sure, can't see it on your screenshot), whereas you should point one level up, e.g. /OPC_DA_ClientSDK_0.4a/ProjectsInAutomation/OPC_DA_ClientSDK_0.4/OPCClientToolKit

[Updated on: Fri, 12 May 2017 11:34]

Report message to a moderator

Re: using OPC to control siemens PLC [message #1763292 is a reply to message #1763288] Fri, 12 May 2017 11:54 Go to previous messageGo to next message
Jiahang Chen is currently offline Jiahang ChenFriend
Messages: 34
Registered: April 2017
Member
thanks for your answer
i did point it into OPCClientToolKit
could you be so kind to help me again to find the problem?
  • Attachment: 1.PNG
    (Size: 4.15KB, Downloaded 74 times)
Re: using OPC to control siemens PLC [message #1763313 is a reply to message #1763292] Fri, 12 May 2017 14:32 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 645
Registered: January 2014
Senior Member
I think on issue could be in the CMakeList.txt file of the OPC module. Could you try to add the line:

forte_add_include_directories(${CMAKE_CURRENT_SOURCE_DIR})

right after the line if(FORTE_COM_OPC), which is line 19 in my FORTE version?
Re: using OPC to control siemens PLC [message #1763316 is a reply to message #1763313] Fri, 12 May 2017 14:43 Go to previous messageGo to next message
Jiahang Chen is currently offline Jiahang ChenFriend
Messages: 34
Registered: April 2017
Member
Thanks for your answer. It helps a lot but not all.

i still see here some error wenn i complied the C Project


  • Attachment: 1.PNG
    (Size: 50.23KB, Downloaded 53 times)
Re: using OPC to control siemens PLC [message #1763321 is a reply to message #1763316] Fri, 12 May 2017 15:31 Go to previous messageGo to next message
Kirill Dorofeev is currently offline Kirill DorofeevFriend
Messages: 38
Registered: February 2016
Member
as a quick fix you can try to put all case-statements that give you an error into curly brackets, f.ex, case {...}
Re: using OPC to control siemens PLC [message #1763358 is a reply to message #1763321] Sat, 13 May 2017 13:06 Go to previous messageGo to next message
Jiahang Chen is currently offline Jiahang ChenFriend
Messages: 34
Registered: April 2017
Member
Thanks for your suggestion.
i have tried to do that but it still shows the same errors
Re: using OPC to control siemens PLC [message #1763360 is a reply to message #1763321] Sat, 13 May 2017 13:38 Go to previous messageGo to next message
Jiahang Chen is currently offline Jiahang ChenFriend
Messages: 34
Registered: April 2017
Member

Hi now i have put all the case-statements into the curly brackets.
and have only 1 error
  • Attachment: 5.PNG
    (Size: 67.35KB, Downloaded 80 times)
Re: using OPC to control siemens PLC [message #1763411 is a reply to message #1763360] Mon, 15 May 2017 13:34 Go to previous messageGo to next message
Kirill Dorofeev is currently offline Kirill DorofeevFriend
Messages: 38
Registered: February 2016
Member
I was able to successfully build forte after just casting the second argument to Variant.

    itemList.push_back(new SOpcItemData((LPCTSTR) (item->getName()), (Variant) itemData->vDataValue));


Hope, this helps
Re: using OPC to control siemens PLC [message #1763412 is a reply to message #1763411] Mon, 15 May 2017 13:55 Go to previous messageGo to next message
Jiahang Chen is currently offline Jiahang ChenFriend
Messages: 34
Registered: April 2017
Member
Thanks, i have also done it before, the error C2664 is really gone.
But new errors come now.
That means, wenn i delete the added "Variant", then only error C2664 is shown.



  • Attachment: 7.PNG
    (Size: 51.88KB, Downloaded 83 times)
Re: using OPC to control siemens PLC [message #1763415 is a reply to message #1763412] Mon, 15 May 2017 14:03 Go to previous messageGo to next message
Kirill Dorofeev is currently offline Kirill DorofeevFriend
Messages: 38
Registered: February 2016
Member
all these are already Linker errors. that means compiler is done its job successfully. Just quickly googling on this 'RuntimeLibrary' errors gave me as a possible cause of these the different version of C Runtime library in project you're building and library you are linking. Check Project Properties >> C/C++ Code generation >> Runtime Librarly value for both forte project and OPCClientToolKit. They should be the same (Multi-threaded in my case).
  • Attachment: CRT.png
    (Size: 51.53KB, Downloaded 83 times)

[Updated on: Mon, 15 May 2017 14:22]

Report message to a moderator

Re: using OPC to control siemens PLC [message #1763443 is a reply to message #1763415] Tue, 16 May 2017 08:34 Go to previous messageGo to next message
Jiahang Chen is currently offline Jiahang ChenFriend
Messages: 34
Registered: April 2017
Member
i did the same as you said

but it still doesn't work and shows error LNK 2001 and LNK 2038

Re: using OPC to control siemens PLC [message #1763444 is a reply to message #1763443] Tue, 16 May 2017 08:54 Go to previous messageGo to next message
Kirill Dorofeev is currently offline Kirill DorofeevFriend
Messages: 38
Registered: February 2016
Member
Did you change the OPCClientToolKit.lib file and *.h files in your /lib and /include directories respectively after you rebuilt OPCClient? It still complains about different RuntimeLibrary values.
Re: using OPC to control siemens PLC [message #1763457 is a reply to message #1763444] Tue, 16 May 2017 11:43 Go to previous messageGo to next message
Jiahang Chen is currently offline Jiahang ChenFriend
Messages: 34
Registered: April 2017
Member
Hi, thanks for your answer.

i did change the OPCClientToolKit.lib and all the header file after i rebuilt the OPCClient. But it seems still dont work

i have totally no idea which step i did wrong

or could you tell me, which mode did you choose, when you built your project? release or debug? can this a problem?
  • Attachment: forte.PNG
    (Size: 109.69KB, Downloaded 82 times)
Re: using OPC to control siemens PLC [message #1763460 is a reply to message #1763457] Tue, 16 May 2017 11:53 Go to previous messageGo to next message
Kirill Dorofeev is currently offline Kirill DorofeevFriend
Messages: 38
Registered: February 2016
Member
I built a release version for both projects.
Re: using OPC to control siemens PLC [message #1763468 is a reply to message #1763460] Tue, 16 May 2017 13:12 Go to previous messageGo to next message
Jiahang Chen is currently offline Jiahang ChenFriend
Messages: 34
Registered: April 2017
Member
thanks, i changed the version of release of both and it works now
Re: using OPC to control siemens PLC [message #1763470 is a reply to message #1763468] Tue, 16 May 2017 13:18 Go to previous message
Kirill Dorofeev is currently offline Kirill DorofeevFriend
Messages: 38
Registered: February 2016
Member
cool. just a quick note. if needed, a debug configuration can be built as well if RuntimeLibrary in project properties is set to Multithreaded Debug /MTd for both OPCClient and forte projects.
Previous Topic:Unable to launch FBRT/Local FORTE after importing application
Next Topic:declaration of subroutines/functions currently not possible in ST algorithms?
Goto Forum:
  


Current Time: Sun Oct 21 16:31:28 GMT 2018

Powered by FUDForum. Page generated in 0.28672 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top