Skip to main content
Mohan1
Associate III
January 2, 2020
Question

Can i write polynomial equation in STM32cubeIDE

  • January 2, 2020
  • 3 replies
  • 821 views

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.

This topic has been closed for replies.

3 replies

Tesla DeLorean
Guru
January 2, 2020

>> 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) ...

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
Mohan1
Mohan1Author
Associate III
January 2, 2020

@Community member​ Thanks for your response sir.

RMcCa
Senior II
January 2, 2020

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[].​

Mohan1
Mohan1Author
Associate III
January 4, 2020

@RMcCa​ Thanks for your reply sir.