## 4 posts in this topic

Is there a simple instruction where I can fill in a table and do a look-up based on a value.  I have a airflow meter that Pressure correlates to Airflow but it is non linear.  I have 11 pressures that equal 11 flows.

Using RSLogix 5000 V20.04 Ladder logic only, no language pack.

Thanks

##### Share on other sites

Yes there is. Well... kind of, you have to have Function Block licensing. There's a function block called FGEN (Function Generator) that is wonderful for doing what you want to do. I've used it for Air/Fuel Ratio control, valve characterization, etc. If I remember correctly (been over a year since I've used it), when you make the tag for X and Y you need to make it for number of characters +1 or it will fault.

Or you can roll your own un Structured Text. Y = mX+b... slope of a line for each segment of the non-linear curve. I'd use FGEN :)

1 person likes this

##### Share on other sites

There isn't anything in LAD that will just drop-in and do what you want but it shouldn't be too hard to roll your own with an array and some LIM instructions. If they hadn't eliminated the SCP instruction in the 5000 world, it would be even easier...

Ok, so I couldn't resist trying this. Here's my made-up table of pressures and flows:

The first column is 11 pressure data points. Second column is the span between the points. Third and fourth columns are the same for flow. Here are the PLC tags:

The pressure and flow data points are variables so you can adjust your table as desired. Next, calculate the span tags:

The spans for the flow are calculated the same way. I built 2 branches of the scaling calculation here:

This is just a simple linear interpolation calculation. Ironically, it would be far easier in the Logix 5 and Logix 500 worlds by using the SCP instruction. With that, we could eliminate the range calculations altogether and just have a "LIM SCP" branch for each step. But Rockwell decided we don't need SCP any more.... They do have the SCL instruction in structured text and FBD but that doesn't help us much in the LAD world. I've tinkered with making my own SCP instruction as an AOI but haven't had a lot of time to work on it.

I tested this with a variety of pressures from 0 up to 20 including the actual pressure points (10 and 20) and it returned the right answer (it agreed with Excel, anyway).

##### Share on other sites

Thanks  I ended up doing a similar network in Ladder to get what I needed.  I agree that they should have kept the SCP in ladder.