Sign in to follow this  
Followers 0
Saxony Thermal

Subroutine bug across POUs

3 posts in this topic

Hello, I have a subroutine error that I cannot figure out.
I had about a 45k step ladder project with about 50 subroutines running great. I decided to add another subroutine and I get this error (attached.)

  • Error H33E7 which means there is some structural ordering issue. I have had this before and it was always that I forgot my RET or I deleted a RET on accident after a subroutine definition. No prob, easy fix.
  • However, that is not the case with this issue I am having. After cutting code out of my project until the error went away, it came down to specifically this: (see simple code attached)


This is a test project separate from my main project to replicate the issue. Notice in the Navigation panel that I have two POU's under main program. POU2 shown in the picture is M0 controlling a call for P1. FEND, then P1 is defined as a simple INC Z0 and then RET. This is the exact 'structure' in my working subroutine ladders but with much more complex operations; where, I define 50 or so subs P1-100 thereabouts, and call them throughout my other POU's, and each sub is 25-100 rungs.

This code you see does not error until I added POU1. Meaning, building and simulating POU2 by itself will work. Adding POU1 is a simple SM401 (always off) controlling INC Z1. Its just a dead line to make POU1 a thing when compiled. Then I get the error. No matter what is in POU1, the error will exist. This basically means I cant have any other POU's without a structural error when using subroutines.

In diagnostics while simulating (and on the FX5UC PLC unit I have, I tested if it wasnt just simulation), I can jump to the error line. It will always point to the first line of POU1. This is important to note: in my full program with the 50 subs, when the error occurs, it will pick one of my 7 POUs and say error at the first line of it. If I unregistered that POU that is marked, the error will simply jump to another POU, and so on until it was reduced to basically the sample code I showed in the attached. The error went away when it was 1 POU.

 

But in my working project (before implementing this sub that caused all this issue) all these subs work and there are several POUs.

I spent a 2days on this so I am just g oing to copy paste this code I intended to sub many times just to move forward, but I want o understand what is the hangup. The test project was me just trying to write a sub again and apparently I cannot anymore.

Thoughts? I appreciate it, thanks.

 

 


 

 

error.png

simple code.png

Share this post


Link to post
Share on other sites

Did you check what the on which pointer nr the global pointer is set ?

By Default on an iQ-R it's, the FX5 2048

Share this post


Link to post
Share on other sites

I think I found what you are referring to (attached). I am in IQ-F which also is 2048 points as you said. But what do I do with that? Would my 50 subs consume all those points? I cant imagine more than a point per sub, right?

 

So that I can finish my project, I found a work around where I didn't do the additional sub routine and instead copied the routine code the several times it needed to be ran.

Or I had to merge 3 POU's into one. So I had 7 Pous, and 3, 4, and 5 had to merge to make the sub work which was not something I wanted to do for organization purposes.

I don't know what merging POU's solving the issue mean. The order of the ladder did not change. I simply copied the code all into one POU (because I was trying to see what the problem was) and the error went away. My code is running on a PLC fine now, no functional issues and passed bench tests.

 

I still want to understand this issue because its preventing me from doing more subs (big issue) or ruining my organizational structure (also an issue). Maybe its not just a pointer issue but a large abstract structural problem, and the subroutine pointer just brought it to light?

 

pointer.png

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0