I am using the Codesys RTE for controlling a motion system. In my application I cyclic poll with special FBs the state of the motion system. This works quite well, but some times the PLC runs into an exception.
The log shows the following two exceptions which occur at the same time:
If I double click the exception the position in the source code is marked. But at this position nothing strange happens, only normal logical operations. Also at this position no pointers, references, strings or arrays are used. I also checked all variables/FB instances in this POU in online mode and the values seem to be correct. Furthermore, the point in the source code is not always the same. It differs always between in a range of about 10 code lines.
My first guess was that this exception is somehow generated by the wrong use of pointers. But could it also be that the exceptions are generated by wrong task scheduling? I have seen that the max execution time of one task is sometimes much higher than its cycle time.
Maybe someone has a hint what I should further try.
Thank you
BR
Martin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My guess also would be a sporadic overrun of the task cycle time.
Do you have any time-consuming operations, that are not called cyclical, but triggered by time or when a buffer is full?
E.g. when you have file operations like writing a looger file when a buiffer is full, this may cause trouble because file access needs some time. Or using DO .. WHILE loops may be critical, when the condition is changing sometimes.
Look for such things, in worst case try masking out some procedures in your program - it's a kind of try and error
Good luck
Alfred
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
I am using the Codesys RTE for controlling a motion system. In my application I cyclic poll with special FBs the state of the motion system. This works quite well, but some times the PLC runs into an exception.
The log shows the following two exceptions which occur at the same time:
Exception: SOURCEPOSITION App[myApp] area=3, offset=133585
Exception: EXCEPTION [AccessViolation] occured: App[myApp], Task=[MainTask]
The component is both times CmpIecTask.
If I double click the exception the position in the source code is marked. But at this position nothing strange happens, only normal logical operations. Also at this position no pointers, references, strings or arrays are used. I also checked all variables/FB instances in this POU in online mode and the values seem to be correct. Furthermore, the point in the source code is not always the same. It differs always between in a range of about 10 code lines.
My first guess was that this exception is somehow generated by the wrong use of pointers. But could it also be that the exceptions are generated by wrong task scheduling? I have seen that the max execution time of one task is sometimes much higher than its cycle time.
Maybe someone has a hint what I should further try.
Thank you
BR
Martin
Hi Martin!
My guess also would be a sporadic overrun of the task cycle time.
Do you have any time-consuming operations, that are not called cyclical, but triggered by time or when a buffer is full?
E.g. when you have file operations like writing a looger file when a buiffer is full, this may cause trouble because file access needs some time. Or using DO .. WHILE loops may be critical, when the condition is changing sometimes.
Look for such things, in worst case try masking out some procedures in your program - it's a kind of try and error
Good luck
Alfred
Give us the content of the line (and eventually few other) spotted by the exception. Also provide dΓ©clarations.