Studio 5000 Creating a Lookup Table

I am receiving an integer via modbus from a motor protection relay that can be one of ~250 values telling me why the motor shutdown. I need to write to a string based on the value of the integer. For instance, a 0 input would mean no shutdowns active, a 1 would mean Forced Setpoints dump, a 2 would mean Speed Switch Trip etc. I could write logic (see link) to Copy the value from an array of strings into a tag, but that would mean 250 rungs of code, and I need to do this for five motors, so that would be a lot of time. Is there a better way to do this?

Edit: I used one bpeck451's solution and it worked great. I updated the Imgur pics to show the ladder logic in case anyone is interested. Thank you to everyone who responded. Please note: I did have to do a MOV block from my modbus register to a controller tag that didn't have brackets in order for it to work correctly.

https://imgur.com/a/3EFXI6O

Posted Feb 3, 2020, 1:43 PM UTC · edited

215
bpeck451•

Make an array of strings with all those strings in it and just reference the individual elements. Use the Modbus value you use for the array element. As long as the states all map the same it should make your rung count really low.

AB does the this for description and error lists with PlantPAX.

3
con247•

Depending on the platform, you may want to apply a bounds check before indexing the array.

4
SmallGovmentBetterOP•

I am confused on how to dynamically reference an individual element based on an integer. If my integer is 100 I would have to 100 to the name of my array to get it to look at COLT_Array[100]

1
bpeck451•

If you take that modbus value you were talking about and put it in a variable you should be able to use COLT_Array[Modbus_Val]. As long as Modbus_Val is of the right data type it will work.

Like the u/con247 said do some bounds checking. You WILL crash a compactlogix if you mess that up. I'm not sure about a controllogix since I haven't actually crashed one of those for this reason. But it's a better safe than sorry kind of thing.

3
ut17•

Yeah, it will also cause a major controller fault on a ControlLogix. Definitely add in bounds (starting with a SIZE is usually helpful!)

3
SmallGovmentBetterOP•

I did this and it worked great. I updated the Imgur pics to show the ladder logic in case anyone is interested. Thank you to everyone who responded.

2
SmallGovmentBetterOP•

Sounds good, I will give that a try. Thanks!

1
BCI_JeffBit Plumber•

Move/Copy COLT_Array[NameOfTag] into AlarmStringDescription

There should be instructions in the help of how to do indirect addressing. There may not be this exact example, but enough to understand how it works.

1
BCI_JeffBit Plumber•

Index the array with the value, but make sure the value is acceptable first. You don't want to index out of bounds. Should be a clean operation.

1
SmallGovmentBetterOP•

Okay, I saw one program where there was a LIM function used for that. Makes sense. Thanks!

2
brybrythekickassguyElectron Warlock•

Is there just a single active alarm or multiple for each motor?

1
SmallGovmentBetterOP•

There will only be one at a time. I assume it’s like a first out shutdown

1
brybrythekickassguyElectron Warlock•

So you need to create an array of “active alarms” for each motor. Either keep these as a FIFO, or just stuff the active alarm for each motor into the raw array index IE ActiveAlarm[1] is the active alarm integer for motor 1.

So, then you need to display this stuff right? Well, do you just want to show to alarm, if it exists, for a second with no user interaction? Then you’d set up a timer to iterate a counter every 25ms, set the counter accumulator to be the index value of the alarm array. Count from 1-5, if the array index is true, quit counting and display that message via another timer for a second or so. If there’s only that one message, it will continue to show that message. You’ll have to come up with a default message to display for when they’re all

1
5hall0pexRockwell•

If the value is 0-250 then use it as a pointer for a lookup table. If the value is not then also add a column of the error codes. Use a FSC to find the value and the position returned in the FSC is the pointer to your text. Be sure to put in an unknown error in case something goes wonky. I'd written a LUT that worked fine for years until the drive firmware was updated. Then proceeded to fault the processor when it couldn't find the new error codes.

1
SmallGovmentBetterOP•

I used another person's solution and it worked. I might try this as well to see which one is easier. Thank you for your response.

1