esp加入

This commit is contained in:
2025-10-19 19:08:23 +08:00
parent e7b0457fb9
commit 71ef7cdd20
16 changed files with 948 additions and 97 deletions

View File

@@ -15,8 +15,6 @@
Power_Out_t power_outs[POWER_OUT_NUM];
void Power_Out_Single_Init(Power_Out_t *power_out, int16 vot_channel, int16 amp_channel, float votK[2], float ampK[2], int16 enable_pin, uint8 can_adjust, int16 vot_pwm_channel)
{
if(enable_pin != POWER_OUT_FUNCTION_DISABLE)
@@ -27,6 +25,7 @@ void Power_Out_Single_Init(Power_Out_t *power_out, int16 vot_channel, int16 amp_
power_out->config.current_read_channel = amp_channel;
Init_lowPass_alpha(&power_out->config.vot_filter, POWER_OUT_READ_TIME_MS / 1000.0f, 10.0f);
Init_lowPass_alpha(&power_out->config.amp_filter, POWER_OUT_READ_TIME_MS / 1000.0f, 10.0f);
Init_lowPass_alpha(&power_out->config.vot_adc_filter, POWER_OUT_READ_TIME_MS / 1000.0f, 100.0f);
power_out->config.votK[0] = votK[0];
power_out->config.votK[1] = votK[1];
power_out->config.ampK[0] = ampK[0];
@@ -43,9 +42,9 @@ void Power_Out_Single_Init(Power_Out_t *power_out, int16 vot_channel, int16 amp_
memset(power_out->status.past_voltage_V, 0, sizeof(power_out->status.past_voltage_V));
memset(power_out->status.past_current_A, 0, sizeof(power_out->status.past_current_A));
power_out->set_voltage_V = 0.0f;
power_out->set_current_A = 0.0f;
power_out->max_power_W = 300.0f;
power_out->set_voltage_V = VOT_ADJUST_DEF;
power_out->set_current_A = AMP_ADJUST_DEF;
power_out->max_power_W = POW_ADJUST_DEF;
power_out->enabled = 0;
if(vot_channel != POWER_OUT_FUNCTION_DISABLE)
{
@@ -58,7 +57,7 @@ void Power_Out_Single_Init(Power_Out_t *power_out, int16 vot_channel, int16 amp_
if(vot_pwm_channel != POWER_OUT_FUNCTION_DISABLE)
{
pwm_init((pwm_channel_enum)vot_pwm_channel, VOT_PWM_FREQUENCY_HZ, 5000);
pwm_init((pwm_channel_enum)vot_pwm_channel, VOT_PWM_FREQUENCY_HZ, 10000);
}
}
@@ -103,6 +102,8 @@ void Power_Out_Single_Read(Power_Out_t *power_out)
{
// tmp = (float)adc_convert((adc_channel_enum)power_out->config.voltage_read_channel);
tmp = (float)adc_mean_filter_convert((adc_channel_enum)power_out->config.voltage_read_channel,2);
Low_pass_filter(&power_out->config.vot_adc_filter, tmp);
power_out->config.v_adc = tmp;
power_out->status.voltage_V = Low_pass_filter(&power_out->config.vot_filter, tmp) * power_out->config.votK[0] + power_out->config.votK[1];
}
else