muhsin
Sometimes I get an error when I open execution control. But sometimes I don't. This is very frustrating.openPlc.pngopenPlc2.pngopenPlc3.png
Reply 0 0
thiagoralves
This doesn’t seem to be related to EN pin. It is complaining that you’re trying to compare a BOOL with a DINT. I can’t know for sure without your actual project file
Reply 0 0
muhsin
Here is my project file. The error is in "AutoDown_Act".
Reply 0 0
thiagoralves
That's the first time I'm seeing something like this. It seems to be a bug on MatIEC, the compiler OpenPLC uses to convert ST code to C. The C code generated by MatIEC in your program example is missing the definition of some blocks. The weird thing is that if you change the GE to a GT for example, it generates the definition correctly. I'll have to dig deeper into that. Meanwhile you can just remove the EN pins and use AND blocks connected to the output of your GE/LE/GT blocks to enable/disable the output of them.
Reply 0 0
muhsin
Thank you for your response. But adding "AND" blocks complicates the code.
Reply 0 0
muhsin
Additionally, while this problem occurs in some "GE" blocks, it does not occur in some "GE" blocks. It seemed completely random to me. Note: The problem sometimes occurs for GE, GT, LT, LE and MOVE blocks.
Reply 0 0
muhsin
Could the problem be caused by me copying and pasting some blocks? I haven't created a new project and tried it. I'm not sure for this reason.
Reply 0 0
thiagoralves
That shouldn’t matter. The compilation process happens in 3 steps: PLCopen XML (your whole project) to Structured Text, then Structured Text to C, then C to machine language. Your ST code looks clean. The problem happens on the ST to C part, which is what MatIEC does. 
Reply 0 0
thiagoralves
And yes, the problem seems to be quite random. Some GE/GT/LT blocks work, some don’t. 
Reply 0 0
thiagoralves
Just had an idea that might solve your problem as a workaround. You could create your own GE/GT/LT blocks with the enable pin that are essentially calling regular GE/GT/LT blocks with an AND port at the end for the enable. Then you just have to replace the regular blocks with your custom made blocks (no need to re-wire, just double-click and switch block. As long as they have the same number of pins it will work). I know it’s not ideal, but at least it won’t pollute the code and should work just fine, at least until I figure out what is wrong with MatIEC
Reply 0 0
thiagoralves
This is mad!! Look at this snippet:
Untitled.jpg
 
This is a search for "MAIN_GE__BOOL__DINT on the code generated by MatIEC from your project. The first block with lines starting with "static inline ..." are function definitions, and the second block are places where those functions are being used. You can see that for the first 4 functions, the name matches and it works. For the last function, it was defined as __MAIN_GE__BOOL__DINT17, but used as __MAIN_GE__BOOL__DINT1. Same thing happens with the other functions:
Screen Shot 2024-06-25 at 9.25.16 PM.png
 
It seems that MatIEC is struggling with the counter increment for these functions. I'm not familiar with MatIEC code, so this will be a hard fix... I would try reporting it to them, but they haven't updated their code in quite a long time, so I doubt that they would work on this anyway.
Reply 0 0
Reply