梁工你好,请教一下下面的代码怎样理解呢
- while (1)
- {
- if(B_adc_ok)
- {
- B_adc_ok = 0;
-
- adc_filter[VOL_OUTPUT] = (adc_filter[VOL_OUTPUT] *3)/4 + adc[VOL_OUTPUT];
- j = adc_filter[VOL_OUTPUT] / 4; //输出电压, 低通滤波结果为14位,取值12位
- voltage = (u16)((float)j * Uo_SCALE); //输出电压, ADC结果12位, 分压电阻33K+3K,5V基准,量程30.00V,则V=adc*3000/4096 = adc*0.73242(实测为准), 计算结果分辨率0.01V, 2位小数
- adc_filter[CUR_OUTPUT] = (adc_filter[CUR_OUTPUT] *3)/4 + adc[CUR_OUTPUT];
- j = adc_filter[CUR_OUTPUT] / 2; //输出电流, 低通滤波结果为14位,取值13位
- if(j >= Io_adc_zero) j -= Io_adc_zero; //计算电流
- else j = 0;
- current = (u16)((float)j * Io_SCALE); //输出电流, ADC结果13位,20mR采样放大24/1.5=16倍,电流量程=2.5/16/0.02=7.8125A,则校准系数 = 7812.5/8192 = 0.9536,则电流 = adc * 0.9536
- j = PID_Compute((float)pid_Vol_Set, (float)voltage); //(float setpoint, float input)
- if(B_BAT_low || B_stop) j = 0, integral = 0; //电池低压 或 停止输出 则禁止PID
- PWM_Value = j;
复制代码
一、请问行7代码:adc_filter[VOL_OUTPUT] = (adc_filter[VOL_OUTPUT] *3)/4 + adc[VOL_OUTPUT];
这里的低通滤波算法是什么呢?
二、请问低通滤波结果为14位是怎样推算出来的呢?
三、请问输出电压、电流采样滤波后的结果分别取12位和13位是基于什么原因呢?
谢谢!
|