PWM switch also implemented as class
This commit is contained in:
+11
-6
@@ -99,11 +99,15 @@ void update_measurements()
|
||||
(float)(((adc_filtered[ADC_POS_V_BAT] >> (4 + ADC_FILTER_CONST)) * vcc) / 4096) *
|
||||
ADC_GAIN_V_BAT / 1000.0;
|
||||
|
||||
#if FEATURE_DCDC_CONVERTER
|
||||
hv_bus.voltage =
|
||||
(float)(((adc_filtered[ADC_POS_V_SOLAR] >> (4 + ADC_FILTER_CONST)) * vcc) / 4096) *
|
||||
ADC_GAIN_V_SOLAR / 1000.0;
|
||||
#ifdef ADC_OFFSET_V_SOLAR
|
||||
hv_bus.voltage = hv_bus.voltage + -(vcc * ADC_OFFSET_V_SOLAR / 1000.0 + hv_bus.voltage);
|
||||
#endif
|
||||
#if FEATURE_PWM_SWITCH
|
||||
pwm_sw_ext.voltage = lv_bus.voltage - vcc * ADC_OFFSET_V_SOLAR / 1000.0 -
|
||||
(float)(((adc_filtered[ADC_POS_V_SOLAR] >> (4 + ADC_FILTER_CONST)) * vcc) / 4096) *
|
||||
ADC_GAIN_V_SOLAR / 1000.0;
|
||||
#endif
|
||||
|
||||
load_terminal.current =
|
||||
@@ -112,10 +116,12 @@ void update_measurements()
|
||||
|
||||
#if FEATURE_PWM_SWITCH
|
||||
// current multiplied with PWM duty cycle for PWM charger to get avg current for correct power calculation
|
||||
hv_terminal.current = - pwm_switch_get_duty_cycle() * (
|
||||
pwm_terminal.current = - pwm_switch.get_duty_cycle() * (
|
||||
(float)(((adc_filtered[ADC_POS_I_SOLAR] >> (4 + ADC_FILTER_CONST)) * vcc) / 4096) *
|
||||
ADC_GAIN_I_SOLAR / 1000.0 + solar_current_offset);
|
||||
lv_terminal.current = -hv_terminal.current - load_terminal.current;
|
||||
pwm_port_int.current = pwm_terminal.current;
|
||||
lv_terminal.current = -pwm_port_int.current - load_terminal.current;
|
||||
pwm_terminal.power = pwm_sw_ext.voltage * pwm_terminal.current;
|
||||
#endif
|
||||
#if FEATURE_DCDC_CONVERTER
|
||||
dcdc_port_lv.current =
|
||||
@@ -127,9 +133,8 @@ void update_measurements()
|
||||
|
||||
dcdc_port_lv.power = lv_bus.voltage * dcdc_port_lv.current;
|
||||
dcdc_port_hv.power = hv_bus.voltage * dcdc_port_hv.current;
|
||||
#endif
|
||||
|
||||
hv_terminal.power = hv_bus.voltage * hv_terminal.current;
|
||||
#endif
|
||||
lv_terminal.power = lv_bus.voltage * lv_terminal.current;
|
||||
load_terminal.power = lv_bus.voltage * load_terminal.current;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user