我使用Adafruit INA219模块来测量线性执行器的电压和电流,我有一个关于如何根据我的情况最好地校准模块的问题。
我有一个12V的电源(类似于一个电源砖的笔记本电脑),有一个最大的电流等级为10A。执行机构额定为12V @ 5A最大,提供35磅的力量。我使用MegaMoto驱动盾来驱动执行器,并使用Arduino Nano作为控制器。
INA219模块的默认校准似乎是32V @ 2A,它还有一些其他设置可通过函数调用这里来实现,但我看不到任何适合12V @ 5A情况的设置,如果要编写一个新的函数来校准INA219,则不确定对各种值使用什么。有人知道我能用什么吗?
我希望我能在这个模块上得到准确的读数,以满足我的需求,但我却得到了一些相当大的价值波动和一些奇怪的(?)分流电压值(或者很可能,我只是不明白它们)。例如,当移动执行器时,我每1ms读取一次15毫秒的模块值,然后平均输出功率使用情况,并以此作为一种筛选出高低值的方法,以查看一般的功率使用情况。我使用的是示例代码中的公式:
shuntvoltage = ina219.getShuntVoltage_mV();
busvoltage = ina219.getBusVoltage_V();
current_mA = ina219.getCurrent_mA();
loadvoltage = busvoltage + (shuntvoltage / 1000);
power = current_mA * loadvoltage;
下面是一个阅读的例子:
分流电压:-31.76母线电压: 12.16 current_mA:-258.60电压: 12.13电源:-3137.40 分流电压:-59.12母线电压: 12.16 current_mA:-548.50电压: 12.10功率:-6637.33 分流电压:-52.00母线电压: 12.18 current_mA:-691.30电压: 12.12功率:-8381.32 分流电压:-32.09母线电压: 12.12 current_mA:-936.60电压: 12.09电源:-11321.54 分流电压:-27.42母线电压: 12.11 current_mA:-286.00电压: 12.08电源:-3455.05 分流电压:-86.82母线电压: 12.11 current_mA:-338.90电压: 12.03电源:-4075.33 分流电压:-67.63母线电压: 12.16 current_mA:-620.90电压: 12.09电源:-7508.15 分流电压:-30.81母线电压: 12.18 current_mA:-874.60电压: 12.15功率:-10625.68 分流电压:-30.31母线电压: 12.11 current_mA:-346.90电压: 12.08电源:-4189.75 分流电压:-71.75母线电压: 12.16 current_mA:-557.00电压: 12.09电源:-6733.16 分流电压:-48.03母线电压: 12.18 current_mA:-668.70电压: 12.13功率:-8112.65 分流电压:-31.90母线电压: 12.18 current_mA:-938.20电压: 12.15功率:-11397.35 分流电压:-30.14母线电压: 12.12 current_mA:-627.20电压: 12.09电源:-7580.25 分流电压:-31.42母线电压: 12.14 current_mA:-430.20电压: 12.10功率:-5207.39 分流电压:-66.28母线电压: 12.17 current_mA:-643.70电压: 12.10功率:-7789.88 分流电压:-30.93母线电压: 12.18 current_mA:-880.00电压: 12.15功率:-10694.70
为什么分流电压值是负数?现在的值呢?也许我只需要扭转极性。
以下是执行器上的规格:PA-14P.pdf
发布于 2016-09-28 20:27:27
以下是Adafruit代码的摘录。给出了参数的计算方法。您还可以在INA219数据表中找到解释的信息。这是一个如何设置16V 400 an集成电路的例子。
void Adafruit_INA219::setCalibration_16V_400mA(void) {
// Calibration which uses the highest precision for
// current measurement (0.1mA), at the expense of
// only supporting 16V at 400mA max.
// VBUS_MAX = 16V
// VSHUNT_MAX = 0.04 (Assumes Gain 1, 40mV)
// RSHUNT = 0.1 (Resistor value in ohms)
// 1. Determine max possible current
// MaxPossible_I = VSHUNT_MAX / RSHUNT
// MaxPossible_I = 0.4A
// 2. Determine max expected current
// MaxExpected_I = 0.4A
// 3. Calculate possible range of LSBs (Min = 15-bit, Max = 12-bit)
// MinimumLSB = MaxExpected_I/32767
// MinimumLSB = 0.0000122 (12uA per bit)
// MaximumLSB = MaxExpected_I/4096
// MaximumLSB = 0.0000977 (98uA per bit)
// 4. Choose an LSB between the min and max values
// (Preferrably a roundish number close to MinLSB)
// CurrentLSB = 0.00005 (50uA per bit)
// 5. Compute the calibration register
// Cal = trunc (0.04096 / (Current_LSB * RSHUNT))
// Cal = 8192 (0x2000)
ina219_calValue = 8192;
// 6. Calculate the power LSB
// PowerLSB = 20 * CurrentLSB
// PowerLSB = 0.001 (1mW per bit)
// 7. Compute the maximum current and shunt voltage values before overflow
//
// Max_Current = Current_LSB * 32767
// Max_Current = 1.63835A before overflow
//
// If Max_Current > Max_Possible_I then
// Max_Current_Before_Overflow = MaxPossible_I
// Else
// Max_Current_Before_Overflow = Max_Current
// End If
//
// Max_Current_Before_Overflow = MaxPossible_I
// Max_Current_Before_Overflow = 0.4
//
// Max_ShuntVoltage = Max_Current_Before_Overflow * RSHUNT
// Max_ShuntVoltage = 0.04V
//
// If Max_ShuntVoltage >= VSHUNT_MAX
// Max_ShuntVoltage_Before_Overflow = VSHUNT_MAX
// Else
// Max_ShuntVoltage_Before_Overflow = Max_ShuntVoltage
// End If
//
// Max_ShuntVoltage_Before_Overflow = VSHUNT_MAX
// Max_ShuntVoltage_Before_Overflow = 0.04V
// 8. Compute the Maximum Power
// MaximumPower = Max_Current_Before_Overflow * VBUS_MAX
// MaximumPower = 0.4 * 16V
// MaximumPower = 6.4W
// Set multipliers to convert raw current/power values
ina219_currentDivider_mA = 20; // Current LSB = 50uA per bit (1000/50 = 20)
ina219_powerDivider_mW = 1; // Power LSB = 1mW per bit
// Set Calibration register to 'Cal' calculated above
wireWriteRegister(INA219_REG_CALIBRATION, ina219_calValue);
// Set Config register to take into account the settings above
uint16_t config = INA219_CONFIG_BVOLTAGERANGE_16V |
INA219_CONFIG_GAIN_1_40MV |
INA219_CONFIG_BADCRES_12BIT |
INA219_CONFIG_SADCRES_12BIT_1S_532US |
INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS;
wireWriteRegister(INA219_REG_CONFIG, config);
}
让我们从最大母线电压开始。你有一个12V的电源,所以我们坚持16V的例子(你可以选择16V和32V),并联电阻值为0.1欧姆为Adafruit板。您的执行器在最大负载时绘制5A。欧姆定律告诉我们,最大电流会使并联电阻的电压下降0.5V,所以我们的VSHUNT_MAX是0.5。
现在计算当前测量的LSB值。5A / 32767LSB =每个LSB 150 A(当然,如果你不需要完全分辨率的话,你可以选择其他的东西)
根据数据表中的公式计算校准寄存器: Cal = trunc (0.04096 / 0.00015 / 0.1) = 2730
等等..。我希望你明白重点。
https://stackoverflow.com/questions/39713799
复制相似问题