4

I did my best to search all topics regarding to SCADA and developing your own C++ desktop application to communicate with PLCs, but could not find any recent, or in my opinion, relevant topics that fit what I needed. If I missed them, a link to them would be very much appreciated. If I also happened to post this in the wrong section, or you can think of a better section for me to post this in, I will take it there.

With that said, I thank you in advance for taking the time to read my questions, and appreciate any input you have to offer.


A little bit about what I'm doing

I'm currently in school for electromechanical engineering, and for my final year project I am developing a desktop application in C++ to monitor PLCs we have located within one of our labs.

Within this lab, I have a pre-existing ethernet network connecting all PLCs to single point, which I am tying into with a PC, and will be doing all my work from there.

I will be developing the application in Qt for an easy way to design the GUI, and giving me access to the QNetworkInterface as well as QTcpSocket.

With that said, I wouldn't go as far as saying I'm an experienced programmer, but I have been fooling around with a few languages (i.e.: python, c++, c, php) for quite a few years, and am still learning, considering the learning NEVER stops.


My questions

  1. Is there any reference material I can read, that you can suggest, on the subject to more easily understand what sort of process I need to go through to receive information (i.e.: individual I/Os, status bits, tags, logs, etc...) from the PLCs directly, and not through an OPC server?

  2. If an OPC server is required, I've never dealt with OPC links other than using Rockwell Automations RSLinx to grab tags and display their values within excel (I had created a prototype using that exact method to start, but would like to move away from excel, and if possible, the OPC server (RSLinx) as well). What would you suggest to someone who knows nothing about the subject of OPC servers, or to my knowledge, OPC in general?

  3. Have any of you previously written your own application to do something similar, if not of the same nature to what I'm trying to accomplish?

  4. What advice or suggestions would you give for someone who is attempting this type of project?


PS: As a start for this project, I would initially just want to get the reading of the I/Os (tags or addresses) to view what their current values are (closed or open for inputs, energized or not for outputs). But eventually I would also like to be able to write values to tags on the PLCs I'm monitoring based on the values I've received from them.

PSS: I would like to note again, that I am still a student, and am still learning about this subject in it's entirety. I would just like to ask for your patience, as I may not grasp things completely the first time!

If I've missed any information you feel is pertinent to be able to provide an answer, please let me know! I will do my best to come up with said information in a timely manner!

Thank you!


EDIT #1: Added in another question, and altered my first question slightly

EDIT #2: Fixed up question 2

Josh
  • 41
  • 1
  • 5
  • If there is already an OPC Server, won't it cause a port conflict if you poll the PLCs directly or can both of them exist concurrently? It might be faster to get off the ground using the OPC server and just work out what tags it takes since every PLC is different. what OPC does is to give you a consistent interface to all of them. – cup Dec 28 '13 at 06:17
  • If it works in excel, you could do it as an hta in javascript/vbscript. It is not portable to Linux but it will work on any Windows platform (from 95 or later). – cup Dec 28 '13 at 06:19
  • As far as I understand it, the OPC server is RSLinx. It was the middleman between the PLCs and excel in my prototype. However if I cut out RSLinx, I'm assuming I can make a connection directly to the PLCs given their IP addresses on my network. My intention is to develop a SCADA suite, or at the very least something leading up to it for future classes to develop on and add to. Which is why I would like to eliminate RSLinx from the picture. However I do see what you're saying, get it working using RSLinx, then remove it. But that raises a new question, how do I communicate with RSLinx? – Josh Dec 28 '13 at 06:23
  • 1
    What OPC gives you is an ODBC database which you can query. Why not do it in two stages: first work out what your GUI is going to look like using OPC with ODBC. At the same time you can work out the tags for controlling the PLC. Once you have done that, try talking to the PLC directly. If there is insufficient time to complete that, then at least you have the control GUI to show. Also you can add OPC to your CV since it is quite a well known standard. You could put a switch in your code for selecting whether to talk directly or through OPC – cup Dec 28 '13 at 06:37
  • So I know I understand you correctly, you're saying to figure out how to access the database provided by RSLinxs OPC server, and poll that for the tags/information I want? (Also, not mentioned in the original post, but I already have a base mock up of what I want my GUI to look like. It is located [here](http://imgur.com/a/FPFGB#4). I have it currently setup to connect to a MySQL database I am setting up locally to log all transactions) – Josh Dec 28 '13 at 06:55
  • Yes - figure out how to control the PLCs through OPC first. Does the GUI tell an engineer what they want? Does it allow them to change the parameters of the PLC and see the result? That is the sort of thing engineers will want: they're not interested in databases. You handle that behind the scenes. Work out a plan of what you have to do and the timescale in which it has to be achieved. If things slip then the stuff at the end has to be shelved. Put in the original plan and what actually happened as part of your write up. It is also a measure of what you think of your abilities. – cup Dec 28 '13 at 07:43
  • Alright. That sounds pretty good! I'll work at getting a more useful layout and interface, but I think that'll still be a few weeks down the road, until I get the ODBC communication working! Thanks @cup you've been quite informative! – Josh Dec 28 '13 at 08:13
  • 1
    plc connectivity is a major security thread, that's why you feel confuse dealing with what exist so far. Opc was designed at the begining as a backdoor for microsoft to step into industrial computing ruled by main frame manufacturers. Opc-ua introduce multiplatform portability, (even for embedded stuff) but still keep it's well designed opacity. Control is the key point in our economies, and plant busses are well focused by those who doesn't want to loose control... – j-p Apr 16 '14 at 16:33
  • 1
    MQTT will (or not) be the step ahead, Up to regulatory institution to let some presure released for field busses interconectivity – j-p Apr 16 '14 at 16:35

4 Answers4

5

IMHO a SCADA program should have as a minimum requirement to be able to connect to an OPC server. OPC is used for most commercial PLCs.

Strictly speaking there is no need to have an OPC server/client approach but it gives you flexibility and gives you an abstraction model. If you want to directly connect to PLCs using a protocol then that is of course possible as well. You then need to know more details about the protocols and their various versions.

Yes I worked for a few years in a team that developed a commercial SCADA application.

It is very easy to get lost in details in such a project so try to keep things as simple as possible. By using OPC you will save time instead of fiddling directly with the protocols. You could add the ability to add custom-drivers for other protocols - depending on your timeframe. Try to model up your project before you start coding to a birdsview of the model and avoid getting lost in the details.

AndersK
  • 35,813
  • 6
  • 60
  • 86
4

I would stay well away from looking to write your own code to connect directly to an AB PLC - there are products out there that you can use in your application: http://www.rtaautomation.com/software/ethernetip/client/tagc/ControlWin.html http://www.automatedsolutions.com/products/dotnet/ascomm/

You would be better to use OPC - you can write you own OPC client if you want and follow examples you find here: http://www.opcconnect.com/source.php#freesource

According to this http://www.control.com/thread/1026173407 you should be able to get source code of Kepwares OPC Quick Client.

It would probably be easier to just use a library as in this example (RSLogix,C#): http://www.mesta-automation.com/opc-client-with-c-an-how-to-video/

You might find this of use: http://www.rockwellautomation.co.kr/applications/gs/ap/GSKR.nsf/files/rslinxsdk_ma_eng.pdf/$file/rslinxsdk_ma_eng.pdf

Some resources: http://www.opcconnect.com/ , http://www.mesta-automation.com/

A Murray
  • 421
  • 1
  • 9
  • 15
1

Answer to question #4 - realize that your lab technically could contain ANY manufacturer's PLCs in the future. If you ever took a Data Communications class, you realize that for N different PLC types, you would have to write N different communication drivers for your PLC client.

This is where standards are helpful. Without the use of a standard protocol, scaling your lab could become more time consuming and less manageable. This is why communications standards exist.

HOWEVER, not all PLCs necessarily support the standard(s) you may decide upon.

The best choice is OPC/UA. Many PLCs have server drivers readily available. That means that your client just needs to understand 1 protocol (OPC/UA), and then it can "easily" be connected to any PLC that has a driver for that standard.

After that, there is OPC. After that, Modbus (TCP and RTU flavors), a relatively simple industry standard that is supported by most PLCs. EtherNet/IP is also a possible choice, although not all PLCs support it in a "server" role (many do support it as a client, but that is not what you need).

franji1
  • 3,088
  • 2
  • 23
  • 43
0

have a look at pycomm in github or pylogix at github which are Python written drivers to link to clx plc.