From 0df7ea6350fa7429ea07b9f7d757756b471c3005 Mon Sep 17 00:00:00 2001 From: sunbeam0529 Date: Tue, 8 Jul 2025 14:49:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=BE=93=E5=87=BA=E7=94=B5?= =?UTF-8?q?=E5=B9=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app_code/main.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app_code/main.c b/app_code/main.c index 0528952..da5ea52 100644 --- a/app_code/main.c +++ b/app_code/main.c @@ -19,8 +19,8 @@ typedef enum #define IAP_ADDRESS 0x0000 -#define LED_ON P16 = 1 -#define LED_OFF P16 = 0 +#define LED_ON P16 = 0 +#define LED_OFF P16 = 1 #define WT_30M 0x80 #define WT_24M 0x81 @@ -187,7 +187,7 @@ float xdata CurrentError = 0; float xdata AdjVoltage = 0; // 调节电压 float xdata CompensationValue = 0; // 补偿系数 float xdata OutGain = 0; // 输出增益调节 - +float xdata LoadRes = 0; // new OUTSTATE_t xdata OutPutState; unsigned int xdata InitTimeCnt,ErrTimeCnt; @@ -376,6 +376,7 @@ void OutPutCtrl(void) { OutCurrent = 0; } + LoadRes = (float)OutVoltage / (OutCurrent/100); if (OutCurrent > TargetCurrent + 10) { if (OutputVol > 100) @@ -399,10 +400,10 @@ void OutPutCtrl(void) { LED_OFF; } - if (OutCurrent > 30000) + if (OutCurrent > 10000) { ErrTimeCnt++; - if (ErrTimeCnt > 50)//500ms + if (ErrTimeCnt > 10)//100ms { OutPutState = OUT_ERR; } @@ -1622,8 +1623,8 @@ void UartSendData(void) SendBuffer[0] = 0x55; SendBuffer[1] = 0xAA; - SendBuffer[2] = RunTime >> 8; // 运行时间H - SendBuffer[3] = RunTime; // 运行时间L + SendBuffer[2] = (unsigned int)LoadRes >> 8; // 运行时间H + SendBuffer[3] = (unsigned int)LoadRes; // 运行时间L SendBuffer[4] = InitError >> 8; // 输入电压H SendBuffer[5] = InitError; // 输入电压L SendBuffer[6] = OutVoltage >> 8; // 输出电压H