2020-01-01 08:05 PM
Hello,
I am trying to estimate initial SOC of battery by using a polynomial equation obtained from discharged voltage data of battery. I successfully run this polynomial equation in MATLAB but don't know how to write in STM32cubeIDE.
The obtained polynomial equation is-
p1 = 9.722*10^(-24);
p2 = -1.565*10^(-19);
p3 = 9.908*10^(-16);
p4 = -3.139*10^(-12);
p5 = 5.22*10^(-9);
p6 =-4.318*10^(-6);
p7 = 0.00127;
p8 = 3.709;
x=4;
j = p1*(x.^7)+p2*(x.^6)+p3*(x.^5)+p4*(x.^4)+p5*(x.^3)+p6*(x.^2)+p7*(x)+p8
Here 'j' is polynomial equation and 'x' is initial voltage of battery.
Thanks.
2020-01-01 08:48 PM
>> don't know how to write in STM32cubeIDE.
Write it in C
>> p1 = 9.722*10^(-24);
p1 = 9.722e-24;
>> j = p1*(x.^7)+p2*(x.^6)+p3*(x.^5)+p4*(x.^4)+p5*(x.^3)+p6*(x.^2)+p7*(x)+p8
j = p1*pow(x,7) + p2*pow(x,6) ...
2020-01-01 09:22 PM
@Community member Thanks for your response sir.
2020-01-02 04:20 AM
You could also declare 2 vectors (1 dimensional arrays) and use arm_dot_prod_f32() to do all the multiplying and adding.
Declare p[8] and initialize all 8 values and x[8]. Set x[0] = 1.0 and then use a for loop to calculate the other x[]s as they are simply the input value * the previous x[].
2020-01-03 09:10 PM
@RMcCa Thanks for your reply sir.