mbunds
 
I ran into an oddball issue when I finished converting a project from the old OpenPLC Editor/Runtime to the new version, where the runtime presented a server error when I uploaded/compiled the project:

2025-05-14_11-38-17.png
 
...But appears to have compiled successfully anyway, because the PLC instance can be started and run with no errors, and the PSM appears to be functional, but "normal" operation cannot be verified because monitoring does not display my variables as the old versions does, and I have not yet tested advanced comms until the smaller items are resolved.
 
So this is about a smaller issue.
 
Below is an image illustrating a very simple project I began in order to troubleshoot issues with the much, much larger OpenSIM DCS project.

It has two variables declared for globals and the main POU, but errors-out when compiling in the runtime due to missing ";" in the external variable.

If I declare these in main as local, the runtime compiles them just fine. These are documented in the image below.

I find this puzzling as my main project, which compiles and runs perfectly on the old version, has just "completed" being refactored into the new editor and runtime, and compiles without issue in the editor, but my project is full of external variables which do not cause compiler errors
 
The runtime compiler causes other strange issues, which will be addressed in another dispatch if I can't get the runtime to behave as the old one does.
 
2025-05-14_11-33-04.png
 
It appears the editor has been updated since, but I'm not sure about the runtime, which is the version having Step 7 integrated, (and I am eager to test it). If an update has addressed this issue, then I'll get updated and test for the other issues.
Reply 0 0
thiagoralves
The runtime hasn't changed, so you should expect the exact same behavior (like monitoring variables, comms and PSM) no matter if the program was created on the new or old editor. I believe the issue is most likely related to your program. From the screenshots it is hard to see, but I believe you misspelled "heartbeat" in one of the instances, which could be causing the errors. If you attach your project file here, I can take a look.
Reply 0 0
mbunds
BTW: Attached is the OpenSIM DCS project .st code generated for the OpenPLC runtime. This code compiles from
the .json project to this .st project with no issues, but the runtime produces an "Internal Server Error"
when compiling the .st program.

In spite of the server error though, when the runtime GUI is reloaded, this project starts and appears to
run without errors, although nothing shows up on the monitor window, which is why I started the smaller project.
Reply 0 0
thiagoralves
Your code contain invalid characters on your comments
Screenshot 2025-05-14 at 3.06.04 PM.png
 
This is what is causing the compiler to crash. I removed those comments and the compiler went through the code without crashing. The code still does not compile as there seems to have other typos and errors on it.
 
Another issue that I found, and this is related to the new editor, is that when you create new tasks, the time interval for them comes messed up if you don't alter it:
    TASK task0(INTERVAL := T#20ms,PRIORITY := 0);
    TASK task1(INTERVAL := T#0d0h0min0s20ms0µs,PRIORITY := 0);
    TASK task2(INTERVAL := T#0d0h0min0s20ms0µs,PRIORITY := 0);
    TASK ONE_SECOND_PULSE(INTERVAL := T#1s,PRIORITY := 0);
 
The "µ" character is also invalid and it is being inserted by the new editor. If you simply click on the "Interval" line for each task to open the time dialog, even if you don't change the interval, it will fix the issue and print only T#20ms instead of T#0d0h0min0s20ms0µs
Reply 0 0
mbunds
Your code contain invalid characters on your comments
Screenshot 2025-05-14 at 3.06.04 PM.png
 
This is what is causing the compiler to crash. I removed those comments and the compiler went through the code without crashing. The code still does not compile as there seems to have other typos and errors on it.
 
Another issue that I found, and this is related to the new editor, is that when you create new tasks, the time interval for them comes messed up if you don't alter it:
  1. TASK task0(INTERVAL := T#20ms,PRIORITY := 0);
  2.     TASK task1(INTERVAL := T#0d0h0min0s20ms0µs,PRIORITY := 0);
  3.     TASK task2(INTERVAL := T#0d0h0min0s20ms0µs,PRIORITY := 0);
  4.     TASK ONE_SECOND_PULSE(INTERVAL := T#1s,PRIORITY := 0);
 
The "µ" character is also invalid and it is being inserted by the new editor. If you simply click on the "Interval" line for each task to open the time dialog, even if you don't change the interval, it will fix the issue and print only T#20ms instead of T#0d0h0min0s20ms0µs
Aha! Thank you Dr. Alves!
 
Those odd characters are the consequences of using ChatGPT to help refactor the code. I'll be more careful with it in the future!

I found some earlier which were causing the editor compiler to fail, so I thought I had found all of them once it succeeded.

I did experiment with the simple project, and it absolutely does not like to have external variables defined in an early project, even when the typos have been fixed. I'm still trying to figure that out

Reply 0 0
thiagoralves
Do you mind sharing your simple project here? I can take a look to see what is going on
Reply 0 0
mbunds
Do you mind sharing your simple project here? I can take a look to see what is going on
Here is the most basic version, which compiles fine from the editor, but causes errors when the runtime tries to compile it.
This is especially puzzling since the OpenSIM DCS project is full of externals and compiles and runs in spite of the server errors caused by the bad characters in the unit conversion tables. I am working on those now.
(Brought in as "project.txt" since .json is not among acceptable upload types.)
Reply 0 0
thiagoralves
I don’t think the OpenSIM project compiles. You’re probably just running a previously compiled version. When the compilation fails, the OpenPLC binary still contains the previously successful project. I’ll check your project and see what’s going on
Reply 0 0
mbunds
I don’t think the OpenSIM project compiles. You’re probably just running a previously compiled version. When the compilation fails, the OpenPLC binary still contains the previously successful project. I’ll check your project and see what’s going on
Thank you sir, but you don't have to waste any time on my project.

I have found that browsing the forums, or waiting for improvements always solves "problems", and I hate wasting your time with dumb problems like typos or odd unicode characters.

Your help has put me back on track, and I am certain that if any real problems exist, the community will tell you which are actually important and I don't wish to side-track your efforts to work on user projects, or solve problems caused by my user errors.
Reply 1 0
thiagoralves
That's ok. Sometimes exploring user projects like yours help me find bugs on the editor that I wouldn't be able to find otherwise. That was the case with the task generation code that was inserting the µs invalid character, and now with this small project of yours using external variables I just found another bug. You can't have initial value on external variables. The initial value of external variables must be defined at the source. So if you simply move the initial values you placed in the main program into the resource global variables your program will compile and work just fine. The v3 editor had the initial value field blocked for all variables defined as external, which prevents this user error. I must do the same thing with the v4 editor. Thanks 🙂
Reply 0 0
mbunds
That's ok. Sometimes exploring user projects like yours help me find bugs on the editor that I wouldn't be able to find otherwise. That was the case with the task generation code that was inserting the µs invalid character, and now with this small project of yours using external variables I just found another bug. You can't have initial value on external variables. The initial value of external variables must be defined at the source. So if you simply move the initial values you placed in the main program into the resource global variables your program will compile and work just fine. The v3 editor had the initial value field blocked for all variables defined as external, which prevents this user error. I must do the same thing with the v4 editor. Thanks 🙂
Thank you once again!
 
I failed to compare the old with the new, another thing which probably should have been obvious. That solves that mystery; now I can finish fixing the big project and test the ladder which I'm not completely convinced I refactored correctly, although it must be fairly close. The big project did actually compile and run even if the runtime web GUI choked on it with the bad characters, as it was the only project ever loaded onto the new OpenPLC LXC I built specifically to test the new runtime. Strange, but true, after the "server error", and I back-up to the dashboard, then to programs, there it is, and it starts, reports my PSM awaiting client connections (although I haven't connected any yet).
 
All will be well after I finish fixing any issues remaining in my OpenPLC project and get monitoring up again, then I can test the Siemens connections.
 
The PSM script prototype which currently accepts and maintains client connections and establishes peer connections over MODBUS is attached. I use this script to read and write data among any number of connected peers and clients, including an ancient hardware DL-06 by Automation Direct via a TCP/MODBUS RTU converter.

PXL_20250403_213524221 CROPPED.jpg
Reply 1 0
Reply