主题中讨论的其他器件:INA228、 INA226
Ω 10A 的最大电流、如果分流电阻为0.005 μ A、则无法实现正确的电流测量。 即使分流电压读数刚好在现场、也是如此。
如果我们计算 CURRLSBCALC 为13107.2 x 10^7 x CURRENT_LSB x RSHUNT、然后将寄存器7h (向右移4位)的内容乘以 CURRENT_LSB、然后乘以10、我们得到正确的电流值。
是否确定数据表值正确? 还是软件方面的错误?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Ω 10A 的最大电流、如果分流电阻为0.005 μ A、则无法实现正确的电流测量。 即使分流电压读数刚好在现场、也是如此。
如果我们计算 CURRLSBCALC 为13107.2 x 10^7 x CURRENT_LSB x RSHUNT、然后将寄存器7h (向右移4位)的内容乘以 CURRENT_LSB、然后乘以10、我们得到正确的电流值。
是否确定数据表值正确? 还是软件方面的错误?
您好 Mitch、
请在下面找到所需的信息。
SHUNT_CAL 原始值:1250
VSHUNT 原始值:13680
分流电压:0.00027
当前原始值:-21472
分流电流:-0.02560
我使用的 VBUS 电压为24V、负载电阻为470Ω Ω、因此分流电压读数很好。 电流读数为负、我没有理想原因...
原理图如下所示、请记住、我们使用原理图的 INA-48V 部分、分流器为5mΩ Ω、我们使用的 INA 是 INA228-Q1、而不是原理图上所写的 INA226。
我用于读取寄存器的代码如下:
#define INA2228_REG_CONFIG(0x00)
#define INA2228_REG_ADCCONFIG(0x01)
#define INA2228_REG_SHUNTCAL (0x02)
#define INA2228_REG_TEMPSCOCONFIG (0x03)
#define INA2228_REG_VSHUT(0x04)
#define INA2228_REG_VBUS (0x05)
#define INA2228_REG_DIETEMP (0x06)
#define INA2228_REG_CURRENT(0x07)
#define INA2228_REG_POWER (0x08)
#define INA2228_REG_ENERGY (0x09)
#define INA2228_REG_CHARGE (0x0A)
#define INA2228_REG_DIAGALRT (0x0B)
#define INA2228_REG_SOVL (0x0C)
#define INA2228_REG_SUVL (0x0D)
#define INA2228_REG_BOVL (0x0E)
#define INA2228_REG_BUVL (0x0F)
#define INA2228_REG_TEMPLIMIT (0x10)
#define INA2228_REG_PWRLIMIT (0x11)
#define INA2228_REG_MANUFACTURID (0x3E)
#define INA2228_REG_DEVICEID (0x3F)
int32_t INA228::readRegister24 (uint8_t reg)
{
int32_t 值= 0;
Wire.beginTransmission(inaAddress);
Wire.write (reg);
wire.endTransmission ();
Wire.requestFrom (inaAddress、3);
uint8_t vha = Wire.read();
uint8_t vMA = Wire.read();
uint8_t VLA = Wire.read();
值=(uint32_t) vha << 16 |(vMA << 8)| VLA;
返回值;
}
int16_t INA228::readRegister16 (uint8_t reg)
{
int16_t 值;
Wire.beginTransmission(inaAddress);
Wire.write (reg);
wire.endTransmission ();
Wire.requestFrom (inaAddress、2);
uint8_t vha = Wire.read();
uint8_t VLA = Wire.read();
值= vha << 8 | VLA;
返回值;
}
void INA228::writeRegister16 (uint8_t reg、uint16_t val)
{
uint8_t vla;
VLA =(uint8_t) val;
Val >>= 8;
Wire.beginTransmission(inaAddress);
Wire.write (reg);
Wire.write ((uint8_t) val);
Wire.write (VLA);
Wire.endTransmission ();
}
bool INA228:::calibrate (float rShuntValue、float iMaxCurrentExpected)
{
uint16_t calibrationValue;
rShunt = rShuntValue;
float iMaxPosible;
iMaxPosible = vShuntMax/rShunt;
currentLSB = iMaxCurrentExpected / pow (2、19);
powerLSB =电流 LSB * 3.2;
energyLSB = currentLSB * 51.2;
chargeLSB =当前 LSB;
calibrationValue =(uint16_t)(13107.2 * pow (10、6)* currentLSB * rShunt);
writeRegister16 (INA2228_REG_SHUNTCAL、calibrationValue);
返回 true;
}
float INA228::readShuntCurrent (void)
{
int32_t CURRENT_RAW;
// Current_RAW = readRegister24 (INA2228_REG_CURRENT)>> 4;
Current_RAW = readRegister24 (INA2228_REG_CURRENT);
serial.println ((String)"当前原始值:"+ CURRENT_RAW);
CURRENT_RAW = CURRENT_RAW >> 4;
serial.print ("分流电流:");
serial.println (currentLSB,5);
return (Current_RAW * currentLSB);
}
float INA228::readShuntVoltage (void)
{
int32_t VOLTAGE_RAW;
// volte_raw = readRegister24 (INA2228_REG_VSHUT)>> 4;
VOLTGE_RAW = readRegister24 (INA2228_REG_VSHUT);
serial.println ((字符串)"shunt_CAL 原始值:"+ readRegister16 (INA2228_REG_SHUNTCAL));
serial.println ((String)"VSHUNT 原始值:"+ VOLTGE_RAW);
VOLTGE_RAW = VOLTGE_RAW >> 4;
serial.print ("分流电压:");
serial.println (volte_raw * 0.0000003125、5);
返回((浮点) VOLTGE_RAW * 0.0000003125);//如果 ADCRANGE = 0
}
Sebastião μ A、
感谢您的观看。 我要向数据表团队指出、该数字不一致。 不确定它们是否希望它为1或0、因为它是修订 ID、并且两个数字都可以存在。 (虽然目前大多数人会说1)。
至于电流读数问题、由于我能够通过 EVM 上的仿真设置获得预期的电流值、因此这不是一个一致的器件问题。 因此、我认为有2个测试路径:
1.如果问题出在您的硬件/软件上、最好尝试使用具有相同电流感应设置的 EVM、以查看您是否从中获得正确的值。
2.如果器件因某种原因损坏并导致了问题、则最好将 INA228与另一个器件交换、看看您是否遇到相同的问题。
通常、在 I2C 通信线路上放置示波器并确保 Arduino 报告的值与 I2C 总线上显示的值相同也不会有任何影响。
请执行上述测试、并告诉我测试结果如何。 (如果这可以解决您的问题、我会将此帖子标记为"TI 认为已解决"、但一旦您知道结果、我仍然很想了解这些结果)。
因此、在使用 EVM 之后、我发现问题出在 Arduino 方面。 这种“哈”的铸造是问题所在。 将 vha、vMA 和 vLA 定义为 uint32_t 可以解决问题。