11-24-2012 03:25 AM - edited 11-24-2012 03:26 AM
Hi Scuba,
based on your physical model (battery discharge vs time) you can use a suitable fitting function, found in the mathematics palette...
Then you could present fitting parameters to the user or use the graph cursors to control the fitting algorithm.
11-24-2012 09:24 AM
If your process does not have a well defined function (from theory), you could use a piecewise linear approximation from the pairs of [x,y] points. If you need derivatives, you may need to pay special attention to the segment junctions.
Lynn
11-24-2012 10:37 AM
I don't think a piecewise representation would work properly as there are no theoretical equations for the relationships between the battery parameters. The parameters can be modeled In these sort of graphs and it is the only information I can find.
I tried the polynomial fit VI though I don't really get how I am supposed to use it. I attached the VI I am working on in which I am trying to create a formula that can model the graph generated. I used array constants to create a makeshift graph/x-y relationship. I am sorry for being such a squid.
11-24-2012 10:53 AM
Scubaman,
Your VI does not include any data. It looks like you tried to Make Current Value Default but clicked on the numeric control rather than the Array border. The VI has empty arrays with the default value for the numeric in the time array = 8.5 and in the volts array = 1.2. Those were probably the first elements in your array or the ones visible when you tried to Make Current Values Default. This is one of those subtle little things which can catch you off guard.
Lynn
11-24-2012 10:58 AM
Oops! Ok I used an array constant this time for the values. Here you go.
11-24-2012 12:57 PM
Scubaman,
It is not considered polite to post VIs which run forever. Change the False constant wired to the loop termination terminal to a control (and change the mechincal action to Latch When Released).
If you look at the error output of the General Polynomial Fit.vi you find that it is not happy because the input arrays are different sizes. From the Help menu select Explain error... and enter the value of the error code = -20002.
I deleted the last two elements of the time array and then the Fit VI runs. I connected a control to the Polynomial Order input and an indicator to the Residue output. Residue is a measure of the error of the fit. See the Detailed Help for more information. I plotted the on the same graph as the data to see how the fit looked.
The shape of the curve resembles an odd order polynomial and the residue drops to a low value when the order becomes 3. Slightly higher order polynomials produce lower residues but the extra computation time may not be worth the trouble. At much higher orders the fit becomes worse, which is typical behavior for polynomial fitting.
You can then use the polynomial coefficients output with the Polynomial Evaluation.vi to evaluate the curve for any value of the independent varaible. Note that ploynomial fits do not extrapolate well beyond the endpoints of the data used to fit.
Lynn
11-24-2012 05:12 PM
Thank you Lynn that is a great way of displaying the best fit line. And I promise to not post any VIs that cannot be stopped with a button.
My next task is to extract a 4th order polynomial equation from this. This equation would be in the form y= a + bx + cx^2 + dx^3. Using the program CurveExpert, I am given a, b, c and d. How do I do this?
After I have those four coefficients, I need to create a formula node using these so I can use the discharge rate as the x value and the discharge time as the y value. I then have to find a way to account for different discharge rates. A formula will need to be applied to the previous formula to account for different battery discharge rates. Unfortunately the relationship between two different discharge rates on this plane is also non-linear. As the discharge rate increases, the curves at the end become increasingly steep, while the linear portion in the middle shifts down. The opposite happens as the discharge rate decreases. Once I know how to do this I can then apply the same procedure to the other relationships to create an accurate estimation of battery SOC.
11-24-2012 05:13 PM
*How do I do this in Labview
11-24-2012 05:45 PM
Scubaman,
Use the Polynomial Coefficients output from the General Polynomial Fit.vi. They are in order of acsending power so element 0 should corresond to "a" in the equation form you specified. Set Polynomial Order to 4. Wtih your data I get 1.48491, -0.158598, 0.0335117, -0.00310509, 4.63377E-5.
Lynn
11-24-2012 05:55 PM
Scubaman,
I just read your post more carefully.
Do you have a manually generated table of points for each curve in the family, like the ones in the graph in the third message in this thread?
If so, run the fitting process for each curve. Store the coefficients in a 2D array where each row represents the curve for a different discharge current. For a given current select the row nearest the current and use the Polynomial Evaluation.vi to get a plot for that value. For intermediate values you can interpolate by calculating the curve for the nearest currents above and below the specified value.
I do not think you need the formula node. Just use the polynomial VIs and some interpolation.
Lynn