This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc. 

Try our online PLC Simulator FREE. Click here now to try it. 
November 24th, 2021, 04:49 PM  #1 
Member
Join Date: Nov 2021
Location: Minnesota
Posts: 1

Getting data from a point on a nonliner graph
Hello
I am hoping someone here can maybe at least tell me what I shlould read up on or if this is even possible. Rockwell Studio 5000 is my environment if I have a relationship like is expressed in the attached graph, is there a way I can use a PLC to pick point y and have it compute point x? Has anyone done something like this? I am far from a pro and struggling to get a start. 
November 24th, 2021, 04:56 PM  #2 
Lifetime Supporting Member

Based on the equation shown at the bottom of your graph. For any value of X, you can compute Y. I've done this type of thing many times for nonlinear processes, such as defoamer additions, or converting density to percent solids.
A process engineer or similar, collects empirical data, plugs it into excel and excel produces an equation to fit the numbers given.
__________________
Certified Siemens Functional Safety Professional, ID: SFSP17010238 NRA Benefactor 
November 24th, 2021, 05:01 PM  #3 
Lifetime Supporting Member

As noted by @Ken Moore, you can start with an X value and calculate a Y value directly.
Going the other way, from a Y value (position on vertical axis on plot) that you choose, to the corresponding X value (position on horizontal axis on plot), as requested in the original post, however has a problem: for many of the plotted Y values, there are multiple possible X values (roots).
__________________
i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. Last edited by drbitboy; November 24th, 2021 at 05:17 PM. 
November 24th, 2021, 05:09 PM  #4 
Member

I am assuming the dotted line is supposed to approximate the blue line. The dotted line generated by the polynomial does not match the blue line very well, duh.
If you have the data points that were used to generate the blue line then the simple thing to do is to do a linear interpolation between the points that made up the blue line. The blue line does look like it is made of segments. The problem with this is finding the which two point to interpolate between. What is MUCH easier and I would do is enter the points that made up the blue line into a cam table, Rockwell's name for a cubic spline. This would provide a 3rd order interpolation which is much better than a first order interpolation. The nice thing about this is that Rockwell should provide a function that will then generate a y value given a x value using 3rd order interpolation. This eliminates the need to search through the table to find which two points to interpolated between. I don't have RS5000 anymore. If would be best if you provided the x and y coordinates that were used to make the blue line. Some kind soul might enter these points in a cam table to show you. I can show how this is done on other software.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon 
November 24th, 2021, 05:24 PM  #5  
Lifetime Supporting Member

Quote:
Anyway, welcome to the forum!
__________________
i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. 

November 24th, 2021, 05:25 PM  #6 
Member

@andy:
Have you tried FGEN ? The FGEN instruction converts an input based on a piecewise linear function.
__________________
My two cents. 
November 24th, 2021, 05:48 PM  #7 
Lifetime Supporting Member

[oh dear, now I'm hooked]
Hey @Peter, If the dotted line is
I ask because my calibrated eyeball tells me that dotted line has a zero slope with a positive second derivative (concave upward) at an X value near where the cubic term of the annotation is. But when I solve for the quadratic roots I get this: >>> import mathHuh? That error could only be a negative discriminant, right? >>> print(0.0126**2  4*9e5*.4796)Really? >>> .0126**2What am I doing wrong? I know I make a lot of mistakes, but now with the quadratic formula too?
__________________
i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. 
November 24th, 2021, 06:01 PM  #8 
Lifetime Supporting Member

Never mind, it's eXcel being useless eXcel as usual: the cubic term needs more digits, it's probably around 2.75e5 or less; my calibrated eyeball tells me those local extrema near the inflection point are not too severe.
__________________
i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. 
November 24th, 2021, 06:08 PM  #9 
Lifetime Supporting Member
Join Date: May 2014
Location: Dallas, Texas
Posts: 648

Curiously, the OP asked for how to implement the inverse of this function on Reddit:
https://www.reddit.com/r/PLC/comment...tm_name=iossmf Which problem are we solving? If your input is ‘x’ and output is ‘y’ then what I said there applies: Lookup tables are costly with the precious few bytes of memory Rockwell provides. The function is small, fixed, and easily implemented as others have said with a CPT expression closely resembling the mathematical notation. The other way around? Piecewise linear regression across the known range. 
November 24th, 2021, 06:12 PM  #10 
Lifetime Supporting Member

Anyway, if OP is going from X to Y and has the raw data, then @widelto's suggestion of FGEN is probably the quickest route to a solution; see this link.
If OP is going from Y to X, then there is no unique solution for the data presented.
__________________
i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. 
November 25th, 2021, 11:58 AM  #11 
Member

@drbitboy, in #7 your derivative is correct but I can't tell what you are trying to achieve after that.
I didn't know about FGEN but if is is only piecewise linear then cam tables would be better of accuracy is required. @drbitboy, do you know that Code:
y=a*x^3+b*x^2+c*x+d Code:
y = ((a*x+b)*x+c)*x+d @JeremyM, I thought the PLCs have lots of memory now. I stated above that it is best if the programmer doesn't need to determine which two points he is interpolating between. Use cam tables/splines if accuracy is required Use FGEN if piecewise linear interpolation is good enough. Both methods will avoid the messy searching through a table to see which two points one is interpolating between. We have not got a list of Xs and Ys.
__________________
"Living is easy with eyes closed, misunderstanding all you see...." Strawberry Fields Forever, John Lennon 
November 25th, 2021, 12:28 PM  #12  
Lifetime Supporting Member

Quote:
The eventual goal was, once I know how to extract the XY data, to see if a higherorder polynomial could do a better job of modeling the data. Anyway, I figured out the problem: it was the resolution of the posted model's coefficients. Exactly, which is why I was fiddling around wasting time with the process above. Quote:
Umm, yes. This ain't exactly my first rodeo. Quote:
__________________
i) Take care of the bits, and the bytes will take care of themselves. ii) There is no software problem that cannot be solved with another layer of indirection. 

November 26th, 2021, 11:04 AM  #13 
Lifetime Supporting Member

1) The equation for the trend line shown is only third order. Excel lets you go to sixth. Keep increasing the order until RČ stops increasing.
2) As Dr. Bitboy says, you generally need to use scientific notation with at least five decimal places in the coefficients to get reasonable results. 3) This is an irregular function, and you don't identify the physical parameters on x and y. You also don't give magnitudes of the x and y grid. Your plot could be right, or it could represent ± experimental errors around what should be a straight line or a sinusoidal curve. Consider the theoretical expectation of what the plot should be and adjust the equation accordingly. 4) To get the inverse function simply use another graph swapping x and y values and create a new trend line. 
Bookmarks 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)  
Thread Tools  
Display Modes  


Similar Topics  
Thread  Thread Starter  Forum  Replies  Last Post 
Scaling temp. data in CMore Line Trend Graph  Dan_S  LIVE PLC Questions And Answers  13  March 9th, 2021 12:59 PM 
Fatek Plc Floating Point Data Move  ishak1057  LIVE PLC Questions And Answers  0  December 26th, 2020 05:34 AM 
rs 500 long word data type use  Controls Tech  LIVE PLC Questions And Answers  3  December 12th, 2018 02:18 PM 
Point IO IA4 module  where to find channel data?  selectionplc  LIVE PLC Questions And Answers  6  May 23rd, 2017 12:18 PM 
Omron Cj1m  glenncovington  LIVE PLC Questions And Answers  10  March 7th, 2012 07:01 PM 