Store PLCnext CommunityPLCnext on LinkedInPLCnext on Instagram  PLCnext on YouTube Github PLCnext CommunityStore PLCnext Community

  1. Arne Smets
  2. PLCnext Technology & PLCnext Controls
  3. Wednesday, 18 September 2019

I'm asking quite a lot on the forum these weeks, but I have to make a project on the PLCNext and I want to understand which options the PLCNext has before I start programming. On the Phoenix site I read this: "easy integration of open-source software". Yesterday I recieved an answer that I should use the add-ins for VS or Eclipse, until it couldn't do what I want to do. But how can I implement open source then? 

Is it for example also possible to make a C++ project on Linux? (VS can do) Is it even possible to make a C++ project in VS which I can use for the PLCNext? Is there a tutorial online about this? I worked with VS C++ quite a lot so I think i'm the most confident there. I am not sure about all the software I can use and what I can do with the linux part of the PLCNext. The idea I have right now is that the plug ins are the only options.. 

Thank you in advance,

Arne 

Martin PLCnext Team Accepted Answer Pending Moderation
1
Votes
Undo

Hi Arne,

Your questions are welcome ... I hope it's OK that I am answering many of them (of course others are also welcome to give their opinion!)

The "easy integration of open-source software" is demonstrated by the NE10 example in the Makers Blog. This example uses the PLCnext add-in for Eclipse on Linux to build a C++ project that includes the open-source NE10 library. This demonstrates how an open-source C/C++ library can be cross-compiled and used in your own PLCnext Control project.

Is it for example also possible to make a C++ project on Linux?

Yes - in a number of ways:

  1. You can use Eclipse with the PLCnext Add-in to create C++ projects for PLCnext, on a Linux platform.
  2. It is also possible to use Visual Studio Code on Linux to create C++ components and programs for PLCnext Control, but in this case we do not have a PLCnext add-in for Visual Studio Code, so there is a bit more work to do. If you want to build PLCnext Components and Programs in Visual Studio Code, then you can create the project skeleton using the PLCnext CLI tool, edit the code using VS Code, and then use the PLCnext CLI tool to help with the build process (if you want)

Is it even possible to make a C++ project in VS which I can use for the PLCNext?

Yes (as mentioned above - assuming you are talking about Visual Studio Code, and not Visual Studio). There is an example of how to do this in the Makers Blog article.- "How to use Visual Studio Code to write C++ for PLCnext". It would also be possible to do something similar using Visual Studio on Windows, but we don't have any examples showing this.

If your C++ application does not require the use of PLCnext Components or Programs - e.g. if it does not need to access any I/O, or does not need to use any other resources provided by the PLCnext Control framework - then you can simply cross-compile your C++ application using the appropriate Software Development Kit (SDK), similar to the "Hello PLCnext" example shown in Part 1 of the Sample Runtime tutorial.

Finally, if you would like to broadly describe the project you are working on (without giving away anything sensitive or confidential), then we might be able to point you towards examples or tutorials that could get you started.

Hope this helps.

- Martin.

 

 

 

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
Arne Smets Accepted Answer Pending Moderation
0
Votes
Undo

Thanks Martin! 

Arne Smets Accepted Answer Pending Moderation
0
Votes
Undo

"PLCnext Runtime System architecture in a nutshell | PLCnext Technology Basics" video : https://www.youtube.com/watch?v=y38tVUaYoo8&feature=youtu.be

In this video I get a good idea about the PLCNext, but I don't understand the first part. About just using the SDK or generic toolchain to run the different languages. When do I want to use this? If I understand it right, these parts can't be realtime? And it is not possible to use all the i/o's?

Thanks,

Arne

Martin PLCnext Team Accepted Answer Pending Moderation
1
Votes
Undo

When do I want to use this?

If your C++ application does not require the use of PLCnext Components or Programs - e.g. if it does not need to access any I/O, or does not need to use any other resources provided by the PLCnext Control platform - then you can simply cross-compile your C++ application using the appropriate Software Development Kit (SDK), similar to the "Hello PLCnext" example shown in Part 1 of the Sample Runtime tutorial.

One example of this type of application is node.js, which can be built from source for PLCnext targets. Applications like node.js are really useful, but why run it on a PLCnext Control? Well - node.js applications can exchange data with other applications running on the PLC, including PLCnext Engineer projects, and then do stuff with that data.

If you are writing your application from scratch, and your application needs to directly interact with PLC I/O or other services provided by the PLCnext Control platform (e.g. the ESM or RSC services), then you are better building your application using PLCnext Component(s) and/or Program(s), rather than as an application that is completely independent of the PLCnext Control platform.

these parts can't be realtime?

No, that's not correct. In the video you can see that the Linux kernel includes the PREEMPT-RT patch, so it is possible for these "external" applications to create threads and schedule them to run on a real-time priority (this is demonstrated in Part 6 of the Sample Runtime tutorial). But this requires advanced, low-level operating system knowledge, and it is much easier to use the ESM (provided by the PLCnext Control platform) to run real-time processes, if possible.

And it is not possible to use all the i/o's?

That's not completely correct ... for applications that run entirely independently of the PLCnext Control platform (like node.js), I/O data can be exchanged using standard interfaces like REST or OPC UA, but this needs a bit of configuration, and the I/O data will definitely not be exchanged on a deterministic cycle. That's fine for some applications (let's say home automation, for example), but would be unacceptable for most industrial control applications (e.g. PID control loops).

For applications that need real-time access to I/O data, creating your C++ application in the PLCnext Control framework - using PLCnext Components and Programs - is by far the simplest option.

Hope this helps.

- Martin.

 

 

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
Arne Smets Accepted Answer Pending Moderation
0
Votes
Undo

In your video you describe the PLM, ACF and the Servicemanager. Is there an example online about setting this up? I don't understand how I could be able to see the difference between the real-time and non-real-time C++ programs. And is this also possible with the other plug-ins or only with eclipse?

Arne

Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

Hi Arne,

To make sure we're using terms the same way - these are the (rough) definitions used in the PLCnext world:

  • C++ Components - can not be scheduled to run on the ESM, and so are not considered "real-time".
  • C++ Programs - can only run on the ESM.

So using this terminology, there is no such thing as a "non-real-time C++ program". There are only real-time C++ Programs (which run on the ESM), and non-real-time Components (which do not run on the ESM).

C++ Programs can only be provided by C++ Components that are started by the Program Library Manager (PLM).

C++ Components that do not need to provide C++ Programs can be started by either the PLM or the ACF, but there is no need to use the PLM if no programs are provided.

Does this make sense?

 

 

 

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
Arne Smets Accepted Answer Pending Moderation
0
Votes
Undo

Thanks, this does make sense!

Martin PLCnext Team Accepted Answer Pending Moderation
1
Votes
Undo

... and just to answer some other points you raised:

The Service Manager is an internal PLCnext Component that provides a mechanism to register and use RSC Services on the PLCnext Control. There is no need to consider the Service Manager for very simple C++ projects.

And is this also possible with the other plug-ins or only with eclipse?

By far the easiest way to build C++ Components and Programs is using Eclipse with the PLCnext add-in. It is possible to build PLCnext C++ Components and Programs in other (much more complicated) ways, but why would you want to?   :-)

- Martin.

 

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
Arne Smets Accepted Answer Pending Moderation
0
Votes
Undo

I'm coming back once more on this subject. I do think I understand it quite good, but I still got some questions.

In the video, Martin is telling that it's possible to write deterministic real time C# programs. But as far as I read and understand it's only possible to make function(block)s, to implement in IEC code.Is that true? Does this work exactly the same with simulink?

With the Eclipse IDE, a new project contains Program.cpp and Component.cpp. I saw it's possible to run these directly on the AXCF2152, but for now I want to use PLCnext Engineer for configuration as I think it's much easier and clear. A program can be loaded as a task in PLCnext engineer to run it on the ESM, right? Then it's also possible to wright components. These components can provide deterministic real-time C++ programs via the PLM. (Is the plm doing that or should I configure the plm somewhere myself? Here I get confused a bit). After that Martin says if there is no need for real-time, you can just 'use' the ACF. How can I use it? Can I use the components as a block, like the C# blocks. Maybe I don't understand the component part..

 

Arne

Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

Hi Arne,

But as far as I read and understand it's only possible to make function(block)s, to implement in IEC code.Is that true?

No, it is also possible to create Programs in C#. If this is somethng you really want to try then we can discuss this separately - it is not as straightforward as the Functions (Blocks) in C#.

Does this work exactly the same with simulink?

Yes, it is possible to create both Programs and Function (Blocks) in Simulink.

I saw it's possible to run these directly on the AXCF2152, but for now I want to use PLCnext Engineer for configuration as I think it's much easier and clear.

Good idea.  :-)

A program can be loaded as a task in PLCnext engineer to run it on the ESM, right?

Correct - when this is done in PLCnext Engineer, what is happening in the background is: PLCnext Engineer is configuring the PLM to load the C++ Component that you wrote - the one that provides the C++ program that you wrote. Only then can the C++ program be instantiated in the task on the ESM. In PLCnext Engineer, this happens in the background so you don't need to worry about it.

Then it's also possible to wright components. These components can provide deterministic real-time C++ programs via the PLM.

Correct. Not only is it possible to write C++ components, but (as outlined above), it is necessary to have at least one C++ Component to provide C++ programs - even when you are instantiating the C++ program in PLCnext Engineer. In PLCnext Engineer you can see your C++ Component in the Tree View (on the right) - it contains your C++ program.

These components can provide deterministic real-time C++ programs via the PLM. (Is the plm doing that or should I configure the plm somewhere myself?

It depends whether you are using PLCnext Engineer, or not. Either way, to instantiate a real-time C++ program on the ESM, the process is the same:

  1. The C++ Component must be loaded by the PLM. If you are using PLCnext Engineer, it configures this for you. If you are not using PLCnext Engineer, you must do this yourself by editing XML files on the PLC.
  2. Once the C++ Component is loaded by the PLM, then instances of the C++ Program provided by that Component can be instantiated. If you are using PLCnext Engineer then you do this by dragging your C++ program from the tree view on the right, into a Task on the ESM. If you are not using PLCnext Engineer, then you must do this by editing XML files on the PLC.

After that Martin says if there is no need for real-time, you can just 'use' the ACF. How can I use it?

Now we have moved into an area where PLCnext Engineer cannot help us. If you want to write a C++ Component that does not contain any real-time programs, then you cannot (currently) instantiate that C++ Component using PLCnext Engineer. In this case (currently) the only option is to configure this yourself, by editing XML files on the PLC. As I discuss on Day 4 of the MQTT Diary series, we can load the C++ Component using a PLM configuration file - like we would if the component had programs - or we can load the C++ Component using an ACF configuration file. Either way, it involves editing XML configuration files directly on the PLC - this is a topic for a whole other discussion.

Can I use the components as a block, like the C# blocks.

Well, perhaps - but Components are not as simple to link together as Functions and Function Blocks in PLCnext Engineer's FDB editor. If you want to link Components together like "blocks", then you will need to do this using GDS ports, similar to the way that you link C++ Program instances together.

I usually think of C++ Components as the things I write if I want to create non-real-time services on the PLC, like the MQTT client service, or the OPC UA server, or the Proficloud TSD service. As soon as I need determinstic, real-time performance, I add one or more Programs to my Component (and perhaps my Component is otherwise "empty").

The question is - does your application need determinstic real-time capability, or only non-real-time capability, or a mixture of both?

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
Arne Smets Accepted Answer Pending Moderation
0
Votes
Undo

So if I create a C++ project, I get one  (or more) component and one (or more) programs. I made a small test program, and didn't change the component.h and cpp. However, When I search in the tree on the right, the library contains MyComponent, wich contains MyProgram. I think the thing I don't understand is what is the difference between them, which one I want to use in what case and how they relate to eachother...

I'm currently just researching about the PLCnext and the possibilities of it, how to use it and which language options there are and what the pros and cons are. I'm doing my internship and this is kind of the research part, so that if the company wants to use the PLCnext in a while they can easily start with it. I am going to start an implementation of a project soon. I do think that project has to be deterministic because it contains PID as far as I know, but right now I don't know the exact working.

 

That's the reason I'm just testing out a bit and want to understand everything before I start. If I choose to make a project in c# in combination with IEC, I have to explain why I choose it instead of C++, that's the reason for  all my questions :)

 

Thanks,

Arne

Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

So if I create a C++ project, I get one (or more) component and one (or more) programs. I made a small test program, and didn't change the component.h and cpp. However, When I search in the tree on the right, the library contains MyComponent, wich contains MyProgram.

That's right - even though you didn't change the component .cpp and .hpp files, if you look at them there's a lot going on there already - including a "Program Factory".

I think the thing I don't understand is what is the difference between them, which one I want to use in what case and how they relate to eachother...

We have plans to do a tutorial series similar to the Sample Runtime series, but for Extension Components, where we build up the idea of "Components" and "Programs" from first principles, which hopefully will make it easier to understand. Two of the steps in series might look something like:

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

1. How can developers extend the PLCnext Runtime, with (for example) custom services?

Use the Application Component Framework (ACF) to create C++ "Components" that are managed by the PLCnext Runtime. These C++ Components - which inherit from "ComponentBase" - can implement non-real-time processes and services. This is how many of the services that come with the PLCnext runtime - like the OPC UA server and the Proficloud TSD service - are written.

2. But developers also want to write C++ programs that run in real-time, on the ESM. How can they do that?

There is a special type of ACF component that has been designed to help with this. These special Components - which inherit from "ProgramComponentBase" - are managed by the Program Library Manager (PLM). After one of these "Program Components" is instantiated, it can provide real-time C++ programs that run on the ESM.

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

So, take your pick - C++ Component, or C++ Program, or a combination of the two.

IEC programs (including function block(s) written in C#) and C# Programs are a little different - they do not directly use the Application Component Framework (which is a C++ framework), but instead are compiled by PLCnext Engineer to run on the "Embedded Common Language Runtime" (ECLR). As the name implies, the ECLR is an embedded version of the .NET framework designed for real-time applications.

It is quite complex ... and it probably takes experience on a few projects to get a really good understanding. No one should expect you to come up with the "perfect" structure for a PLCnext Control application before you've even started your first PLCnext project.

In this case, if your employer is happy for you to share some information about the project, we are always happy to help advise on what we think might be the best solution. Or if you want us to review a draft software design that you do for your employer, where you justify your design decisions, then perhaps that could be a good basis for discussion.

- Martin.

 

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
Arne Smets Accepted Answer Pending Moderation
0
Votes
Undo

Allright! Really appreciate your anwers, Martin! So, I have a last conclusion that I want to be checked.

"After one of these "Program Components""

A program is actually a special component (can be used in real-time).  I just noticed that the Compont.h is included in the Program.h. 

 

I have to check if I am allowed to share some data or some principles, but if I am I will contact you if needed. 

Thanks!

Arne

 

 

Martin PLCnext Team Accepted Answer Pending Moderation
0
Votes
Undo

A program is actually a special component (can be used in real-time).

No, not by our definitions of "Component" and "Program". In the expression "Program Component", we uses "Program" as an adjective, and "Component" as a noun - a "program component" is a special type of component that can supply program instances.

I might as well give the technical definitions we use:

  • A Component is a C++ class that inherits from the ComponentBase class.
  • A Program Component is a C++ class that inherits from the ProgramComponentBase class. It also inherits from the ComponentBase class, just like every other component. So, a Program Component is just one special type of component. The ProgramComponentBase class includes a mechanism for generating Program instances, using a "Program Factory".
  • A Program is a C++ class that inherits from the ProgramBase class. Programs always "belong" to a Program Component - which is why you see the component header file included in the Program definition (every program keeps a reference to its "parent" component). Instances of a Program can only be created using the Program Factory in the "parent" Component.

 

I just noticed that the Compont.h is included in the Program.h.

That's right, because every program keeps a reference to its "parent" component - you can see this Component reference further down in the Program.h file.

- Martin.

Phoenix Contact Electronics Headquarters - PLCnext Runtime Product Management and Support
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.