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?
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?