Hi, I am doing some application for the PLCnext. Most of the code I write in c++. 1: I am looking for a good way to be able to test the C++ code that I am doing for PLCnext. (unit test / google test) The “problem” is that right now I build some library (.pcwlx) from the c++ files, that can be added in PLCnext engineer(using Eclipse atm). Is there some smart way to able to build the files to executable so that I can test the code in unit test possible to google test. I tried to make a separate GCC target, but then realizing how much of the functionality that was missing includes, I want to see what solutions the experts have first. 2: When the complete program is ready in PLCnext Engineer. How can I in a good way do automatic testing with for instance c++ or c# program or similar with the complete PLCnext software? Is it possible to somehow simulate the PLC on my computer or interface to the PLC-hardware in an easy way? You made it possible to interface with Matlab Simulink, but would it be possible to write some code, and use this interface without having Simulink?
Hello vengzor, please find the answers to your questions below: 1: I am looking for a good way to be able to test the C++ code that I am doing for PLCnext. (unit test / google test) The “problem” is that right now I build some library (.pcwlx) from the c++ files, that can be added in PLCnext engineer(using Eclipse atm). Is there some smart way to able to build the files to executable so that I can test the code in unit test possible to google test. I tried to make a separate GCC target, but then realizing how much of the functionality that was missing includes, I want to see what solutions the experts have first. → Currently it is possible to implement C# Functions and Function Blocks in Visual Studio, you can try to use following description to realize the unit-tests: https://github.com/MicrosoftDocs/visualstudio-docs/blob/master/docs/test/walkthrough-creating-and-running-unit-tests-for-managed-code.md → Could you give me a short feedback, if it will be usable for you to perform the tests within a c++ component (without realtime programs), please? 2: When the complete program is ready in PLCnext Engineer. How can I in a good way do automatic testing with for instance c++ or c# program or similar with the complete PLCnext software? Is it possible to somehow simulate the PLC on my computer or interface to the PLC-hardware in an easy way? → When all programs are instantiated in PLCnext Engineer, you can download the project to plcnext target, start a self-test-mode and execute all needed (dynamically) test sequences. The test sequences you have to implement by yourself. → Currently it is not possible to simulate the plcnext controller on the PC, but this feature is planned. You made it possible to interface with Matlab Simulink, but would it be possible to write some code, and use this interface without having Simulink? → Yes it is possible, you can define the port-variables for MatLab “Simulink FB” and integrate the FB’s/Functionality at a later time. If you have additionally questions, please don’t hesitate to ask!
Thanks & Best Regards, Eduard
Hi, Thanks for the feedback. Yes I can get a unit test up and running with VS as you show in the link, but you are right it is very complicated to get it running without the realtime program. This way is probable not the way to go for me. “-> When all programs are instantiated in PLCnext Engineer, you can download the project to plcnext target, start a self-test-mode and execute all needed (dynamically) test sequences. The test sequences you have to implement by yourself.” Can you explain how this work. How do I set PLCnext in “self-test-mode” and run a test sequence ? When do you plan to release a simulated PLCnext target for PC(Win and/or Linux) ? “-> Yes it is possible, you can define the port-variables for MatLab “Simulink FB” and integrate the FB’s/Functionality at a later time.” I don’t think i understand the above. Is there some kind of special port for Matlab ? I don’t have Matlab right now so I was looking for a way to make a simple simulator of my physical system, and test this against the PLCnext control code. I am unsure about howto make the interface from Model ↔ PLCnext functionality, and how to execute it. Thanks, Christian
Hello Christian, please see the answers to your questions below: Can you explain how this work. How do I set PLCnext in “self-test-mode” and run a test sequence ? → With “self-test-mode” I mean your own Testprogram for testing of Applications, please see the possible solution under following link: https://www.ni.com/de-de/shop/data-acquisition-and-control/application-software-for-data-acquisition-and-control-category/what-is-veristand.html When do you plan to release a simulated PLCnext target for PC(Win and/or Linux) ? → This feature is planned, but currently I can’t give you any information as to when it will be available. I don’t think i understand the above. Is there some kind of special port for Matlab ? → No, that are the standart port-variable or you can also use the global/external variable as SW-Interface. I don’t have Matlab right now so I was looking for a way to make a simple simulator of my physical system, and test this against the PLCnext control code. I am unsure about howto make the interface from Model → You can implement for example a FB in IEC61131 or C++ as a simple simulator of your physical system (e.g. linear standard elements P-, PT1-, PT2 etc) and use this FB as SW-Interface (with defined global- or portvariables) for developing of project application. If the complex Matlab Simulink model is ready, you can exchange the IEC61131 or C++ FB with MatLab Simulink FB. Best Regards, Eduard