我是arduino的新手,我正在尝试编写一个程序,使用coulomb countig方法(下面是带有公式的图片)计算电池中剩余电量的百分比。是否有可能在arduino上执行这种类型的计算?

发布于 2021-03-21 17:52:04
1.)模型
假设CBat是电池的容量和常数(物理学家更喜欢用字母Q表示电荷;CBat可能会随着年龄的增长而减少,“健康状态”)
根据定义:
SOC(t) = Q(t)/CBat微分方程:
dQ/dt = I(t)近似:"dt=1“
Q(t)-Q(t-1) ~= I(t)或
SOC(t) ~= SOC(t-1) + I(t)/Cbat2.)Ardunio:以下是一个纯虚拟脚本,在线编译器不会提供服务。
// Assume current coming from serial port
const float C_per_Ah = 3600;
// signal adjustment
const float current_scale_A = 0.1; // Ampere per serial step
const int current_offset = 128; // Offset of serial value for I=0A
float CBat_Ah = 94; /* Assumed Battery Capacity in Ah */
float Cbat_C = CBat_Ah * C_per_Ah; /* ... in Coulomb */
float SOC = 0.7; /* Initial State of Charge */
int incomingByte = current_offset; // for incoming serial data, initial 0 Ampere
float I = 0; /* current */
// the setup routine runs once when you press reset:
void setup()
{
Serial.begin(9600); // opens serial port, sets data rate to 9600 bps
}
// the loop routine runs over and over again forever:
void loop()
{
delay(1000); // wait for a second
if (Serial.available() > 0)
{
// read the incoming byte:
incomingByte = Serial.read();
}
I = (incomingByte-current_offset) * current_scale_A;
SOC = SOC + I/Cbat_C;
Serial.print("New SOC: ");
Serial.println(SOC, 4);
}https://stackoverflow.com/questions/66724140
复制相似问题