// 相位校准 typedef struct { float phase_0deg_voltage; // 0°对应电压 float phase_90deg_voltage; // 90°对应电压 float phase_180deg_voltage; // 180°对应电压 } phase_cal_data_t; void phase_calibration(void) { phase_cal_data_t cal_data; // 0°校准 - 输入同相信号 printf("请输入两路同相信号(0°相位差)\n"); delay_ms(2000); cal_data.phase_0deg_voltage = read_phase_voltage(); printf("0°校准电压: %.3fV\n", cal_data.phase_0deg_voltage); // 90°校准 - 输入正交信号 printf("请输入90°相位差信号\n"); delay_ms(2000); cal_data.phase_90deg_voltage = read_phase_voltage(); printf("90°校准电压: %.3fV\n", cal_data.phase_90deg_voltage); // 180°校准 - 输入反相信号 printf("请输入180°相位差信号\n"); delay_ms(2000); cal_data.phase_180deg_voltage = read_phase_voltage(); printf("180°校准电压: %.3fV\n", cal_data.phase_180deg_voltage); // 计算校准系数 float scale = (cal_data.phase_180deg_voltage - cal_data.phase_0deg_voltage) / 180.0; printf("相位比例系数: %.4f V/°\n", scale); // 保存校准数据 save_calibration_data(&cal_data); } // 温度补偿校准 void temperature_compensation(void) { float temp_voltage = read_temperature_voltage(); float temperature = (temp_voltage - 0.5) / 0.01; // 10mV/°C // 温度补偿系数 const float PHASE_TEMP_COEFF = 0.5; // °/°C const float GAIN_TEMP_COEFF = 0.1; // dB/°C float temp_offset = (temperature - 25.0); float phase_temp_error = PHASE_TEMP_COEFF * temp_offset; float gain_temp_error = GAIN_TEMP_COEFF * temp_offset; printf("环境温度: %.1f°C\n", temperature); printf("相位温度误差: %.2f°\n", phase_temp_error); printf("增益温度误差: %.2fdB\n", gain_temp_error); }