Jump to content

finding the equation of a line ( continues data)


Recommended Posts

hi, I wonder if you can help me please?

I am not a mathematician, but used to teach science, so I have a little knowledge.

I am now disabled and use mobility scooters, I am trying to reasonably accurately predict the discharge of my batteries.

way back in the day, I used to use a Dos program called XY math ( I think).

It allowed you to enter experimental results and  plot them.

an algorithm would then test the data against about 20 equations of various types.

it would then give an indication of correlation and display the line (curve) of best fit.

I have searched Google that I can only find a program in French.

does anyone know of a current app. That I could use to do this.

preferably windows, if not android. Sorry, no Mac.

 Alternatively,can somebody suggest he correct search terms to use.

 

Link to comment
Share on other sites

Something like statistics and probability for when your battery will discharge.

 

If you want an online calulator and graph then I would guess something like Desmos. 

https://www.desmos.com/calculator/2rnqgoa6a4

https://www.desmos.com/calculator/zzxbryrahc

Start with a full battery, record how many hours you can go, and how far you went before you need to recharge. If you graph the numbers and they turn out to be a Normal Distribution you can then find the standard deviations and then the probability of when you will need to recharge.

Hope this helps.

8 hours ago, steve crr said:

 

Edited by NimrodTheGoat
Link to comment
Share on other sites

thanks for your reply,

 

There were a whole list of equations such as-

Y=mx+c

y=m2+c

y=M+1/x2+C

Logs

Polynomials

Trignometric

Quadratic

exponential etc.

 

The The algorithm would then find the expression that match the entered data closest. It may not be an exact match, but close enough to make approximate predictions

 

 

 

Link to comment
Share on other sites

First question: are you using Excel?

(I'm not sure how it works with other stuff).

Second question.

Can you get it to plot a scatter plot of miles vs charge (or whatever)?

If so, it should be a matter of Right  clicking on the graph and selecting "add trend line" then selecting the type of trend line you want (polynomial or whatever adn clicking the buttons for "display equation on graph" (or something like that.)

Failing that, I'm curious to know what the data looks like.

If you post it here I will stuff it into a spreadsheet for you (as long as there's not huge amounts of it).

Link to comment
Share on other sites

thanks for your offer of help.

I am actually using open office, but it seems almost identical in function.

I can plot graphs and add trendlines, but there are only a limited number of options for the trendline, non  of them seem to fit the data.

 

A set of data is below (file attached)

 

Voltage  distance miles.

-image.png.ae07faf2f7de139017661752c14ce1fc.png

test data.xls

Link to comment
Share on other sites

A quick look suggests that there's something else strongly affecting some of the data.

 

If you remove the first two rows of data the remainder fit very well to a linear model.

Given how much easier it is to work with linear approximations than with anything else, I'd go with that.

 

Was there anything special about the first two point?

Are you able to monitor the temperature of the battery?

 

Link to comment
Share on other sites

Hi

Looking at your data,

 it looks a little screwy

 when fully charged (& then discharging)

 between 26.7 V - 25.8 V = 0.9 V difference

 is not much mileage (1.8 Miles).

~2 Miles/V.

 

But between 25.7 V - 24.4 V =1.3 V difference

 you're getting almost a straight line

 & travelled 13.24 Miles !

 

You're getting (very) ruffly  ~10 Miles per (that) volt discharged.

 

So you can throw away (=forget) the first top 1 volt (as overcharge);

 or else you have typing errors in the table.

Let

y=Voltage

 x=miles

 b=25.7 V (starting voltage, after the 1st 2 Miles)

 m=-0.1 V/Mile (slope)

y=m*x+b

=(-0.1 V/Mile)*13.2 Miles + 25.7 V

=24.4 V.

 

That's NOT a curve,

 so (I guess) it probably will not help you.

 

 

If you insist on x being the total mileage (but ignore the first 2 miles),

 maybe

y=~(-0.1 V/Mile)*(x-1.8 Miles) + 25.7 V,

for when x=1.8 .. 17.1 Miles.

 

I hope that helps a bit.

 

Mofa's_Miles_vs_Battery_Voltage_test data_2018_05_22_2305_PS_Wi.xls

Edited by Capiert
Link to comment
Share on other sites

Hi Capiert,

 

Thank you very much for spending time on this.

The data is behaving exactly as expected, it is a curve.

The initial 2 Points are where the battery voltage drops rapidly as surface charge is taken from the Cells I agree these can be ignored.

I agree we are.lacking data towards the high discharge end Of the data, but believe me it is non-linear I have been using scooters for far too many years and the drop-off from about 12 V Increases rapidly. Also, curvature can be seen.

Below is an article on modelling battery Behaviour.  Battery discharge curves can be found on page 12. Which confirms this.

it is really the software application I am after, rather than how to calculate it.

If I can't find the software, I'll simply take more readings towards the high discharge end, plot a curve manually and extrapolate that, but it's not as elegant, I really would like a formula so I can get a simple prediction of distance left.

Once again, many thanks for your efforts.

 

 

NimrodTheGoat

 

Thanks for taking the time to reply.

I could not see how to enter raw data into Demos.

yes, this approach would work. However, discharging the battery  fully reduces their life i.e. the number of times they can be recharged. So I do routinely discharge the battery is fully. So cannot use this method.

I am looking for some software that will find the equation for the discharge data. (see previous post).

Thanks again for replying,

Steve

 

 

Edited by steve crr
dictation errors
Link to comment
Share on other sites

Is the purpose to extrapolate beyond the collected distance range? If so i wouldn't recommend it - from the statistics alone you cannot guarantee that the data will behave in the same way in the unobserved range as in the observed range -  unless you have good theoretical reason to suspect so. Can you afford at least one full discharge to collect such data?

A quick check to see if this is the case is the check the residuals of whatever model you fit - if the residuals are are getting wider (or narrower) then your model may not be ideal.

Sorry, don't know any suitable free software. Fancy learning something like R?

Link to comment
Share on other sites

hi Prometheus,

thanks for taking the time to reply.

From the data graphs shown, professionally carried out battery tests, and my own experience, a battery can be considered to have used the majority of its useful Charge when the voltage drops to 11 Volts. By extrapolating the graph back to 11 V and repeating it, it will give me an indication of the maximum range. Furthermore the Reproducibility of this value will give me an indication of the reliability of the findings.

 

I probably could discharge the battery fully once or twice. But there are so many variables involved that this would not give me a very good indication of range. I guess truly it is something I don't need to do, but it's something I want to do.

Thanks again.

 

Link to comment
Share on other sites

On 23.05.2018 at 9:09 AM, steve crr said:

it is really the software application I am after, rather than how to calculate it.

From equation there can be created software application e.g. in .NET Framework or HTML code with JavaScript. So you will be able to use it. But we need to know where do you want it to work. Smartphone, desktop computer or laptop or both? HTML approach will work on both.

I created this HTML and JavaScript code for you:

<html>
<script type="text/javascript">
function calculate()
{
 var voltage_start = document.getElementById( 'voltage_start' ).value;
 var distance_start = document.getElementById( 'distance_start' ).value;
 var voltage_end = document.getElementById( 'voltage_end' ).value;
 var distance_end = document.getElementById( 'distance_end' ).value;
 //alert( 'Voltage Start=' + voltage_start );
 //alert( 'Distance Start=' + distance_start );
 //alert( 'Voltage End=' + voltage_end );
 //alert( 'Distance End=' + distance_end );
 var delta_voltage = voltage_start - voltage_end;
 var delta_distance = distance_end - distance_start;
 var distance;
 if( delta_voltage == 0 )
 {
  distance = "Undefined";
 }
 else
 {
  distance = delta_distance * voltage_end / delta_voltage;
 }
 document.getElementById( 'distance_predicted' ).value = distance;
}
</script>
<body>
<table>
<tr>
<td>Start Voltage</td>
<td><input type="text" id="voltage_start" value="0" onchange="calculate();" ></td>
<td>Start Distance</td>
<td><input type="text" id="distance_start" value="0" onchange="calculate();" /></td>
</tr>
<tr>
<td>End Voltage</td>
<td><input type="text" id="voltage_end" value="0" onchange="calculate();" /></td>
<td>End Distance</td>
<td><input type="text" id="distance_end" value="0" onchange="calculate();" /></td>
</tr>
<tr>
<td colspan="2"> </td>
<td>Predicted Distance</td>
<td><input type="text" id="distance_predicted" value="0" readonly /></td>
</tr>
</table>
</body>
</html>
	

Save it to e.g. index.html file, and open in web browser.

Adjust equation from line "distance = delta_distance * voltage_end / delta_voltage;" to your needs.

You can ask David @fiveworlds to add dynamic generation of image in JavaScript code to draw graph.

Edited by Sensei
Link to comment
Share on other sites

Hi Sensei,

 

Wow, I wasn't expecting that amount of effort. Thank you very much.

 

Whilst it would be handy to have something that would run on the browser. I am fairly familiar with programming in Visual Basic.net. So that would actually give me the most flexibility.

 

I do not profess to follow the code with any degree of certainty, however it appears to assume a linear relationship.

 

If that is the case, I am afraid it will not work.

 

page 12 on https://pdfs.semanticscholar.org/10b9/3c3ce7adae76e1ef0b5ca1f0c83d660f6090.pdf

contains a manufacturers  graph that clearly shows the relationship is non-linear.

Once again, many thanks for your effort.

 

Link to comment
Share on other sites

On 24.05.2018 at 1:51 PM, steve crr said:

unfortunately, that's the easy bit, is finding the equation that's the problem.

Easy/quick way is simply to make envelope.

Like ADSR.

https://en.wikipedia.org/wiki/Synthesizer#Attack_Decay_Sustain_Release_(ADSR)_envelope

There are needed to store just a few control points enough to interpolate and/or extrapolate the rest of curve.

Link to comment
Share on other sites

On 26.05.2018 at 9:24 PM, steve crr said:

Thanks for your reply, but I'm afraid this is beyond me.

Curve which is passing through the all control points is called Catmull-Rom curve. There is ready source code on Wikipedia page:

https://en.wikipedia.org/wiki/Centripetal_Catmull–Rom_spline

https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull–Rom_spline

ADSR envelope is even easier, because it's not curve, but series of linear equations, one by one, triggered by time..

 

Edited by Sensei
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.