esp网页监控面板框架已成,通讯解决

This commit is contained in:
2025-10-29 00:05:05 +08:00
parent c1436f00f0
commit 3db2af8d2f
22 changed files with 13811 additions and 12266 deletions

View File

@@ -88,7 +88,7 @@ void ESP8266_Into_Download_Mode(void)
gpio_set_level(ESP8266_IO2, 1);
gpio_set_level(ESP8266_IO15, 0);
gpio_set_level(ESP8266_EN, 0);
system_delay_ms(1);
system_delay_ms(10);
gpio_set_level(ESP8266_EN, 1);
}
@@ -150,6 +150,7 @@ void ESP8266_Uart_Callback(void)
}
else
{
esp8266_get_config_pkt_index = 0;
}
}

View File

@@ -17,7 +17,7 @@
#define ESP8266_EN P20_6
#define ESP8266_UART_CHANNEL UART_2
#define ESP8266_UART_BAUDRATE 115200
#define ESP8266_UART_BAUDRATE 1152000
#define ESP8266_UART_TX_PIN UART2_TX_P33_9
#define ESP8266_UART_RX_PIN UART2_RX_P33_8
@@ -56,6 +56,7 @@ void ESP8266_Uart_Callback(void);
void ESP8266_send_data(uint8 *data, uint32 len);
void ESP8266_Set_Config(uint8 *ssid, uint8 *password, uint8 *target_ip, uint16 target_port);
void ESP8266_Into_Change_Config_Mode(uint8 on);
void ESP8266_Into_Download_Mode(void);
// void ESP8266_Auto_Download_Uart_Hook(void);
// void ESP8266_Uart_Callback(void);
// void ESP8266_Main_Loop_Change_Mode(void);

View File

@@ -129,10 +129,37 @@ void Power_Ctrl_Loop_1ms(void)
timer_counter_1ms %= (1 * 500);
}
typedef union
{
uint8 send[4];
float data;
}tmp_float_data;
float Power_Vot_Protect_Send_Parser(void)
{
tmp_float_data protect_status;
for(uint8 i = 0; i < POWER_OUT_NUM; i++)
{
protect_status.send[0] |= (power_outs[i].status.voltage_protect_triggered >= power_outs[i].config.protect_trigger_cycles) << i;
}
for(uint8 i = 0; i < POWER_OUT_NUM; i++)
{
protect_status.send[1] |= (power_outs[i].status.current_protect_triggered >= power_outs[i].config.protect_trigger_cycles) << i;
}
for(uint8 i = 0; i < POWER_OUT_NUM; i++)
{
protect_status.send[2] |= (power_outs[i].status.power_protect_triggered >= power_outs[i].config.protect_trigger_cycles) << i;
}
for(uint8 i = 0; i < INA226_NUM; i++)
{
protect_status.send[3] |= (ina226[i].result.alert_flag) << i;
}
return protect_status.data;
}
void Power_Status_Upload(void)
{
VOFA_Set_JustFloat_Data(0, power_outs[0].status.voltage_V);
VOFA_Set_JustFloat_Data(1, power_outs[0].status.current_A);
VOFA_Set_JustFloat_Data(2, power_outs[1].status.voltage_V);
@@ -154,8 +181,42 @@ void Power_Status_Upload(void)
VOFA_Set_JustFloat_Data(18,ina226[1].result.voltage_V);
VOFA_Set_JustFloat_Data(19,ina226[1].result.current_A);
VOFA_Set_JustFloat_Data(22,vofa_last_data);
VOFA_Send_Datas(27);
VOFA_Set_JustFloat_Data(20,power_outs[0].status.power_W);
VOFA_Set_JustFloat_Data(21,power_outs[0].status.energy_J);
VOFA_Set_JustFloat_Data(22,power_outs[0].status.quantity_C);
VOFA_Set_JustFloat_Data(23,power_outs[1].status.power_W);
VOFA_Set_JustFloat_Data(24,power_outs[1].status.energy_J);
VOFA_Set_JustFloat_Data(25,power_outs[1].status.quantity_C);
VOFA_Set_JustFloat_Data(26,power_outs[2].status.power_W);
VOFA_Set_JustFloat_Data(27,power_outs[2].status.energy_J);
VOFA_Set_JustFloat_Data(28,power_outs[2].status.quantity_C);
VOFA_Set_JustFloat_Data(29,power_outs[3].status.power_W);
VOFA_Set_JustFloat_Data(30,power_outs[3].status.energy_J);
VOFA_Set_JustFloat_Data(31,power_outs[3].status.quantity_C);
VOFA_Set_JustFloat_Data(32,power_outs[4].status.power_W);
VOFA_Set_JustFloat_Data(33,power_outs[4].status.energy_J);
VOFA_Set_JustFloat_Data(34,power_outs[4].status.quantity_C);
VOFA_Set_JustFloat_Data(35,power_outs[5].status.power_W);
VOFA_Set_JustFloat_Data(36,power_outs[5].status.energy_J);
VOFA_Set_JustFloat_Data(37,power_outs[5].status.quantity_C);
VOFA_Set_JustFloat_Data(38,power_outs[6].status.power_W);
VOFA_Set_JustFloat_Data(39,power_outs[6].status.energy_J);
VOFA_Set_JustFloat_Data(40,power_outs[6].status.quantity_C);
VOFA_Set_JustFloat_Data(41,power_outs[7].status.power_W);
VOFA_Set_JustFloat_Data(42,power_outs[7].status.energy_J);
VOFA_Set_JustFloat_Data(43,power_outs[7].status.quantity_C);
VOFA_Set_JustFloat_Data(44,ina226[0].result.power_W);
VOFA_Set_JustFloat_Data(45,ina226[0].result.energy_J);
VOFA_Set_JustFloat_Data(46,ina226[0].result.quantity_C);
VOFA_Set_JustFloat_Data(47,ina226[1].result.power_W);
VOFA_Set_JustFloat_Data(48,ina226[1].result.energy_J);
VOFA_Set_JustFloat_Data(49,ina226[1].result.quantity_C);
float protect_status = Power_Vot_Protect_Send_Parser();
VOFA_Set_JustFloat_Data(50,protect_status);
VOFA_Set_JustFloat_Data(51,vofa_last_data);
VOFA_Send_Datas(52);
}

View File

@@ -26,10 +26,12 @@ void Power_Out_Single_Init(Power_Out_t *power_out, int16 vot_channel, int16 amp_
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];
power_out->config.ampK[1] = ampK[1];
memcpy(&power_out->config.votK, votK, sizeof(votK));
memcpy(&power_out->config.ampK, ampK, sizeof(ampK));
power_out->config.protect_trigger_cycles = 5;
float vot_protect_k[2] = VOT_PROTECT_K;
memcpy(&power_out->config.vot_protect_k, vot_protect_k, sizeof(vot_protect_k));
power_out->config.amp_protect_k = AMP_PROTECT_K;
power_out->config.enable_pin = enable_pin;
power_out->config.can_adjust = can_adjust;
power_out->config.vot_pwm_channel = vot_pwm_channel;
@@ -39,6 +41,8 @@ void Power_Out_Single_Init(Power_Out_t *power_out, int16 vot_channel, int16 amp_
power_out->status.power_W = 0.0f;
power_out->status.energy_J = 0.0f;
power_out->status.quantity_C = 0.0f;
power_out->status.voltage_protect_triggered = 0;
power_out->status.current_protect_triggered = 0;
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));
@@ -75,6 +79,7 @@ void Power_Out_Init()
{
uint8 can_adjust = vot_pwm_channel_list[counter] != -1 ? 1 : 0;
Power_Out_Single_Init(&power_outs[counter], vot_channel_list[counter], amp_channel_list[counter], votK[counter], ampK[counter], enable_pin_list[counter], can_adjust, vot_pwm_channel_list[counter]);
}
}
@@ -87,6 +92,13 @@ void Power_Out_Enable(Power_Out_t *power_out, uint8 enable)
power_out->enabled = enable;
}
void Power_Out_Clear_Error_Status(Power_Out_t *power_out)
{
power_out->status.voltage_protect_triggered = 0;
power_out->status.current_protect_triggered = 0;
power_out->status.power_protect_triggered = 0;
}
void Power_Out_Set_PWM(Power_Out_t *power_out, uint32 duty_cycle)
{
if(power_out->config.can_adjust && power_out->config.vot_pwm_channel != POWER_OUT_FUNCTION_DISABLE)
@@ -123,6 +135,42 @@ void Power_Out_Single_Read(Power_Out_t *power_out)
}
power_out->status.power_W = power_out->status.voltage_V * power_out->status.current_A;
if(power_out->enabled)
{
if(power_out->status.voltage_V < power_out->config.vot_protect_k[0] * power_out->set_voltage_V || power_out->status.voltage_V > power_out->config.vot_protect_k[1] * power_out->set_voltage_V)
{
power_out->status.voltage_protect_triggered++;
}
else
{
power_out->status.voltage_protect_triggered = 0;
}
if(power_out->status.current_A > power_out->config.amp_protect_k * power_out->set_current_A)
{
power_out->status.current_protect_triggered++;
}
else
{
power_out->status.current_protect_triggered = 0;
}
if(power_out->status.power_W > power_out->max_power_W)
{
power_out->status.power_protect_triggered++;
}
else
{
power_out->status.power_protect_triggered = 0;
}
if(power_out->status.voltage_protect_triggered >= power_out->config.protect_trigger_cycles || power_out->status.current_protect_triggered >= power_out->config.protect_trigger_cycles || power_out->status.power_protect_triggered >= power_out->config.protect_trigger_cycles)
{
Power_Out_Enable(power_out, 0);
}
}
uint8 counter;
for(counter = 0; counter < 9; counter++)
{

View File

@@ -31,11 +31,11 @@
#define VOT_ADJUST_MIN 3.0f
#define AMP_ADJUST_MAX 15.0f
#define VOT_ADJUST_DEF 5.0f
#define AMP_ADJUST_DEF 1.0f
#define VOT_ADJUST_DEF 20.0f
#define AMP_ADJUST_DEF 15.0f
#define POW_ADJUST_DEF 300.0f
#define VOT_PROTECT_K {0.9f,1.1f} // <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>
#define VOT_PROTECT_K {0.0f,10.0f} // <20><>ѹ<EFBFBD><D1B9><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>
#define AMP_PROTECT_K 1.1f // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5>
typedef struct
@@ -47,6 +47,9 @@ typedef struct
float quantity_C;
float past_voltage_V[10];
float past_current_A[10];
uint16 voltage_protect_triggered;
uint16 current_protect_triggered;
uint16 power_protect_triggered;
} Power_Out_Status_t;
typedef struct
@@ -55,6 +58,9 @@ typedef struct
int16 current_read_channel;
float votK[2]; // <20><>ѹУ׼ϵ<D7BC><CFB5>
float ampK[2]; // <20><><EFBFBD><EFBFBD>У׼ϵ<D7BC><CFB5>
float vot_protect_k[2];
float amp_protect_k;
uint16 protect_trigger_cycles;
low_pass_filter_t vot_filter;
low_pass_filter_t amp_filter;
low_pass_filter_t vot_adc_filter;

View File

@@ -13,12 +13,12 @@
#define VOFA_CLIENT_COM_INTERFACE (0) // 0:<3A><><EFBFBD><EFBFBD> 1:WIFI<46><49><EFBFBD><EFBFBD>SPI 2:<3A>Զ<EFBFBD><D4B6><EFBFBD>
#define VOFA_RECEIVE_CH (64) // <20><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD>256<35><36>ͨ<EFBFBD><CDA8>
#define VOFA_SEND_CH (32) // <20><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
#define VOFA_SEND_CH (64) // <20><><EFBFBD><EFBFBD>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>
#if VOFA_CLIENT_COM_INTERFACE == 0
#define VOFA_CLIENT_UART_PORT UART_0 // <20><><EFBFBD>ں<EFBFBD>
#define VOFA_CLIENT_UART_BAUDRATE 115200 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define VOFA_CLIENT_UART_BAUDRATE 1152000 // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define VOFA_CLIENT_UART_RX UART0_RX_P14_1 // <20><><EFBFBD>ڽ<EFBFBD><DABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define VOFA_CLIENT_UART_TX UART0_TX_P14_0 // <20><><EFBFBD>ڷ<EFBFBD><DAB7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>