songyanghua
Hello, when I referenced the official document ADDING NEW BLOCKS TO OPENPLC EDITOR'S LIBRARY to create a custom block, I found an error during compilation and found that TEST was not found. After checking, I followed the requirements of each step to set it. On the Win11 system, I hope you can help me. I haven't found the reason for several days!
0e3299f2fb9758a349c83a334cb4c0dd.png17c9f4a5a9e78bda26026cd8e97fa14d.png49e31f5864b567d4db9f47ca35ae5488.png

Delete that module to pass

Reply 0 0
thiagoralves
It looks like you modified the Editor substantially, so the instructions on the OpenPLC documentation page might not fully apply to your case. I don't know where you're getting the MatIEC lib for your build, but most likely it does not contain any definition for your new "TEST" block. You must update MatIEC lib files to include your new block C source code and definition.
Reply 0 0
songyanghua
It looks like you modified the Editor substantially, so the instructions on the OpenPLC documentation page might not fully apply to your case. I don't know where you're getting the MatIEC lib for your build, but most likely it does not contain any definition for your new "TEST" block. You must update MatIEC lib files to include your new block C source code and definition.
Sorry, I downloaded the source code from the official website a few days ago and updated it into my project. Then, I made modifications according to the official documentation. The MatIEC library should be new, and all custom. xml,. h, and. txt files have been modified. After checking and confirming, the compilation shows an error with the TEST name. Is there still any part of the source code that has not been modified? Looking forward to your reply very much, thank you
Reply 0 0
thiagoralves
From your screenshots and the build system output messages, it doesn't look like the original OpenPLC Editor. You're generating code for a target that is not even officially supported on OpenPLC. Maybe you should start with the original OpenPLC Editor code to make sure you understood the process correctly, then you can move it over to your custom build.
 
As I said, this error message either means that your MatIEC library was not modified correctly to include your new TEST block, or that you're not linking it properly during your custom build process. The instructions on the OpenPLC documentation include a Python tool that makes the process a lot easier. Try using that tool (instead of making the modifications manually) on the original OpenPLC Editor to include your TEST block, and then go from there.
Reply 0 0
songyanghua
从您的屏幕截图和构建系统输出消息来看,它看起来不像原始的 OpenPLC 编辑器。您正在为OpenPLC上甚至没有正式支持的目标生成代码。也许您应该从原始的OpenPLC编辑器代码开始,以确保您正确理解该过程,然后您可以将其移动到自定义构建中。
 
正如我所说,此错误消息要么意味着您的 MatIEC 库未正确修改以包含新的 TEST 块,要么表示您在自定义构建过程中未正确链接它。OpenPLC文档中的说明包括一个Python工具,该工具使该过程变得容易得多。尝试在原始OpenPLC编辑器上使用该工具(而不是手动进行修改)以包含您的TEST块,然后从那里开始。
1.Hello, the update to the MatIEC library you mentioned refers to/OpenPLC_ Editor/matic/lib and
/OpenPLC_ Is there a latest file replacement for the Editor/editor/arduino/src/lib libraries? Then add custom function block content?
2. If I expand the content of the custom block on top of the original code, such as SR, and define an SR2 below SR without creating new XML, h, txt, and adding it below the original code, is there a problem?
3. I will try using the most primitive editor to verify if my modifications are linked correctly
Reply 0 0
thiagoralves
1. You must include your new block changes to the MatIEC lib you're using to build. Since your build system is different than the original OpenPLC Editor I cannot answer that question because I don't know how your build system works. On the original OpenPLC Editor, you must change both /matiec/lib (used for simulation) and /arduino/src/lib (used for arduino builds).
 
2. You can place the definition of your custom blocks anywhere, but it is better to place them in separate files to keep things more organized.
 
3. Ok.
Reply 0 0
songyanghua
1. 您必须将新的块更改包含在您用于构建的 MatIEC 库中。由于您的构建系统与原始的OpenPLC编辑器不同,因此我无法回答这个问题,因为我不知道您的构建系统是如何工作的。在原始的 OpenPLC 编辑器上,您必须更改 /matiec/lib(用于模拟)和 /arduino/src/lib(用于 arduino 构建)。
 
2.您可以将自定义块的定义放在任何地方,但最好将它们放在单独的文件中,以使事情更有条理。
 
3. 好的。
1. How can I expose my build system to better address bug reporting?
2. I compiled the definition of custom block SR2 in multiple locations using the same SR source code, but the error persists. Are there any missing areas that have not been supplemented with code?
1.png2.png3.png4.png5.png6.png7.png8.png9.png
 
 

Looking forward to your reply. Thanks!

Reply 0 0
songyanghua
 
 

This is my IEC library

Reply 0 0
thiagoralves
I don't know how your Editor works. What you have running on your computer is not OpenPLC Editor, so I cannot help you. If you want to add a custom block on OpenPLC Editor, here are the steps:
 
1. Download OpenPLC Editor from https://autonomylogic.com
2. Install OpenPLC Editor and create a new project
3. On your new project, create a function block with your desired code (grey plus icon -> function block)
4. Save your project and export the .st file clicking on the orange down arrow icon at the toolbar
6. Launch OpenPLC Import tool passing as argument the .st file you exported on step 4
7. Done!
Reply 0 0
songyanghua
我不知道你的编辑器是如何工作的。您在计算机上运行的不是OpenPLC编辑器,所以我无法帮助您。如果要在OpenPLC编辑器上添加自定义块,请执行以下步骤:
 
1. 从 https://autonomylogic.com 下载OpenPLC编辑器
2. 安装OpenPLC编辑器并创建一个新项目
3. 在新项目上,使用所需代码创建一个功能块(灰色加号图标 ->功能块)
4. 保存您的项目并单击工具栏上的橙色向下箭头图标导出 .st 文件
6.启动OpenPLC导入工具,将您在步骤4中导出的.st文件作为参数传递
7. 完成!
Reply 0 0
thiagoralves
I don’t know. As I have already said a million times, I have no idea how your custom build process works. I don’t have access to your customized version of OpenPLC Editor. Where is the code published? There are several things that could be wrong with it. Most likely the issue is with the MatIEC lib you’re using on your custom build process, but I can’t be sure. I can only help if you use the original OpenPLC Editor
Reply 0 0
songyanghua
我不知道。正如我已经说过一百万次的那样,我不知道您的自定义构建过程是如何工作的。我无法访问您的自定义版本的OpenPLC编辑器。代码发布在哪里?有几件事可能是错误的。问题很可能出在您自定义构建过程中使用的 MatIEC 库上,但我不确定。我只能帮忙,如果你使用原来的OpenPLC编辑器
OK, I know what you mean. I'll search for the files needed to compile and solve another problem. For example, for the AND block in the bitwise operation, I want its input data IN1 and IN2 to be of type Boolean and change their default value to True=1. In which file should I change its default value to True or False? NOTE: This is the default value, not the initial value.
12.png
Reply 0 0
thiagoralves
There is no such thing as default value in ladder logic. If a block pin is not connected to anything then its value is always assumed to be zero. If you need an AND block with different properties then the best and easy way forward is to create a new custom block with the behavior you want. Modifying the standard OpenPLC library will make it deviate from the IEC 61131-3 standard, and I strongly advise against that.
Reply 0 0
songyanghua
梯形图逻辑中没有默认值这样的东西。如果块引脚未连接到任何内容,则始终假定其值为零。如果您需要具有不同属性的 AND 块,那么最好和简单的方法是创建一个具有所需行为的新自定义块。修改标准的OpenPLC库将使其偏离IEC 61131-3标准,我强烈建议不要这样做。
Ok, I see. Thank you very much for your reply. I have a new question. What if it's a timer block in the program? For example TOF and TON, is it possible to set their initial values, for example the minimum pulse width time range is 0-3600000ms, the step is 10ms, and the default value is 150ms? If possible, can I set up these three operations by changing which part of the source code below and where?
 
1.png2.png3.png
Reply 0 0
thiagoralves
Please stop trying to modify the IEC 61131-3 library. You're just going to get in trouble trying to do that. As I said before, modifying the standard OpenPLC library will make it deviate from the IEC 61131-3 standard, and I strongly advise against that.
 
With that being said, I don't know exactly what you are trying to accomplish. Maybe you could be a little more specific about what your project is, but it appears to me that you just need some logic implemented. You don't have to modify OpenPLC Editor blocks to create your logic. In contrary, you can just use the blocks as they are to create your logic, like everyone else does. For example, on your timers thing, although I haven't understood exactly what you need, you can possibly just use the regular TON and TOF timers to create the logic you need. Once you're happy with your logic, you can encapsulate it into a Function Block so that it can be reused many times in your program easily. You don't have to modify the Editor's source code for that. That's just a normal part of PLC programming.
Reply 0 0
Reply