```
refactor(device): 重构角度传感器模块并优化ADC电压计算 - 将 tle5012b 角度传感器相关文件重命名为 ang_sensor,统一接口命名 - 修正母线电压采样计算公式,增加 VCC_FACTOR 校正系数 - 移除 main.cpp 中重复和未使用的头文件引用 - 删除对旧角度传感器初始化函数的调用,改用新接口读取角度 ```
This commit is contained in:
@@ -129,7 +129,8 @@ float sampler::get_vbus_voltage() {
|
||||
* 如果计算结果超出有效范围(-40到255摄氏度),则重新采样计算。
|
||||
*/
|
||||
void sampler::update_mcu_temp() {
|
||||
memmove(mcu_temp_samples, mcu_temp_samples + 1, FILTER_SIZE * sizeof(float));
|
||||
memmove(mcu_temp_samples, mcu_temp_samples + 1,
|
||||
FILTER_SIZE * sizeof(float));
|
||||
mcu_temp_samples[FILTER_SIZE] =
|
||||
(1.43f - adc_value[0] * ADC_SCALE) * TEMP_FACTOR + 35.0f;
|
||||
}
|
||||
@@ -138,7 +139,8 @@ void sampler::update_mcu_temp() {
|
||||
* @brief 更新MCU温度
|
||||
*/
|
||||
void sampler::update_drv_temp() {
|
||||
memmove(drv_temp_samples, drv_temp_samples + 1, FILTER_SIZE * sizeof(float));
|
||||
memmove(drv_temp_samples, drv_temp_samples + 1,
|
||||
FILTER_SIZE * sizeof(float));
|
||||
float R_now = (float)adc_value[1] / (4096 - (float)adc_value[1]) * 4700;
|
||||
drv_temp_samples[FILTER_SIZE] =
|
||||
1.0f / (0.00335f + 0.00025f * log(R_now / 10000.0f)) - 273.15f;
|
||||
@@ -165,5 +167,5 @@ void sampler::update_current() {
|
||||
*/
|
||||
void sampler::update_vbus_voltage() {
|
||||
memmove(vbus_samples, vbus_samples + 1, FILTER_SIZE * sizeof(float));
|
||||
vbus_samples[FILTER_SIZE] = adc_value[5] * ADC_SCALE;
|
||||
vbus_samples[FILTER_SIZE] = adc_value[5] * ADC_SCALE * VCC_FACTOR;
|
||||
}
|
||||
Reference in New Issue
Block a user