PDA

View Full Version : PID creation Non-Linear



Naf
January 31st, 2007, 08:12 PM
Ok, i am so lost here...

I have an AEM wideband twin channel, i followed the non-linear instructins, and its still not working right...I had a very accurate equation, but the AFR wouldnt pass 9A/F although i was actually at 15A/F

Here is a copy of my PID CALC

*UNITS

#Code System Abbr Description
#-------- ---------- -------- -------------------------------------------------------------
A/F AEM 1 None AFR "Air Fuel Ratio"
B/F AEM 2 None AFR "Air Fuel Ratio"

# ================================================== ============================
# Add slot definitions here
# --------------------------------
# See sae_generic.txt for more information on "SLOT" formats
#
#Units Low High Fmt Expression
#------------ ------------- ------------- ---- --------------------------------------------------------------
*CLC-00-001
A/F 8.41 19.44 .1 "(0.0129*{EXT.AD1}*{EXT.AD1})-(0.0362*{EXT.AD1})+9.5366"
*CLC-00-002
A/F 8.41 19.44 .1 "(0.0129*{EXT.AD2}*{EXT.AD2})-(0.0362*{EXT.AD2})+9.5366"
# ================================================== ============================
*PRN - Parameter Reference Numbers
# --------------------------------
# See sae_generic.txt for more information on the *PRN section
#
#Code PRN SLOT Units System Description
#------------------------- ---- ------------ ---------------- ---------------- ------------------------------------------
CALC.AEM_AFR1 F002 CLC-00-001 "AFR,V" O2-Wide "AEM Wideband"
CALC.AEM_AFR2 F002 CLC-00-002 "AFR,V" O2-Wide "AEM Wideband 2"

Please help...I need to get the widebands to work so i may finish off my tuning...

Thank you all for you time

Manaf

joecar
January 31st, 2007, 09:58 PM
So your equation is: AFR = 0.0129*V^2 - 0.0362*V + 9.5366

This gives:
V=0 --> AFR=9.5366
V=5 --> AFR=9.6781

Your equation is incorrect... :bawl:

Naf
January 31st, 2007, 10:25 PM
This is the equation that Excel gave me...

i have even a 3 order polynominal and 4 order...

What other means do i have to get the proper equation

joecar
February 1st, 2007, 03:42 AM
Naf,

Welcome to the forum... :cheers:

What are your sample data points...?
What are your 3rd/4th order polynomials...?

Cheers
Joe
:cheers:

Alvin
February 1st, 2007, 05:30 AM
This is the equation that Excel gave me...

i have even a 3 order polynominal and 4 order...

What other means do i have to get the proper equation


You'd probally be better setting it up as a piecewise

redhardsupra
February 1st, 2007, 05:45 AM
yea, just give us the data and we'll give you an equation, i've done this for the zeitronix's wb nonlinear output over 2yrs ago, it's not hard

Naf
February 1st, 2007, 06:43 AM
Thanx so much

The points are as follows

Volts AFR Gas 0-5V
0.000 8.41
0.156 8.52
0.312 8.64
0.468 8.81
0.624 8.98
0.780 9.09
0.936 9.26
1.092 9.44
1.248 9.61
1.404 9.78
1.560 9.95
1.716 10.12
1.872 10.29
2.028 10.47
2.184 10.69
2.340 10.92
2.496 11.15
2.652 11.38
2.808 11.67
2.964 11.95
3.120 12.24
3.276 12.58
3.432 12.92
3.588 13.27
3.744 13.67
3.900 14.13
4.056 14.64
4.212 15.21
4.368 15.84
4.524 16.53
4.680 17.27
4.836 18.19
4.992 19.44

Blacky
February 1st, 2007, 09:02 AM
Or you can set up a lookup function in a calculated PID.

lookup()

Syntax:

lookup(x,a1,a2,b1,b2,…,c1,c2)Arguments:

x: a numeric expression
a1,a2,b1,b2,...,c1,c2 is a list of pairs of values.Return value:

The value of the second value of the pair whose first value is less than or equal to x. The list of value pairs must be sorted on the first value of each pair.So in your case:
Lookup({EXT.AD1},0.000,8.41,0.156,8.520.312,8.64,0 .468,8.81,0.624,8.98,0.780,9.09,0.936,9.26,1.092,9 .44,1.248,9.61,1.404,9.78,1.560,9.95,1.716,10.12,1 .872,10.29,2.028,10.47,2.184,10.69,2.340,10.92,2.4 96,11.15,2.652,11.38,2.808,11.67,2.964,11.95,3.120 ,12.24,3.276,12.58,3.432,12.92,3.588,13.27,3.744,1 3.67,3.900,14.13,4.056,14.64,4.212,15.21,4.368,15. 84,4.524,16.53,4.680,17.27,4.836,18.19,4.992,19.44 )


EFILive will interpolate between data points.

Regards
Paul

redhardsupra
February 1st, 2007, 10:03 AM
y = 0.1153x^3 - 0.4494x^2 + 1.5386x + 8.2255 seems to work with R^2=0.9986 so it's very close for the data given

Naf
February 1st, 2007, 08:01 PM
I got the y= part, but where does the R^2=0.9986 come in?

redhardsupra
February 1st, 2007, 08:04 PM
i think it's called the Pearson Coefficient, basically the closer to 1 the better.

Naf
February 1st, 2007, 08:17 PM
AHA!!!

I will plug it in and give it a try, thanx...

Alvin
February 1st, 2007, 08:58 PM
I got the y= part, but where does the R^2=0.9986 come in?


its a regression fit.. closer to 1 the better the fit.

Naf
February 2nd, 2007, 06:21 PM
if i may ask, how did u come to find this equation?

I found ways to find the table from an equation, but not find the equation from the table?

:Eyecrazy:

redhardsupra
February 2nd, 2007, 06:25 PM
do a x-y scatter plot it in excel
right click on any of the data points
insert trendline
pick polynomial, 3rd degree
then in options you should have 'show equation' and 'show R^2'
v'oile!

Naf
February 2nd, 2007, 06:56 PM
AHHHH

I used the wrong type of graph...i used Line graph....

So i could increase the orders and get a closer to perfect line right? What is the order limit for a PID CALC?

redhardsupra
February 3rd, 2007, 10:59 AM
there's some calculus theorem that says that with high enough order polynomials you can approximate any curve.

there's no order on pid calc, that's just math, you can string as many terms as you want (Blacky, is there a string/parsing limit on calc'ed pids?)

excel will only do 6rd degree poly. but you can put it in any better software like matlab or statistica and you can do whatever you want. however, remember that the calculations involved are gonna get computationally expensive. what you have here, 3rd order with a R^2=0.99... is very good already, just stick to that.
i highly recommend that you change the poly fit order tho, and see how R^2 changes. you will understand how quickly you can converge on a good solution, and how little you'll gain if you try to go higher.

Blacky
February 3rd, 2007, 03:43 PM
tthere's no order on pid calc, that's just math, you can string as many terms as you want (Blacky, is there a string/parsing limit on calc'ed pids?)
Limits of calculated PIDs

Length of expression: 65535 characters.
Number of args per function: 255 (mostly this limit is only relevant for the lookup() function).
Max token length: 64 characters.Everything else is limited only by available memory and CPU speed.

Note: Nested calculated PIDs MUST have a lower PRN than the PID being defined. For performance reasons, calc PIDs are evaluated only ONCE per frame by EFILive, from lowest to highest PRN number. It is essential that you make sure the nested calc PIDs' values are evaluated PRIOR to the PID being defined.

Regards
Paul

joecar
February 3rd, 2007, 04:21 PM
The closer R^2 is to 1 is a measure of how well the polynomial/equation fits the data.

Naf
March 14th, 2007, 09:02 PM
# ================================================== ============================
# File details
# ------------
#
# This section defines various details about the file format.

*FILE

#Parameter Value Description
#---------- ---------------- ---------------------------------------------------
VERSION 7.1.1 File version
DECSEP . Decimal separator used in this file



# ================================================== ============================
# Units
# -------------------
# See sae_generic.txt for more information on the *UNITS section

*UNITS

#Code System Abbr Description
#-------- ---------- -------- -------------------------------------------------------------
A/F AEM 1 None AFR "Air Fuel Ratio"


# ================================================== ============================
# Add slot definitions here
# --------------------------------
# See sae_generic.txt for more information on "SLOT" formats
#
#Units Low High Fmt Expression
#------------ ------------- ------------- ---- --------------------------------------------------------------
*CLC-00-001
AFR 8.41 19.44 .01 "(0.0298*{EXT.AD1}*{EXT.AD1}*{EXT.AD1}*{EXT.AD1})-(0.1826*{EXT.AD1}*{EXT.AD1}*{EXT.AD1})+(0.4971*{EX T.AD1}*{EXT.AD1})+(0.5253*{EXT.AD1})+8.4433"

# ================================================== ============================
*PRN - Parameter Reference Numbers
# --------------------------------
# See sae_generic.txt for more information on the *PRN section
#
#Code PRN SLOT Units System Description
#------------------------- ---- ------------ ---------------- ---------------- ------------------------------------------
CALC.AEM_AFR1 F002 CLC-00-001 "AFR" O2-Wide "AEM Wideband"

joecar
March 15th, 2007, 06:30 AM
"(0.0298*{EXT.AD1}*{EXT.AD1}*{EXT.AD1}*{EXT.AD1})-(0.1826*{EXT.AD1}*{EXT.AD1}*{EXT.AD1})+(0.4971*{EX T.AD1}*{EXT.AD1})+(0.5253*{EXT.AD1})+8.4433"


You can express your polynomial in shorter form like this:

"((((0.0298)*{EXT.AD1}-0.1826)*{EXT.AD1}+0.4971)*{EXT.AD1}+0.5253)*{EXT.A D1}+8.4433"