Forum

1769-L33ER faults t...
 
Notifications
Clear all

[Solved] 1769-L33ER faults type 4 code 20 when the recipe number from the HMI reaches 20

8 Posts
3 Users
0 Reactions
116 Views
(@petra66)
New Member
Joined: 1 year ago
Posts: 0
Topic starter   [#142]

Granulator line, CompactLogix 1769 L33ER, Studio 5000 V32. I'm normally on the sensor and loop side here, this routine came to me with the machine. Recipe select is a number from the PanelView, 1 to 20, written into RecipeNo, and a Structured Text routine copies Recipes[RecipeNo] into the working setpoints.

Twice this month the controller's faulted with type 04 code 20, array subscript too large, and both times the operator had picked the last recipe. The array is Recipes[20].

I tried making the array Recipes[25] to give it room, and it faulted again a week later, that time because the operator typed 25 to see what would happen.

I don't see why the last recipe is any different from the others. Is there a proper way to do this? Do I clamp RecipeNo before the copy, or is that maybe just papering over an operator typing 25?


Advertisement

   
Quote
 kaim
(@kaim)
Active Member
Joined: 2 years ago
Posts: 17
 

Recipes[20] has elements 0 to 19. Recipe 20 is one past the end, on every runtime I know. Where does the HMI number get checked before it becomes an index? And what did picking 25 do on the 25 element array, a fault or nothing?


Advertisement

   
ReplyQuote
(@petra66)
New Member
Joined: 1 year ago
Posts: 0
Topic starter  

Nowhere, it goes straight in. And 25 on the 25 array faulted, so that's the same thing as 20 on the 20 array. Zero based, I'd read that somewhere and never connected it to this. Pretty sure that's it. So the way I understand it the array counts from 0, the operator counts from 1, and nobody in between translates.



   
ReplyQuote
(@rsdave)
Trusted Member
Joined: 2 years ago
Posts: 65
 

That's it exactly. Is RecipeNo a DINT or an INT coming from the panel, and has the numeric entry on the panel got min and max set?



   
ReplyQuote
(@petra66)
New Member
Joined: 1 year ago
Posts: 0
Topic starter  

DINT. The panel field is a numeric entry, no limits set.



   
ReplyQuote
(@rsdave)
Trusted Member
Joined: 2 years ago
Posts: 65
 

Then guard it before it's used, every time, and never let an operator number be an index directly:

```
IF (RecipeNo >= 1) AND (RecipeNo <= 20) THEN
idx := RecipeNo - 1;
Working := Recipes[idx];
RecipeFault := 0;
ELSE
RecipeFault := 1;
END_IF;
```

The -1 maps 1 to 20 onto 0 to 19. On V32 the numeric entry has Min and Max fields right there, set them to 1 and 20 as well, belt and braces, but the PLC check is the one that matters because the next HMI won't have it. A fault routine can catch a type 4 and clear it, and then you've got a machine running a recipe it never loaded. There's a writeup on the languages that touches on this: https://plctr.com/introduction-to-plc-programming-languages/



   
ReplyQuote
(@petra66)
New Member
Joined: 1 year ago
Posts: 0
Topic starter  

Range check in with the -1, and limits on the panel field. Recipe 20 loads now and 25 gives the RecipeFault bit and a message instead of faulting the L33.

The index was reaching the array length, no more than that. The array counts from zero, the operator counts from one, and the number went from the panel straight into the brackets with nobody in between. The IF around it and the offset are what was missing.

One thing I'm not sure about, the controller's fault log still shows the two old faults and I don't know whether they clear themselves or whether someone has to. Thanks rsdave and kaim.



   
ReplyQuote
 kaim
(@kaim)
Active Member
Joined: 2 years ago
Posts: 17
 

The log keeps them until you clear it, it doesn't clear itself. Nice that 25 is boring now.



   
ReplyQuote
Share: