[phoenix-project] Re: Expeyes-Junior diode fit fails for LED

  • From: ab <abals@xxxxxxxxxxxxx>
  • To: Georges Khaznadar <georges.khaznadar@xxxxxxx>, phoenix-project@xxxxxxxxxxxxx
  • Date: Fri, 13 Jan 2017 20:40:32 +0100

Dear Georges

Thanks for answer!

I think I found the problem:
It is the fitting algorithm "leastsq" which is a "Levenberg-Marquardt" fit, ie least square fit.
It does not take advantage of the knowledge that the funktion is exponential.
Instead it sees huge values for large x and tiny values for small x. In the end the algorithm has no idea how to vary the parameters in order to find their best values.

The best approach would be a linear fit of log(y) values.

It should be easy to modify "diode_iv.py" (-- for those who took the efforts to write all the libraries). Are there any updates planned?

Best regards
Andreas


On 11.01.2017 17:06, Georges Khaznadar wrote:

Dear Andreas,

ab a écrit :

Unfortunately I don't have a deep knowledge about the program structure of
Expeyes libraries.

Question:
Do you know who is familiar with Expeyes diode fit program? Is it possible
to extend the fit program in order to fit not only Si-diodes but LED as
well?

Andreas

The source of the program is available at
https://github.com/expeyes/expeyes-programs/blob/master/eyes-junior/diode_iv.py
and the piece of software to change slightly might be the function
fit_curve, whose source is there :
-------------------8<---------------------------------------
def fit_curve():
        global data, running
        if running == True or len(data[0])==0:
                return
        f = eyemath.fit_exp(data[0], data[1])
        if f != None:
                g.line(data[0], f[0], 1)
                k = 1.38e-23    # Boltzmann const
                q = 1.6e-19     # unit charge
                Io = f[1][0]
                a1 = f[1][1]
                T = 300.0               # Room temp in Kelvin
                n = q/(a1*k*T)
                s = _('Fitted with Diode Equation : Io = %5.2e mA , Ideality 
factor = %5.2f')%(Io,n)
                msg.config(text = s)
-------------------8<---------------------------------------

This fuction makes a call at eyemath.fit_exp, whose complete source
file is at
https://github.com/expeyes/expeyes-programs/blob/master/expeyes/eyemath.py
the relevant lines of the file are:
-------------------8<---------------------------------------
def fit_exp(xlist, ylist):
    size = len(xlist)
    xa = array(xlist, dtype=float)
    ya = array(ylist, dtype=float)
    maxy = max(ya)
    halfmaxy = maxy / 2.0
    halftime = 1.0
    for k in range(size):
        if abs(ya[k] - halfmaxy) < halfmaxy/100:
            halftime = xa[k]
            break
    par = [maxy, -halftime,0]                     # Amp, decay, offset
    plsq = leastsq(exp_erf, par,args=(ya,xa))
    if plsq[1] > 4:
        return None
    yfit = exp_eval(xa, plsq[0])
    return yfit,plsq[0]
-------------------8<---------------------------------------

Maybe you can find the precise point where you can add a modification?

Best regards,                   Georges.

To unsubscribe from this list goto http://iuac.res.in/~elab/phoenix , enter your email ID, choose Unsubscribe and submit.

Other related posts: