Sign in to follow this  
Followers 0
Conor

Changing an SP based on a value

22 posts in this topic

Hi guys, I have a set point that I need to change based on a percentage value entered by an operator So its like; 100% 3.00 95% 3.23 85% 3.46 And so on to 40%. I was going to do something like below (tagnames not inserted) [EQU(?,?)ONS(?),EQU(?,?)ONS(?)]MOV(?,?); Maybe this is the way that you guys might do this, but I was wondering if there is a better way, or another way of doing this. Thanks, Conor

Share this post


Link to post
Share on other sites
I would scale it in the HMI if it's linear, which it appears to be Edited by Michael Lloyd

Share this post


Link to post
Share on other sites
Or do the scaling in the PLC. Since RS5k doesn't have the SCP instruction (why, AB, why?), you can use a CPT: CPT setpoint maxValue-userInput*span where: setpoint is the output value userInput is the number entered at the HMI (between 0.0 and 1.0) maxValue is the highest value your output can reach (it looks like 7.6 in your example) span is the "size" of the range of values your output can reach (maxValue - minValue, looks like 4.6 in your example) You will DEFINITELY want to do some limit checking to make sure the number from the HMI is between 0.0 and 1.0 (inclusive).

Share this post


Link to post
Share on other sites
Actually... if you have FB or Structured Text CLX has the SCL function. Even better... if you are trying to use a curve, it has the FGEN function. The function generator is extremely handy for fitting a curve to linear data (things like air/fuel ratio controllers, etc are easy to build with the FGEN routine). Y=mX+b or it's derivation is a pretty handy equation. I just realized that The OP's input range is 40-100% but as input increases his calculated value decreases. Something is wrong with the stated ranges of: 85% = 3.46 95% = 3.23 100% = 3.00 85 to 95% is a 10% change and 95-100% is a 5% change yet the incremental change to the output from 85 to 95 is .23... which is the same as the 95-100% setpoint change. It's going to be hard to make an equation fit that... Sounds like a homework project to me...

Share this post


Link to post
Share on other sites
Yeah, at my first glance, it looked like a change of 0.23 for a change of 5%. Upon further looking, that's not the case. This is a bit more challenging since it's not linear. If the user will be limited to step changes in 5% increments, a lookup table type thing may be the simplest (though not necessarily the most elegant) solution.

Share this post


Link to post
Share on other sites
I'm betting that it's a typo. The good news is that the function generator could handle the last little kink if it's not. If he made a typo then the absolute brute force equation for his situation would be Where Y = output and X = Input Y = (X * -0.046) + 7.6 Cut and paste from the spreadsheet that I used to validate the equation: b M X Y 7.6 -0.046 0 7.60 7.60 5 7.37 7.37 10 7.14 7.14 15 6.91 6.91 20 6.68 6.68 25 6.45 6.45 30 6.22 6.22 35 5.99 5.99 40 5.76 5.76 45 5.53 5.53 50 5.30 5.30 55 5.07 5.07 60 4.84 4.84 65 4.61 4.61 70 4.38 4.38 75 4.15 4.15 80 3.92 3.92 85 3.69 3.69 90 3.46 3.46 95 3.23 3.23 100 3.00 3.00 The column on the far right is the brute force increment of .23. The middle column uses the M and b values. First I derived b by setting X to zero (doesn't matter what M is if X is zero) then I solved for M using M = (Y-b)/X Edited by Michael Lloyd

Share this post


Link to post
Share on other sites
Joe: There is an Add-On instruction for RSLogix 500 for the SCP. Why RA chose not to make it part of the instruction set, I don't know, but this gives you the functionality.

Share this post


Link to post
Share on other sites
Hi guys, It was a typo, sorry. I was trying to get the post in before I left here yesterday evening. Here are the values % SP 100 3.00 95 3.23 90 3.46 85 3.69 80 3.92 75 4.15 70 4.38 65 4.61 60 4.84 55 5.07 50 5.30 45 5.53 40 5.76 (just edited this to the right figure) I do have the FB add-on. Thanks for all of your inputs. I will read through them fully now to see which way I am going to proceed with this. Thanks again Edited by Conor

Share this post


Link to post
Share on other sites
Try the FGEN block out. Create two tags with 13 values per tag (either an array or two separate tags. I like arrays myself). Ix and Oy for instance.. Place the values for X (% input) in Ix and the values for Y (Desired result) in (Oy). Reference the two tags in the appropriate location in the FGEN block. The help file for the FGEN block makes it pretty easy to use I'm running late or I would take the time to see if the SP column is linear or not. If it's not FGEN is your answer. If it is then Y=mX+b will do the trick

Share this post


Link to post
Share on other sites
Thanks Micheal, The output is linear, but this maybe subject to change as these figures are just starting values from the process engineer. I take it that if I use the FGEN then this may be the better instruction to use as the values may change in the future

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites
Hi guys, I tried but failed to get this working. I have attached a doc with screen dumps. Below is the configuration of the tags Blend_SP_IP is a REAL Poly_Sol_OP is a REAL Blend_Percent_Values is an array of 13 REAL's Poly_Sol_Values is an array of 13 REAL's I have played with the setting XY1Size, but this doesn't work, as you can see in the attachment. When XY1Size is set to 1 the fault clears but the output is wrong. I have added the values to the array as per the ealier values that I had posted Any help would be great Thanks, Conor fgen_problem.doc

Share this post


Link to post
Share on other sites
Array size is the number of elements in each array. I'm looking at this on my phone but if I read it right the value should be set to 13

Share this post


Link to post
Share on other sites
I have another tip- When you build your X/Y tag you can do it one of two ways: (1) Build two tags like you did. I personally don't like doing it this way but I like UDT's so I have a bias (2) Create a User Defined Data Type callled XY. Make it look like this: then create a tag of the type XY like so The FB addressing would look like this: The primary reason for NOT doing it like this lies in the UDT. You have to plan your UDT. Some would say that this is a frivolous use of a UDT. I would argue that it's one of the intended uses of UDT's since it's reusable. So... what's bad about this method? If you change the number of elements then you have to go edit the REAL[13] portion of the UDT offline and then download. Most people, myself included, do not like stopping the processor of a PLC. I have occasions where I can with no impact to the system but they are rare. The workaround would be to create it with REAL[20] and then use 13 in XY1Size so that it only uses 13 of the 20 data points available FWIW- I'm a big fan of structured text for some things. I have a standard Structured Text routine called IOM (IO Map) Everything that gets mapped gets put in IOM (and IOM has a password on it). If I were doing your little project it would look like this in my IOM file (SP is a tag of the type REAL): I hope that you got it to work. It's as pretty simple Function Block to use and very powerful

Share this post


Link to post
Share on other sites
Hi Michael, When you said that I needed to change the array size, can you explain. I can't seem to get the original FGEN working. So, I said I would try your way. I created a new UDT called XY, and made each a REAL array of 20, as per your suggestion. One thing on this, in your screen dump I see External Access as one of the tabs. I don't seem to have this on mine. Is this because my PLC is running V15.3? So I have this set up, I can't fine the tag, as per your second screen dump Thanks again, Conor

Share this post


Link to post
Share on other sites
You need to set XY1Size to the number of data points. Your version should work when you do that. My last post was to show you how setting it up can be streamlined. I'm using Rev 19 in the example but everything that I showed you will work in 15. I just built the UDT and Function block in a Rev 15 program and it's fine. External access is one of those "features" that AB added to the newer version. I don't use it so I can't help you with what it's for. I just noticed that the Enable Out value in the screen shot is not set to 1. In and out both need to be set to 1 Edited by Michael Lloyd

Share this post


Link to post
Share on other sites
Make sure In and Out have a value of 1 in them (in the FB setup dialog) I built my tags in Controller Tags not Program Tags. Maybe that's why you can't find yours?

Share this post


Link to post
Share on other sites
It must have been too early for me to be thinking... External access (I do use it but not much) allows you to set the tag as read only, write, or read/write. When I create Add-Ins I use the various selections. I don't know when they added this feature. For instance, I'll set something as Read Only if I want to prevent someone from accidentally changing the value at the tag level

Share this post


Link to post
Share on other sites
Hi, I finally got it working, my original FGEN that is. I kept getting XisOutOfOrder errors. So I reversed my values. X.0 was 100 now 40 Y.0 was 3 now 5.76 Values as per the table of values earlier in this topic Any idea's why this would have happened? Conor

Share this post


Link to post
Share on other sites
I'm pretty sure that input data has to be in the order of smallest to largest.

Share this post


Link to post
Share on other sites
Hi Michael, It does seem that. Anyway at least I got it going. I will try on Monday or Tuesday to get your UDT method working. I was talking to my process engineer today and was telling him that I had got it going. I was telling him that the line doesn't have to be linear, and he was very impressed as he thinks that a non linear line (values) will work better for our application. Thanks again for all your help, I am really very grateful Conor

Share this post


Link to post
Share on other sites
No problem. I enjoy sharing the little bit that I know about CLX. I'm glad that you got it working

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