The Designer's Guide Community Forum
https://designers-guide.org/forum/YaBB.pl
Design Languages >> Verilog-AMS >> battery model
https://designers-guide.org/forum/YaBB.pl?num=1189110802

Message started by grosser on Sep 6th, 2007, 1:33pm

Title: battery model
Post by grosser on Sep 6th, 2007, 1:33pm

hello

i am working on the veriloga battery model proposed by prof. Mora in the article

http://www.rincon-mora.com/publicat/journals/tec05_batt_modl.pdf

I am beginer and have some problems in implementing that in veriloga.

In the attached schematics there is battery model with nodes.

I did it as follows

module battery(minus, plus, vref);
inout minus, plus, vref;
electrical minus,plus,vref;

electrical vsoc,v1,v2,v3;

parameter real Rdis=10M;
parameter cap=0.015;
real C,capS,capL,vtemp;


analog begin

    @(initial_step) begin
    vtemp =1;
    end
   
    V(vsoc,vref) <+ vtemp;
   
    C=3600*cap;
    capS=-752.9*limexp(-13.51*V(vsoc,vref))+703.6;
    capL=-6056*limexp(-27.12*V(vsoc,vref))+4475;

    I(vsoc,vref) <+ V(vsoc,vref)/Rdis;
    I(vsoc,vref) <+ ddt(C*V(vsoc,vref));
    I(vsoc,vref) <+ I(minus,v1);
   
    V(v1,minus) <+ -1.031*limexp(-35*V(vsoc,vref))+3.685+0.2156*V(vsoc,vref)-0.1178*pow(V(vsoc,vref),2)+0.3201*pow(V(vsoc,vref),3);
    I(v1,v2) <+ V(v1,v2)/(0.1562*limexp(-24.37*V(vsoc,vref))+0.07446);
   
    I(v2,v3) <+ V(v2,v3)/(0.3208*limexp(-29.14*V(vsoc,vref)));
    I(v2,v3) <+ ddt(capS);
   
    I(v3,plus) <+ V(v3,plus)/(6.603*limexp(-155.2*V(vsoc,vref))+0.04984);
    I(v3,plus) <+ ddt(capL);
   
end


there is one problem, the model is not working :)

can you advice anything?

regards

Title: Re: battery model
Post by Geoffrey_Coram on Sep 7th, 2007, 6:05am


grosser wrote on Sep 6th, 2007, 1:33pm:
    @(initial_step) begin
    vtemp =1;
    end
   
    V(vsoc,vref) <+ vtemp;


This code has no effect; you contribute to the voltage but later contribute to the current I(vsoc,vref).  You can't set both I and V, and Verilog-A's rules say that the last contribution type wins (see "value retention" in the LRM).

You probably need to use a nodeset to set the initial capacitor voltage.

Title: Re: battery model
Post by grosser on Sep 7th, 2007, 6:14am

let's forget about initial block for a while

it also doesn't work without it. the problem is i'm doing it quite intuitially. the ground at the schematic on the left is vref in the code.

i don't see the problem which happens here

Title: Re: battery model
Post by Geoffrey_Coram on Sep 10th, 2007, 7:58am

What simulation are you trying to run?  From your initial_step code, it looked like maybe you were trying to simulate an initially charged battery.  I didn't read the paper: is it supposed to be able to model the battery being charged?  

If the battery is initially discharged -- which is one time=0 solution to the equations you've written -- then you won't get a very interesting simulation.

Title: Re: battery model
Post by Geoffrey_Coram on Sep 10th, 2007, 8:03am

Also, the limexp functions are quite complicated, I can't get any intuition about what's really supposed to happen.  You should probably try simplifying the model -- eg, do you understand the model well enough to turn it into a simple battery with internal series resistance?  Then add the other features, like the increase in resistance as the charge decreases, and make sure each works like you expect before adding the next.

Title: Re: battery model
Post by grosser on Sep 10th, 2007, 1:03pm


Geoffrey_Coram wrote on Sep 10th, 2007, 7:58am:
What simulation are you trying to run?  From your initial_step code, it looked like maybe you were trying to simulate an initially charged battery.  I didn't read the paper: is it supposed to be able to model the battery being charged?  


i am doing a transient one. yes, firstly the battery is fully charged (Vsoc should be 1 initially)

Title: Re: battery model
Post by grosser on Sep 10th, 2007, 1:05pm


Geoffrey_Coram wrote on Sep 10th, 2007, 8:03am:
Also, the limexp functions are quite complicated, I can't get any intuition about what's really supposed to happen.  You should probably try simplifying the model -- eg, do you understand the model well enough to turn it into a simple battery with internal series resistance?  Then add the other features, like the increase in resistance as the charge decreases, and make sure each works like you expect before adding the next.


these functions describe transient response of the specific measured battery. it was extracted from measurment results so it looks like it looks.

thanks

Title: Re: battery model
Post by Geoffrey_Coram on Sep 11th, 2007, 6:07am


grosser wrote on Sep 10th, 2007, 1:05pm:
these functions describe transient response of the specific measured battery. it was extracted from measurment results so it looks like it looks.


OK, you've completely missed my point.  You've got a very complicated model that you say "doesn't work."  I'm suggesting that you remove some of the complications to see if you can get something that shows *qualitatively* the right behavior -- even if it doesn't exactly match your measurement -- so you can see where the problem lies.  This is a fundamental idea for debugging models.

Title: Re: battery model
Post by Geoffrey_Coram on Sep 11th, 2007, 6:13am


grosser wrote on Sep 10th, 2007, 1:03pm:

Geoffrey_Coram wrote on Sep 10th, 2007, 7:58am:
What simulation are you trying to run?  From your initial_step code, it looked like maybe you were trying to simulate an initially charged battery.  I didn't read the paper: is it supposed to be able to model the battery being charged?  


i am doing a transient one. yes, firstly the battery is fully charged (Vsoc should be 1 initially)


Your model is incapable of simulating this situation, in which the battery starts out charged.

Your initial_step code doesn't work because of value retention (did you look that up in the LRM like I suggested?).  If you just take it out ("let's forget about initial block for a while") then the simulation will start with a discharged battery, and presumably it just stays discharged during your simulation.

You need to find a way to start the battery charged; you might be able to use
 if (analysis("ic"))
or you might need to use a nodeset/initial condition specific to your simulator.

The Designer's Guide Community Forum » Powered by YaBB 2.2.2!
YaBB © 2000-2008. All Rights Reserved.