Introduction to PLC Programming with C++

preview_player
Показать описание

============================

▶ You can read the full post here:

⌚Timestamps:
00:00 - Intro
00:41 - Background information
02:43 - Ladder Diagram program
03:26 - C++ program
06:33 - Integrating the C++ Program with the LD Program
07:26 - Conclusion

=============================

In this video, we're going to program a PLC using both Ladder Diagram (LD) and C++. The LD program will accomplish simple Motor Start and Stop operations. The C++ program will produce logging data of motor activations.

We'll use Phoenix Technology PLCnext Engineer to create the LD program, and Eclipse IDE to create the C++ project. PLCnext Engineer is used to run both the LD and C++ programs.

We will run our project utilizing the hardware and I/O on the PLCnext Starterkit.

The five programming languages specified in the IEC 61131-3 Standard are Ladder Diagram, Instruction List, Function Block Diagram, Structured Text, and Sequential Function Chart. 

Most PLC Programming software is capable of programming using two or more of IEC 61131-3 Standard languages.

Generally speaking, PLC Programming software is not capable of higher-level language programming such as C++. C++ programs are created using other programming software.

The resulting C++ program can be added to or work alongside the PLC programming software allowing the IEC 61131-3 program and the C++ program to run together.

C++ programs can be easily created to produce log data to assist with Predictive Maintenance (PdM). A program of that complexity cannot be easily created using IEC 61131-3 languages such as Ladder Diagram.

Creating C++ programs requires an Integrated Development Environment (IDE). An IDE is a complete package that among other things, offers a code editor.

There are lots of C++ IDEs. Microsoft Visual Studio and Eclipse are two very commonly used IDE Editors. Eclipse is one of the simplest and that’s the Editor we use.

- We will use Ladder Diagram for controlling the MOTOR. The ladder diagram tells us that the MOTOR will run when we press the START switch and continue to run until we press the STOP switch.

- We will use C++ for producing logging data of motor activations.

- The C++ project is then added to the LD program in PLCnext Engineer.

- We then run the LD and the C++ programs after we download them to the PLC.

- As we operate the START and STOP switches on the Starterkit, the MOTOR will START, then STOP. Each time the Motor cycles, the Out Port value increments.

- We will use a log file to view the MOTOR activations complete with a Time Stamp. We use WinSCP to extract and view the contents of the log file. WinSCP is a secure file transfer protocol (SFTP) client software.

=============================

=============================

=============================

Missed our most recent videos? Watch them here:

=============================

To stay up to date with our last videos, make sure to subscribe to this YouTube channel:

=============================

=============================

#PLCnext #RealPars #plc
Рекомендации по теме
Комментарии
Автор

Nice thing most PLCs support simulatenous use of both languages. LD or FBD takes care of mechanical controls, while C++/ST excel at crunching numbers for complex calculations or any form of analysis. I remember in college, I would create ST functions I would sneak into a LD program, because my teacher was so obstinate about using LD or SFC.

caffeinatedinsanity
Автор

I created my own language to do this sort of thing and it has logging built into it. It's a functional programming language so it's easier than C but can do more than the non-C alternatives above. How the logging works is that for each output the programmer defines the user can just tick a box and it will log and and display real-time web graphs. Actually the code to do the logging is rather more complicated than your example. I've built in data compression, which is good if you are logging a lot of data and need to display it from the database.

Andrew-rcvh
Автор

Good afternoon, yes, this is interesting, but there are nuances, not all automation engineers know C ++, and also if we are talking about large projects, like the "blast furnace" example, where there are a lot of mechanisms and sensors, and in the event of a breakdown, you need to quickly find the cause, considering that everything is done on the PLC, then the LD language is the most optimal of all those listed, I once wrote a program completely in ST, when creating an object, I had to rewrite everything in LD, since this was required by the operation, I think, as for the developer, use C++ has more features, but for exploitation, these are only minuses

MrAruk
Автор

Well explained. This is where the benefits of DCS over PLC are apparent. Using ST these and many other functions difficult in Ladder. Great option for PLC’s to raise the data options.

Automation_Control_Tuning
Автор

Same thing can be done with MX component by Mitsubishi electric., amazing Work realparts!!

JesusNajera-sito
Автор

Very good explanation about PLC programming with c++...thanks for your information

syufrijal
Автор

Okay, it is good to see how to do it in a VS

mybox
Автор

C++ is actually lower level than ladder diagram. The terms high and low mean the abstraction level in programming languages and c++ has fewer abstractions than ladder diagram

jahndo
Автор

What are the minimum system requirements to warrant a PLC? I program with microcontrollers at work every day. When would I switch from a generic micro controller to a standard PLC?

JKTCGMV
Автор

Random watch but I found it interesting (I wrote PLC code at secondary school 20 years ago). Bad C++ code style.

deeplazydev
Автор

I used to work in "customer support" for programming. We had a saying "C" will let you shoot yourself in the foot. It's harder to shoot yourself with C++, but when you do, it's with a bazooka.

seventhson
Автор

is it possible to do Tracing as well? logs are good, but next step for observability is tracing!!

nikolaydubina
Автор

Really up to the user on what they prefer. Reality is its running all the same in the background.

elijk
Автор

whats the difference of log in hmi and c+? are they different

nayrbsworld
Автор

well even just for starting a motor, it is needed tens of code! it really makes sense hahah

floydian
Автор

it's incredible! Very cool. let's have more examples of programming with PLCnext in high-level languages 🦾

spacexnix
Автор

Am I right in thinking that unless you have realtime or environment requirements, it's perfectly feasible to avoid PLCs altogether in favor of, say, RPi or KNX or something similar?

DmitriNesteruk
Автор

Oh this is sweat. I know why PLC is used for factory control, but C/C++ is a far more capable language for aditional services and a gate for a fab to any cloud based activity.

MrHaggyy
Автор

C++ is actually a lower level language than the others.

Stabby