Desktop SCADA Application - Reading and Writing to PLCs through C++

3.1k views Asked by At

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

4

There are 4 answers

0
A Murray On

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/

0
AndersK On

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.

0
AudioBubble On

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

0
franji1 On

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).