2 Commits

7 changed files with 330 additions and 258 deletions
-166
View File
@@ -1,166 +0,0 @@
$PACKAGES
BUZ-TH_BD12.0-P7.60-D0.6-FD ! BUZ-TH_BD12.0-P7.60-D0.6-FD ! '2.7kHz' ; BUZZER
C0603 ! C0603 ! 100nF ; C1 C5 C9 C11 C14 C16 C17 C20 C22 C24 C29 C30 C31 C35 ,
C37 C38 C40 C43 C44 C45 C47 C48 C49 C52
C0603 ! C0603 ! 100pF ; C27 C28 C33 C34 C41 C42 C50 C51
C0603 ! C0603 ! 10uF ; C13 C15 C19 C21 C23 C25 C32 C36 C39 C46
C0603 ! C0603 ! 47pF ; C2
C0805 ! C0805 ! 100nF ; C8
C0805 ! C0805 ! 22uF ; C4 C10 C12 C18
C1206 ! C1206 ! '2.2uF' ; C7
CAP-TH_BD8.0-P3.50-D0.6-FD ! CAP-TH_BD8.0-P3.50-D0.6-FD ! 470uF ; C3
CAP-TH_BD8.0-P3.50-D0.6-FD ! CAP-TH_BD8.0-P3.50-D0.6-FD ! 47uF ; C6
,
CONN-TH_4P-P1.25_HCTL_HC-1.25-4A ! CONN-TH_4P-P1.25_HCTL_HC-1.25-4A ! '{Value}' ,
; LED
,
CONN-TH_5P-P1.25_HCTL_HC-1.25-5A ! CONN-TH_5P-P1.25_HCTL_HC-1.25-5A ! '{Value}' ,
; CN1 CN2
,
CONN-TH_5P-P1.25_HCTL_HC-1.25-5AW ! CONN-TH_5P-P1.25_HCTL_HC-1.25-5AW ! '{Value}' ,
; CN4 CN5 CN6 CN7
,
CONN-TH_7P-P1.25_HCTL_HC-1.25-7A ! CONN-TH_7P-P1.25_HCTL_HC-1.25-7A ! '{Value}' ,
; DEBUG
HDR-TH_2P-P2.54-V-M ! HDR-TH_2P-P2.54-V-M ! '{Value}' ; H1 H4
HDR-TH_6P-P2.54-V-M ! HDR-TH_6P-P2.54-V-M ! '{Value}' ; H2 H3
IND-SMD_L7.1-W6.6 ! IND-SMD_L7.1-W6.6 ! 47uH ; L1
LED0603-RD ! LED0603-RD ! '{Value}' ; GREEN RED
,
LQFP-48_L7.0-W7.0-P0.50-LS9.0-BL ! LQFP-48_L7.0-W7.0-P0.50-LS9.0-BL ! '{Value}' ,
; U6
M3 ! M3 ! '{Value}' ; U8 U9 U10 U11
R0603 ! R0603 ! '1.5kΩ' ; R20 R22
R0603 ! R0603 ! '100Ω' ; R12 R13 R16 R17 R18 R19 R27 R28
R0603 ! R0603 ! '10kΩ' ; R10 R14 R29
R0603 ! R0603 ! '1kΩ' ; R9 R23 R26
R0603 ! R0603 ! '2.2kΩ' ; R3 R4 R21 R24
R0603 ! R0603 ! '20kΩ' ; R6
R0603 ! R0603 ! '22Ω' ; R1
R0603 ! R0603 ! '300kΩ' ; R2
R0603 ! R0603 ! '30mΩ' ; R5
R0603 ! R0603 ! '4.7kΩ' ; R15
R0603 ! R0603 ! '510Ω' ; R7 R8
R0805 ! R0805 ! '0Ω' ; R11
RJ45-TH_RJ48-56-10P10C_MZ ! RJ45-TH_RJ48-56-10P10C_MZ ! '{Value}' ; RJ1 RJ2
SMA_L4.3-W2.6-LS5.0-FD ! SMA_L4.3-W2.6-LS5.0-FD ! '{Value}' ; D1
SMA_L4.3-W2.6-LS5.2-RD ! SMA_L4.3-W2.6-LS5.2-RD ! '{Value}' ; D3 D5
SMA_L4.4-W2.6-LS5.0-BI ! SMA_L4.4-W2.6-LS5.0-BI ! '{Value}' ; D4
SOD-123FL_L2.7-W1.8-LS3.8-RD ! SOD-123FL_L2.7-W1.8-LS3.8-RD ! '{Value}' ; D2
SOD-323_L1.8-W1.3-LS2.5-RD ! SOD-323_L1.8-W1.3-LS2.5-RD ! '{Value}' ; D6
,
SOIC-8_L4.9-W3.9-P1.27-LS6.0-BL-EP ! SOIC-8_L4.9-W3.9-P1.27-LS6.0-BL-EP ! '{Value}' ,
; U1
SOIC-8_L5.0-W4.0-P1.27-LS6.0-BL ! SOIC-8_L5.0-W4.0-P1.27-LS6.0-BL ! '{Value}' ,
; U4 U7 U12 U13
,
SOT-23-3_L2.9-W1.3-P1.90-LS2.4-BR ! SOT-23-3_L2.9-W1.3-P1.90-LS2.4-BR ! '{Value}' ,
; Q2 Q3 Q4
SOT-89_L4.5-W2.5-P1.50-LS4.2-BR ! SOT-89_L4.5-W2.5-P1.50-LS4.2-BR ! '{Value}' ,
; U2 U3
,
SOT-89-3_L4.5-W2.5-P1.50-LS4.2-BR ! SOT-89-3_L4.5-W2.5-P1.50-LS4.2-BR ! '{Value}' ,
; Q1
Test-Point-0.5mm ! Test-Point-0.5mm ! '{Value}' ; 12.8V
,
TSSOP-20_L6.5-W4.4-P0.65-LS6.4-BL ! TSSOP-20_L6.5-W4.4-P0.65-LS6.4-BL ! '{Value}' ,
; U5
$A_PROPERTIES
$NETS
'+5V' ; RJ1.P6 RJ2.P6
'$1N110513' ; C1.2 R1.1
'$1N110514' ; C1.1 D1.2 L1.1 U1.1
'$1N110520' ; R1.2 U1.8
'$1N110523' ; C2.1 R2.1 R6.2 U1.5
'$1N116128' ; R15.1 U6.44
'$1N116244' ; C43.2 U6.22
'$1N125934' ; H3.6 U6.38
'$1N125936' ; H3.5 U6.39
'$1N125938' ; H3.4 U6.40
'$1N125940' ; H3.3 U6.41
'$1N125942' ; H3.2 U6.42
'$1N125944' ; H3.1 U6.43
'$1N126001' ; H2.2 U6.2
'$1N126003' ; H2.3 U6.3
'$1N126005' ; H2.4 U6.4
'$1N126007' ; H2.5 U6.5
'$1N126009' ; H2.6 U6.6
'$1N140888' ; CN6.2 R18.1
'$1N170439' ; BUZZER.2 D6.2 Q2.3
'$1N170441' ; Q2.1 R9.2 R10.2
'$1N170456' ; LED.4 R8.1 RED.2
'$1N170459' ; GREEN.2 LED.1 R7.1
'$1N170464' ; CN4.3 R16.1
'$1N170465' ; CN4.2 R12.1
'$1N170478' ; R14.1 U5.10
'$1N96636' ; CN5.3 R17.1
'$1N96637' ; CN5.2 R13.1
'$1N96922' ; CN6.3 R27.1
'$1N97208' ; CN7.3 R28.1
'$1N97209' ; CN7.2 R19.1
'AVCC_5V' ; C9.2 C10.2 C21.2 C22.1 C24.1 C25.1 C32.2 C35.1 C39.2 C40.1 C46.2 ,
C47.1 CN4.1 CN5.1 CN6.1 CN7.1 U2.2 U4.1 U4.7 U5.19 U7.1 U7.7 U12.1 ,
U12.7 U13.1 U13.7
'I2C_INT1' ; CN1.4 U6.10
'I2C_INT2' ; CN2.4 U6.11
'I2C_SCL' ; CN1.2 CN2.2 R4.1 U6.12
'I2C_SDA' ; CN1.3 CN2.3 R3.1 U6.13
'IO_BIT0' ; Q3.2 R20.1 R23.2 U6.25
'IO_BIT1' ; Q4.2 R22.1 R26.2 U6.26
'IO_DOUT1' ; U5.1 U6.21
'IO_DOUT2' ; U5.4 U6.19
'IO_DOUT3' ; U5.9 U6.14
'IO_DOUT4' ; U5.7 U6.16
'IO_SCLK1' ; U5.3 U6.20
'IO_SCLK2' ; U5.5 U6.18
'IO_SCLK3' ; U5.8 U6.15
'IO_SCLK4' ; U5.6 U6.17
'RJ45-RX' ; H2.1 RJ1.P3 RJ2.P3 U6.1
'RJ45-TX' ; RJ1.P5 RJ2.P5
'UART1_RXD' ; DEBUG.6 U6.32
'UART1_TXD' ; DEBUG.5 U6.33
'VCC_12V8' ; 12.8V.1 C2.2 C3.1 C4.2 C5.2 C13.2 C14.2 C15.2 C16.2 C19.2 C20.2 ,
D2.1 L1.2 Q1.3 R2.2 U2.3 U3.3
'VCC_3V3' ; C17.2 C18.2 C23.1 C29.2 C36.1 C37.2 C38.2 C49.2 C52.2 CN1.1 CN2.1 ,
DEBUG.7 Q1.2 Q3.1 Q4.1 R3.2 R4.2 R7.2 R8.2 R14.2 R15.2 R20.2 R22.2 ,
R29.1 U5.2 U6.9 U6.24 U6.36 U6.48
'VCC_5V' ; BUZZER.1 C11.2 C12.2 D6.1 R21.2 R24.2 U3.2
AGND ; C9.1 C10.1 C21.1 C22.2 C24.2 C25.2 C27.1 C28.1 C32.1 C33.2 C34.2 C35.2 ,
C39.1 C40.2 C41.1 C42.1 C46.1 C47.2 C50.2 C51.2 CN4.4 CN4.5 CN5.4 ,
CN5.5 CN6.4 CN6.5 CN7.4 CN7.5 R11.2 U4.2 U7.2 U12.2 U13.2
AINN1 ; C27.2 C30.1 R12.2 U4.3
AINN2 ; C28.2 C31.1 R13.2 U7.3
AINN3 ; C41.2 C44.1 R18.2 U12.3
AINN4 ; C42.2 C45.1 R19.2 U13.3
AINP1 ; C30.2 C33.1 R16.2 U4.4
AINP2 ; C31.2 C34.1 R17.2 U7.4
AINP3 ; C44.2 C50.1 R27.2 U12.4
AINP4 ; C45.2 C51.1 R28.2 U13.4
BIT0 ; H4.1 Q3.3 R21.1 RJ1.P8 RJ2.P8
BIT1 ; H4.2 Q4.3 R24.1 RJ1.P9 RJ2.P9
BIT2 ; RJ1.P7 RJ2.P7
BIT3 ; RJ1.P2 RJ2.P2
BUZZ ; R9.1 U6.28
DOUT1 ; U4.6 U5.20
DOUT2 ; U5.17 U7.6
DOUT3 ; U5.12 U12.6
DOUT4 ; U5.14 U13.6
GND ; C3.2 C4.1 C5.1 C6.2 C7.1 C8.1 C11.1 C12.1 C13.1 C14.1 C15.1 C16.1 C17.1 ,
C18.1 C19.1 C20.1 C23.2 C29.1 C36.2 C37.1 C38.1 C43.1 C48.1 C49.1 ,
C52.1 CN1.5 CN2.5 D1.1 D2.2 D4.1 DEBUG.1 H1.2 Q1.1 Q2.2 R6.1 R10.1 ,
R11.1 R23.1 R26.1 RJ1.P4 RJ1.P10 RJ2.P4 RJ2.P10 U1.4 U2.1 U3.1 U5.11 ,
U6.8 U6.23 U6.35 U6.47 U8.1 U9.1 U10.1 U11.1
GREEN ; GREEN.1 LED.2 U6.30
ILIM ; R5.2 U1.2 U1.9
NRST ; C48.2 DEBUG.2 H1.1 R29.2 U6.7
POWER ; C6.1 C7.2 C8.2 D3.1 D5.1 R5.1 U1.3
RED ; LED.3 RED.1 U6.29
SCLK1 ; U4.5 U5.18
SCLK2 ; U5.16 U7.5
SCLK3 ; U5.13 U12.5
SCLK4 ; U5.15 U13.5
SWCLK ; DEBUG.3 U6.37
SWDIO ; DEBUG.4 U6.34
VIN ; D3.2 D4.2 D5.2 RJ1.P1 RJ2.P1
$SCHEDULE
$END
+8 -28
View File
@@ -145,7 +145,7 @@
<SetRegEntry>
<Number>0</Number>
<Key>CMSIS_AGDI</Key>
<Name>-X"Any" -UAny -O206 -S0 -C0 -P00000000 -N00("") -D00(00000000) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO15 -FD1FFF8000 -FC1000 -FN2 -FF0HC32F460_512K.FLM -FS00 -FL080000 -FP0($$Device:HC32F460JETA$FlashARM\HC32F460_512K.FLM) -FF1HC32F460_otp.FLM -FS13000C00 -FL13FC -FP1($$Device:HC32F460JETA$FlashARM\HC32F460_otp.FLM)</Name>
<Name>-X"Any" -UAny -O206 -S9 -C0 -P00000000 -N00("ARM CoreSight SW-DP") -D00(2BA01477) -L00(0) -TO65554 -TC10000000 -TT10000000 -TP20 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO31 -FD1FFF8000 -FC1000 -FN2 -FF0HC32F460_512K.FLM -FS00 -FL080000 -FP0($$Device:HC32F460JETA$FlashARM\HC32F460_512K.FLM) -FF1HC32F460_otp.FLM -FS13000C00 -FL13FC -FP1($$Device:HC32F460JETA$FlashARM\HC32F460_otp.FLM)</Name>
</SetRegEntry>
<SetRegEntry>
<Number>0</Number>
@@ -263,50 +263,30 @@
<Ww>
<count>21</count>
<WinNumber>1</WinNumber>
<ItemText>App.aaa,0x0A</ItemText>
<ItemText>App.ADTrack.LeftUpVPT,0x0A</ItemText>
</Ww>
<Ww>
<count>22</count>
<WinNumber>1</WinNumber>
<ItemText>App.bbb,0x0A</ItemText>
<ItemText>App.ADTrack.LeftLowVPT,0x0A</ItemText>
</Ww>
<Ww>
<count>23</count>
<WinNumber>1</WinNumber>
<ItemText>App.ccc,0x0A</ItemText>
<ItemText>App.ADTrack.RightUpVPT,0x0A</ItemText>
</Ww>
<Ww>
<count>24</count>
<WinNumber>1</WinNumber>
<ItemText>App.ddd,0x0A</ItemText>
<ItemText>App.ADTrack.RightLowVPT,0x0A</ItemText>
</Ww>
<Ww>
<count>25</count>
<WinNumber>1</WinNumber>
<ItemText>App.ADTrack.LeftUpVPT,0x0A</ItemText>
</Ww>
<Ww>
<count>26</count>
<WinNumber>1</WinNumber>
<ItemText>App.ADTrack.LeftLowVPT,0x0A</ItemText>
</Ww>
<Ww>
<count>27</count>
<WinNumber>1</WinNumber>
<ItemText>App.ADTrack.RightUpVPT,0x0A</ItemText>
</Ww>
<Ww>
<count>28</count>
<WinNumber>1</WinNumber>
<ItemText>App.ADTrack.RightLowVPT,0x0A</ItemText>
</Ww>
<Ww>
<count>29</count>
<WinNumber>1</WinNumber>
<ItemText>App.ADTrack.Stop_VPT,0x0A</ItemText>
</Ww>
<Ww>
<count>30</count>
<count>26</count>
<WinNumber>1</WinNumber>
<ItemText>App.MotorPara.Current_height,0x0A</ItemText>
</Ww>
@@ -389,7 +369,7 @@
<DebugFlag>
<trace>0</trace>
<periodic>1</periodic>
<aLwin>0</aLwin>
<aLwin>1</aLwin>
<aCover>0</aCover>
<aSer1>0</aSer1>
<aSer2>0</aSer2>
@@ -430,7 +410,7 @@
<EnableFlashSeq>1</EnableFlashSeq>
<EnableLog>0</EnableLog>
<Protocol>2</Protocol>
<DbgClock>1000000</DbgClock>
<DbgClock>5000000</DbgClock>
</DebugDescription>
</TargetOption>
</Target>
+2 -2
View File
@@ -338,7 +338,7 @@
<v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls></MiscControls>
<MiscControls>--multibyte_chars</MiscControls>
<Define>__DEBUG,HC32F460,USE_DEVICE_DRIVER_LIB,JEUA</Define>
<Undefine></Undefine>
<IncludePath>..\..\..\mcu\common;..\source\User\Inc;..\source\User\Src;..\..\..\driver\src;..\..\..\driver\inc;..\source\Module\CS1237;..\source\Module\dc_motor;..\source\Module\BeepAndLed</IncludePath>
@@ -1026,7 +1026,7 @@
<v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti>
<VariousControls>
<MiscControls>--diag_suppress=186,66</MiscControls>
<MiscControls>--diag_suppress=186,66 --multibyte_chars</MiscControls>
<Define>HC32F460,USE_DEVICE_DRIVER_LIB</Define>
<Undefine></Undefine>
<IncludePath>..\..\..\..\..\mcu\common;..\source;..\..\..\..\..\driver\inc;..\..\..\..\..\bsp\ev_hc32f460_lqfp100_v2</IncludePath>
+7
View File
@@ -31,6 +31,10 @@ typedef struct{
DebugExec DBGExec;
}DBGFunType;
/* 控制盒信息帧→复位→恢复 观测打印: ISR推事件, 主循环打印完整时间线(未知帧全记录用于捕捉过热报错) */
void Uart3ErrLog_Push(uint8_t type, const uint8_t *pFrame, uint16_t height); /* type:0首次信息帧 1复位中回应 2复位完成 3未知帧 */
void Uart3ErrLogLoopHandler(void); /* 主循环调用: 打印报错/复位事件 */
void DebugUartIRQ(char Data);
void DebugLoopHandler(void);
void Dbg1msRoutine(void);
@@ -41,5 +45,8 @@ void Dbg1msRoutine(void);
#define DBG_LOG_F(fmt,arg...)
#define DBG_ARRAY(ARRAY,SIZE)
#define Uart3ErrLog_Push(type, pFrame, height) (0)
#define Uart3ErrLogLoopHandler() (0)
#endif
#endif
+12 -7
View File
@@ -30,8 +30,11 @@
#define TRAVEL_TIME_MS 50000
#define PEAK 1200 //1200mm
#define VALLEY 720 //720mm
#define PEAK 1430 //最高高度mm
#define VALLEY 1000 //最低高度mm
/*高度转应力表索引: 补偿表431点覆盖1000~1430mm(430个步进), h<1000时钳位到0防止越界*/
#define HEIGHT_TO_IDX(h) ((h) < 1000 ? 0 : ((h) - 1000))
#define BDC_STOP() (SET_TWIN_BIT0(),SET_TWIN_BIT1())
#define BDC_DOWN() (SET_TWIN_BIT0(),CLR_TWIN_BIT1())
@@ -73,14 +76,15 @@ typedef struct{
typedef struct{//电机参数
bool InitialFlag;//初始标志位
bool RestFlag;
bool OverheatFlag;//过热标志: 收到过热帧后置true, 持续下降触发控制盒复位
bool CaliFlag;
bool LoopOne;//循环一次标志位
int16_t Current_height;//当前高度mm
int16_t Current_height;//当前高度mm(控制盒上报1000~1430)
int16_t CaliNum;//标校数量
int32_t LU_HeightStress[488];//左上传感器对应高度应力
int32_t LL_HeightStress[488];//左下传感器对应高度应力
int32_t RU_HeightStress[488];//右上传感器对应高度应力
int32_t RL_HeightStress[488];//右传感器对应高度应力
int32_t LU_HeightStress[431];//左上传感器对应高度应力
int32_t LL_HeightStress[431];//左下传感器对应高度应力
int32_t RU_HeightStress[431];//右上传感器对应高度应力
int32_t RL_HeightStress[431];//右传感器对应高度应力
}MotorPara_t;
/*数据读取状态机*/
typedef enum {
@@ -147,6 +151,7 @@ typedef struct {
uint32_t SlopeCollDelay1mSCnt;
uint32_t CailUp1mSCnt;
uint32_t HeightContRolCnt;
uint32_t RestStop1mSCnt;//复位停顿计时: 收到复位帧后先停止电机, 计时结束再下降触发复位
uint8_t FeedDogDlyCnt;
bool CaliZeroFlag;//校零标志位
+202
View File
@@ -400,6 +400,208 @@ const DBGFunType DebugFun[DEBUG_CMD_CNT] = {
"wave", DBGWave_on_off,
};
/*=========================================================================================
* 函数名称: Uart3ErrLog_xxx
* 功能描述: 控制盒报错(01 04)→复位→恢复 观测打印。接收中断中仅推事件入环形缓冲(不打印),
* 由主循环Uart3ErrLogLoopHandler()统一打印, 完整呈现"触发报错→置复位标志→
* 复位过程多包回应→复位完成恢复正常"的时间线。
* 协议: 01 04 d2 d3 = 报错帧(d2/d3为错误码, 如过热); 01 01 h_hi h_lo = 高度帧(清除复位标志)
*=========================================================================================*/
#define U3ERR_EVT_MAX 16 /* 事件缓冲条数 */
#define U3ERR_STATUS_NUM 12 /* 主状态机状态个数 */
/* 事件类型 */
#define U3ERR_T_FIRST 0 /* 首次信息帧(复位标志 0→1) */
#define U3ERR_T_REPLY 1 /* 复位中回应信息帧(复位标志已置位) */
#define U3ERR_T_DONE 2 /* 复位完成(收到高度帧, 复位标志 1→0) */
#define U3ERR_T_UNKNOWN 3 /* 未知帧(非高度/信息帧, 用于捕捉过热等其它报错) */
typedef struct{
uint8_t Type; /* 事件类型 */
uint8_t Bits; /* BIT0/BIT1 输出电平(bit0/bit1) */
uint8_t Status; /* 事件时刻主状态机状态 */
uint8_t Frame[4]; /* 原始4字节帧 */
uint16_t Height; /* type2: 高度帧数值(mm) */
uint16_t Repeat; /* 连发合并的重复包数(不含首包) */
uint32_t Tick; /* 事件时刻(ms, 上电起) */
}U3ErrEvt_t;
/* 连发合并状态: 相同帧500ms内只计数不重复入队, 防止过热帧持续广播刷爆缓冲 */
static uint8_t m_U3ErrLastType = 0xFF; /* 上一帧类型(0xFF=无) */
static uint8_t m_U3ErrLastFrame[4]; /* 上一帧内容 */
static uint16_t m_U3ErrLastHeight = 0; /* 上一帧高度(type2) */
static uint32_t m_U3ErrLastTick = 0; /* 上一帧时刻 */
static uint16_t m_U3ErrRepeat = 0; /* 上一帧已合并的重复包数 */
static const char *m_U3ErrStatusName[U3ERR_STATUS_NUM] = {
"IDLE", "ON", "OFF", "START_BEEP", "MOTOR_INIT", "ZERO_MARKING",
"WAIT_MOTOR_INIT", "WAIT_MOTOR_CALI_UP", "WAIT_MOTOR_CALI_DOWN",
"WAIT_STEADY", "END_BEEP", "HEIGHT_CONTROL"
};
static U3ErrEvt_t m_U3ErrEvt[U3ERR_EVT_MAX]; /* 事件环形缓冲 */
static volatile uint16_t m_U3ErrWr = 0; /* 写指针(中断) */
static volatile uint16_t m_U3ErrRd = 0; /* 读指针(主循环) */
static volatile uint32_t m_U3ErrLostCnt = 0; /* 缓冲满时丢弃条数 */
/* 函数名称: Uart3ErrLog_Enqueue
* 功能描述: 将事件落入队列(内部使用, 关中断保护) */
static void Uart3ErrLog_Enqueue(uint8_t type, const uint8_t *pFrame, uint16_t height, uint32_t tick, uint16_t repeat)
{
U3ErrEvt_t evt;
evt.Type = type;
evt.Bits = (uint8_t)((GET_BIT0_DOUT() ? 0x01u : 0u) | (GET_BIT1_DOUT() ? 0x02u : 0u));
evt.Status = (uint8_t)App.Status;
evt.Frame[0] = pFrame[0];
evt.Frame[1] = pFrame[1];
evt.Frame[2] = pFrame[2];
evt.Frame[3] = pFrame[3];
evt.Height = height;
evt.Repeat = repeat;
evt.Tick = tick;
uint32_t primask = __get_PRIMASK();
__disable_irq();
uint16_t next = (uint16_t)((m_U3ErrWr + 1U) % U3ERR_EVT_MAX);
if(next != m_U3ErrRd){ /* 未满则入队 */
m_U3ErrEvt[m_U3ErrWr] = evt;
m_U3ErrWr = next;
}
else{ /* 满则丢弃当前条并计数 */
m_U3ErrLostCnt++;
}
if(primask == 0U){
__enable_irq();
}
}
/* 函数名称: Uart3ErrLog_Push
* 功能描述: 记录一条报错/复位事件(在USART3接收中断中调用)。相同帧500ms内连发只合并计数,
* 由主循环在连发结束(超时)或出现新帧时落一条带"连发N包"的事件, 避免缓冲溢出 */
void Uart3ErrLog_Push(uint8_t type, const uint8_t *pFrame, uint16_t height)
{
uint32_t tick = SysTick_GetTick();
/* 连发合并: 与上一帧类型/内容相同且间隔<500ms(type2复位完成除外), 只计数 */
if((m_U3ErrLastType != 0xFF) && (type == m_U3ErrLastType) && (type != U3ERR_T_DONE) &&
(pFrame[0] == m_U3ErrLastFrame[0]) && (pFrame[1] == m_U3ErrLastFrame[1]) &&
(pFrame[2] == m_U3ErrLastFrame[2]) && (pFrame[3] == m_U3ErrLastFrame[3]) &&
((tick - m_U3ErrLastTick) < 500U))
{
m_U3ErrRepeat++;
m_U3ErrLastTick = tick;
return;
}
/* 与上一帧不同: 先把滞留的上一帧连同连发计数落队 */
if(m_U3ErrLastType != 0xFF){
Uart3ErrLog_Enqueue(m_U3ErrLastType, m_U3ErrLastFrame, m_U3ErrLastHeight, m_U3ErrLastTick, m_U3ErrRepeat);
m_U3ErrRepeat = 0;
}
/* 本帧记为新的滞留帧, 待其连发结束或下一帧到来时落队 */
m_U3ErrLastType = type;
m_U3ErrLastFrame[0] = pFrame[0];
m_U3ErrLastFrame[1] = pFrame[1];
m_U3ErrLastFrame[2] = pFrame[2];
m_U3ErrLastFrame[3] = pFrame[3];
m_U3ErrLastHeight = height;
m_U3ErrLastTick = tick;
}
/* 函数名称: Uart3ErrLog_BitsName
* 功能描述: BIT0/BIT1输出电平转"升/降/停"描述(ASCII, 避免AC5源码集问题) */
static const char *Uart3ErrLog_BitsName(uint8_t bits)
{
if((bits & 0x01u) && (bits & 0x02u)) return "STOP";
if(bits & 0x02u) return "UP";
if(bits & 0x01u) return "DOWN";
return "?";
}
/* 函数名称: Uart3ErrLog_CodeName
* 功能描述: 已知帧内容转义(发现新帧格式后在此扩充) */
static const char *Uart3ErrLog_CodeName(const uint8_t *pFrame)
{
if(pFrame[0] == 0x01 && pFrame[1] == 0x02 && pFrame[2] == 0x00 && pFrame[3] == 0x10) return "(OVERHEAT)";
if(pFrame[2] == 0x01 && pFrame[3] == 0xAA) return "(RESET)";
return "";
}
/* 函数名称: Uart3ErrLog_StatusName
* 功能描述: 主状态机状态值转可读名 */
static const char *Uart3ErrLog_StatusName(uint8_t status)
{
if(status < U3ERR_STATUS_NUM){
return m_U3ErrStatusName[status];
}
return "?";
}
/* 函数名称: Uart3ErrLogLoopHandler
* 功能描述: 主循环中调用, 打印报错→复位→恢复的完整事件时间线(连发帧合并为一条并显示包数) */
void Uart3ErrLogLoopHandler(void)
{
uint8_t cnt;
/* 连发已结束(超时500ms无同帧)且有滞留帧 → 先落队一条 */
if((m_U3ErrLastType != 0xFF) && (m_U3ErrRepeat > 0U) &&
((SysTick_GetTick() - m_U3ErrLastTick) >= 500U))
{
Uart3ErrLog_Enqueue(m_U3ErrLastType, m_U3ErrLastFrame, m_U3ErrLastHeight, m_U3ErrLastTick, m_U3ErrRepeat);
m_U3ErrLastType = 0xFF;
m_U3ErrRepeat = 0;
}
for(cnt = 0; cnt < 8U; cnt++){
char rep[20];
if(m_U3ErrRd == m_U3ErrWr){
break;
}
U3ErrEvt_t evt = m_U3ErrEvt[m_U3ErrRd];
m_U3ErrRd = (uint16_t)((m_U3ErrRd + 1U) % U3ERR_EVT_MAX);
uint32_t s = evt.Tick / 1000U;
uint32_t ms = evt.Tick % 1000U;
if(evt.Repeat > 0U){
sprintf(rep, ",burst %u", evt.Repeat + 1U);
}
else{
rep[0] = '\0';
}
switch(evt.Type){
case U3ERR_T_FIRST: /* 首次信息帧: 置复位标志 */
DBG_LOG("[T+%3u.%03us][%s|OUT:%s] INFO: code=0x%02X%02X%s -> SetRestFlag%s\r\n",
s, ms, Uart3ErrLog_StatusName(evt.Status),
Uart3ErrLog_BitsName(evt.Bits),
evt.Frame[2], evt.Frame[3],
Uart3ErrLog_CodeName(evt.Frame), rep);
break;
case U3ERR_T_REPLY: /* 复位中回应信息帧 */
DBG_LOG("[T+%3u.%03us][%s|OUT:%s] INFO-REPLY: code=0x%02X%02X%s (RestFlag set%s)\r\n",
s, ms, Uart3ErrLog_StatusName(evt.Status),
Uart3ErrLog_BitsName(evt.Bits),
evt.Frame[2], evt.Frame[3],
Uart3ErrLog_CodeName(evt.Frame), rep);
break;
case U3ERR_T_DONE: /* 复位完成: 收到高度帧 */
DBG_LOG("[T+%3u.%03us][%s|OUT:%s] Height=%dmm -> RestFlag cleared, normal\r\n",
s, ms, Uart3ErrLog_StatusName(evt.Status),
Uart3ErrLog_BitsName(evt.Bits), evt.Height);
break;
case U3ERR_T_UNKNOWN: /* 未知帧: 过热等其它报错可能在此 */
DBG_LOG("[T+%3u.%03us][%s|OUT:%s] UNKNOWN: %02X %02X %02X %02X %s(ATTENTION)%s\r\n",
s, ms, Uart3ErrLog_StatusName(evt.Status),
Uart3ErrLog_BitsName(evt.Bits),
evt.Frame[0], evt.Frame[1], evt.Frame[2], evt.Frame[3],
Uart3ErrLog_CodeName(evt.Frame), rep);
break;
default:
break;
}
}
if((m_U3ErrRd == m_U3ErrWr) && (m_U3ErrLostCnt > 0U)){ /* 缓冲曾溢出 */
uint32_t tick = SysTick_GetTick();
DBG_LOG("[T+%3u.%03us] NOTE: ErrLog buf overflow, lost %u events\r\n",
tick / 1000U, tick % 1000U, m_U3ErrLostCnt);
m_U3ErrLostCnt = 0;
}
}
#endif
+93 -49
View File
@@ -43,7 +43,7 @@ void LEFTUP_CS1237AinADataProcessCallBack(int32_t AD)
// }
if(App.MotorPara.CaliFlag == true)
{
AD = AD + App.MotorPara.LU_HeightStress[(App.MotorPara.Current_height)-725];
AD = AD + App.MotorPara.LU_HeightStress[HEIGHT_TO_IDX(App.MotorPara.Current_height)];
for(int i = OSC_CNT-1; i > 0; i--)
{
App.LeftUpCS1237_TrendArray[i] = App.LeftUpCS1237_TrendArray[i - 1];
@@ -68,7 +68,7 @@ void LEFTLOW_CS1237AinADataProcessCallBack(int32_t AD)
// }
if(App.MotorPara.CaliFlag == true)
{
AD = AD + App.MotorPara.LL_HeightStress[(App.MotorPara.Current_height)-725];
AD = AD + App.MotorPara.LL_HeightStress[HEIGHT_TO_IDX(App.MotorPara.Current_height)];
for(int i = OSC_CNT-1; i > 0; i--)
{
App.LeftLowCS1237_TrendArray[i] = App.LeftLowCS1237_TrendArray[i - 1];
@@ -94,7 +94,7 @@ void RIGHTUP_CS1237AinADataProcessCallBack(int32_t AD)
// }
if(App.MotorPara.CaliFlag == true)
{
AD = AD + App.MotorPara.RU_HeightStress[(App.MotorPara.Current_height)-725];
AD = AD + App.MotorPara.RU_HeightStress[HEIGHT_TO_IDX(App.MotorPara.Current_height)];
for(int i = OSC_CNT-1; i > 0; i--)
{
App.RightUpCS1237_TrendArray[i] = App.RightUpCS1237_TrendArray[i - 1];
@@ -120,7 +120,7 @@ void RIGHTLOW_CS1237AinADataProcessCallBack(int32_t AD)
// }
if(App.MotorPara.CaliFlag == true)
{
AD = AD + App.MotorPara.RL_HeightStress[(App.MotorPara.Current_height)-725];
AD = AD + App.MotorPara.RL_HeightStress[HEIGHT_TO_IDX(App.MotorPara.Current_height)];
for(int i = OSC_CNT-1; i > 0; i--)
{
App.RightLowCS1237_TrendArray[i] = App.RightLowCS1237_TrendArray[i - 1];
@@ -331,7 +331,7 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
{
// if(App.CaliZeroFlag == true)//判断是否校零
{
if(App.MotorPara.Current_height < 1195)
if(App.MotorPara.Current_height < 1425)
{
BDC_UP();
App.CaliZeroFlag = false;
@@ -353,7 +353,7 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
{
// if(App.CaliZeroFlag == true)//判断是否校零
{
if(App.MotorPara.Current_height > 725)
if(App.MotorPara.Current_height > 1005)
{
BDC_DOWN();
App.CaliZeroFlag = false;
@@ -379,7 +379,7 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
{
// if(App.CaliZeroFlag == true)//判断是否校零
{
if(App.MotorPara.Current_height < 1195)
if(App.MotorPara.Current_height < 1425)
{
BDC_UP();
App.CaliZeroFlag = false;
@@ -401,7 +401,7 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
{
// if(App.CaliZeroFlag == true)//判断是否校零
{
if(App.MotorPara.Current_height > 725)
if(App.MotorPara.Current_height > 1005)
{
BDC_DOWN();
App.CaliZeroFlag = false;
@@ -443,7 +443,7 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
&& (abs(Oll_diff3) > abs(Orl_diff3) * SHIELD_VPT)
)
{
if(App.MotorPara.Current_height < 1195)
if(App.MotorPara.Current_height < 1425)
{
BDC_UP();
App.CaliZeroFlag = false;
@@ -483,7 +483,7 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
&& (abs(Oll_diff3) > abs(Orl_diff3) * SHIELD_VPT)
)
{
if(App.MotorPara.Current_height > 725)
if(App.MotorPara.Current_height > 1005)
{
BDC_DOWN();
App.CaliZeroFlag = false;
@@ -526,7 +526,7 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
&& (abs(Orl_diff3) > abs(Oll_diff3) * SHIELD_VPT)
)
{
if(App.MotorPara.Current_height < 1195)
if(App.MotorPara.Current_height < 1425)
{
BDC_UP();
App.CaliZeroFlag = false;
@@ -565,7 +565,7 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
&& (abs(Orl_diff3) > abs(Oll_diff3) * SHIELD_VPT)
)
{
if(App.MotorPara.Current_height > 725)
if(App.MotorPara.Current_height > 1005)
{
BDC_DOWN();
App.CaliZeroFlag = false;
@@ -602,8 +602,8 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
&& ((Olu_diff1 + Oru_diff1) > -(App.ADTrack.Stop_VPT*2/3))
&& ((Olu_diff2 + Oru_diff2) > -(App.ADTrack.Stop_VPT*2/3))
&& ((Olu_diff3 + Oru_diff3) > -(App.ADTrack.Stop_VPT*2/3)))
|| App.MotorPara.Current_height >= 1195
|| App.MotorPara.Current_height <= 725
|| App.MotorPara.Current_height >= 1425
|| App.MotorPara.Current_height <= 1005
)
{
BDC_STOP();
@@ -647,8 +647,8 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
&& ((Olu_diff1 + Oru_diff1) > -(App.ADTrack.Stop_VPT*2/3))
&& ((Olu_diff2 + Oru_diff2) > -(App.ADTrack.Stop_VPT*2/3))
&& ((Olu_diff3 + Oru_diff3) > -(App.ADTrack.Stop_VPT*2/3)))
|| App.MotorPara.Current_height >= 1195
|| App.MotorPara.Current_height <= 725
|| App.MotorPara.Current_height >= 1425
|| App.MotorPara.Current_height <= 1005
)
{
BDC_STOP();
@@ -695,8 +695,8 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
&& ((Olu_diff1 + Oru_diff1) < (App.ADTrack.Stop_VPT*2/3))
&& ((Olu_diff2 + Oru_diff2) < (App.ADTrack.Stop_VPT*2/3))
&& ((Olu_diff3 + Oru_diff3) < (App.ADTrack.Stop_VPT*2/3)))
|| App.MotorPara.Current_height >= 1195
|| App.MotorPara.Current_height <= 725
|| App.MotorPara.Current_height >= 1425
|| App.MotorPara.Current_height <= 1005
)
{
BDC_STOP();
@@ -740,8 +740,8 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
&& ((Olu_diff1 + Oru_diff1) < (App.ADTrack.Stop_VPT*2/3))
&& ((Olu_diff2 + Oru_diff2) < (App.ADTrack.Stop_VPT*2/3))
&& ((Olu_diff3 + Oru_diff3) < (App.ADTrack.Stop_VPT*2/3)))
|| App.MotorPara.Current_height >= 1195
|| App.MotorPara.Current_height <= 725
|| App.MotorPara.Current_height >= 1425
|| App.MotorPara.Current_height <= 1005
)
{
BDC_STOP();
@@ -804,8 +804,8 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
{
if(App.StopFlag == true
&& App.StopCollDelay1mSCnt <= 0
&& App.MotorPara.Current_height <= 1195
&& App.MotorPara.Current_height >= 725){
&& App.MotorPara.Current_height <= 1425
&& App.MotorPara.Current_height >= 1005){
App.ADTrack.LeftUp_Org_AdZero = lu_ad[0];
App.ADTrack.LeftLow_Org_AdZero = ll_ad[0];
App.ADTrack.RightUp_Org_AdZero = ru_ad[0];
@@ -999,7 +999,7 @@ static void AppLoopHandler(void)
App.UpFlag = false;
App.Status = APP_STATUS_IDLE;
}
if(App.MotorPara.Current_height <= 722 && App.MotorPara.Current_height >= 720)
if(App.MotorPara.Current_height <= 1002 && App.MotorPara.Current_height >= 1000)
{
BDC_STOP();
App.StopFlag = true;
@@ -1036,7 +1036,7 @@ static void AppLoopHandler(void)
break;}
case APP_STATUS_WAIT_MOTOR_CALI_UP:{
if(App.MotorPara.Current_height >= 1200 && App.CailUp1mSCnt >= 17000)
if(App.MotorPara.Current_height >= 1430 && App.CailUp1mSCnt >= 17000)
{
App.CailUp1mSCnt = 0;
BDC_STOP();
@@ -1049,7 +1049,7 @@ static void AppLoopHandler(void)
App.Status = APP_STATUS_WAIT_MOTOR_CALI_DOWN;
BDC_DOWN();
}
else if(App.MotorPara.CaliNum >= 480 && App.MotorPara.LoopOne == true)
else if(App.MotorPara.CaliNum >= 410 && App.MotorPara.LoopOne == true)
{
BDC_STOP();
App.StopFlag = true;
@@ -1059,13 +1059,13 @@ static void AppLoopHandler(void)
App.MotorPara.InitialFlag = false;
App.MotorPara.CaliFlag = true;
DBG_LOG("===================LU Data monitoring====================\r\n");
weightedMovingAverageWithEnhance(App.MotorPara.LU_HeightStress,480,7,380,480,4,0);
weightedMovingAverageWithEnhance(App.MotorPara.LU_HeightStress,431,7,341,430,4,0);
DBG_LOG("===================LL Data monitoring====================\r\n");
weightedMovingAverageWithEnhance(App.MotorPara.LL_HeightStress,480,7,380,480,4,0);
weightedMovingAverageWithEnhance(App.MotorPara.LL_HeightStress,431,7,341,430,4,0);
DBG_LOG("===================RU Data monitoring====================\r\n");
weightedMovingAverageWithEnhance(App.MotorPara.RU_HeightStress,480,7,380,480,4,0);
weightedMovingAverageWithEnhance(App.MotorPara.RU_HeightStress,431,7,341,430,4,0);
DBG_LOG("===================RL Data monitoring====================\r\n");
weightedMovingAverageWithEnhance(App.MotorPara.RL_HeightStress,480,7,380,480,4,0);
weightedMovingAverageWithEnhance(App.MotorPara.RL_HeightStress,431,7,341,430,4,0);
DBG_LOG("Motor Cali Ok\r\n");
App.TD1mSDelayCnt = 1000;
App.Status = APP_STATUS_WAIT_STEADY;
@@ -1073,7 +1073,7 @@ static void AppLoopHandler(void)
break;}
case APP_STATUS_WAIT_MOTOR_CALI_DOWN:{
if(App.MotorPara.Current_height <= 725)
if(App.MotorPara.Current_height <= 1005)
{
BDC_STOP();
App.StopFlag = true;
@@ -1087,7 +1087,7 @@ static void AppLoopHandler(void)
BDC_UP();
App.CailUp1mSCnt = 0;
}
else if(App.MotorPara.CaliNum >= 480 && App.MotorPara.LoopOne == true)
else if(App.MotorPara.CaliNum >= 410 && App.MotorPara.LoopOne == true)
{
BDC_STOP();
App.StopFlag = true;
@@ -1097,13 +1097,13 @@ static void AppLoopHandler(void)
App.MotorPara.InitialFlag = false;
App.MotorPara.CaliFlag = true;
DBG_LOG("===================LU Data monitoring====================\r\n");
weightedMovingAverageWithEnhance(App.MotorPara.LU_HeightStress,480,7,380,480,4,0);
weightedMovingAverageWithEnhance(App.MotorPara.LU_HeightStress,431,7,341,430,4,0);
DBG_LOG("===================LL Data monitoring====================\r\n");
weightedMovingAverageWithEnhance(App.MotorPara.LL_HeightStress,480,7,380,480,4,0);
weightedMovingAverageWithEnhance(App.MotorPara.LL_HeightStress,431,7,341,430,4,0);
DBG_LOG("===================RU Data monitoring====================\r\n");
weightedMovingAverageWithEnhance(App.MotorPara.RU_HeightStress,480,7,380,480,4,0);
weightedMovingAverageWithEnhance(App.MotorPara.RU_HeightStress,431,7,341,430,4,0);
DBG_LOG("===================RL Data monitoring====================\r\n");
weightedMovingAverageWithEnhance(App.MotorPara.RL_HeightStress,480,7,380,480,4,0);
weightedMovingAverageWithEnhance(App.MotorPara.RL_HeightStress,431,7,341,430,4,0);
DBG_LOG("Motor Cali Ok\r\n");
App.TD1mSDelayCnt = 1000;
App.Status = APP_STATUS_WAIT_STEADY;
@@ -1132,7 +1132,26 @@ static void AppLoopHandler(void)
break;}
case APP_STATUS_HEIGHT_CONTROL:{
if(App.MotorPara.Current_height <= 725
if(App.MotorPara.OverheatFlag == true)
{
if(App.MotorPara.Current_height <= 1005)
{
BDC_DOWN();//过热+低位: 继续下降触发控制盒复位(SupportControlHandle在<=1005时不执行BDC_DOWN)
}
//过热+高位(>1005): 由SupportControlHandle根据传感器正常判断下降
}
else if(App.MotorPara.RestFlag == true)
{
if(App.RestStop1mSCnt > 0)
{
BDC_STOP();//复位停顿: 先停止电机, 让控制盒进入复位流程
}
else
{
BDC_DOWN();//停顿结束: 再次下降, 触发控制盒完成复位(收到高度帧后RestFlag清除)
}
}
else if(App.MotorPara.Current_height <= 1005
&& App.MotorPara.RestFlag == false
&& App.HeightContRolCnt >= 500
&& GET_BIT0_DOUT() == 1
@@ -1143,7 +1162,7 @@ static void AppLoopHandler(void)
Ddl_Delay1ms(500);
BDC_STOP();
}
else if(App.MotorPara.Current_height >= 1195
else if(App.MotorPara.Current_height >= 1425
&& App.MotorPara.RestFlag == false
&& App.HeightContRolCnt >= 500
&& GET_BIT0_DOUT() == 1
@@ -1167,6 +1186,8 @@ static void App1mSRoutine(void)
App.Uart1Delay1mSCnt--;
if(App.Uart3RxTimeOut1mSCnt > 0)
App.Uart3RxTimeOut1mSCnt--;
if(App.RestStop1mSCnt > 0)
App.RestStop1mSCnt--;
if(App.StopCollDelay1mSCnt > 0)
App.StopCollDelay1mSCnt--;
if(App.RunCollDelay1mSCnt > 0)
@@ -1179,7 +1200,7 @@ static void App1mSRoutine(void)
App.CentCollDelay1mSCnt--;
if(App.MotorPara.InitialFlag == true)
App.CailUp1mSCnt++;
if((App.MotorPara.Current_height < 725 || App.MotorPara.Current_height > 1195))
if((App.MotorPara.Current_height < 1005 || App.MotorPara.Current_height > 1425))
{
App.HeightContRolCnt++;
}
@@ -1206,6 +1227,7 @@ int main(void)
FeedDogHandler();
#endif
DebugLoopHandler();
//Uart3ErrLogLoopHandler(); //调试观测日志(复位流程已验证, 关闭打印, 需要时取消注释)
#if(USE_CS1237_LEFTUP == 1)
LEFTUP_CS1237DataLoopCollect();
#endif
@@ -1301,31 +1323,53 @@ void Usart3RxIrqCallback(void)
{
if(App.RxUart3Data.RxBuff[0] == 0x01 && App.RxUart3Data.RxBuff[1] == 0x04)
{
uint8_t firstErr = (App.MotorPara.RestFlag == false) ? 0 : 1; //0:首次信息帧 1:复位中回应
App.MotorPara.RestFlag = true;
App.MotorPara.OverheatFlag = false;//收到复位帧, 过热状态解除
if(firstErr == 0)
{
App.RestStop1mSCnt = 2000;//首次收到复位帧: 启动停顿计时, 先停止电机让控制盒进入复位流程, 计时结束再下降触发复位
}
//Uart3ErrLog_Push(firstErr, App.RxUart3Data.RxBuff, 0);//调试观测日志(关闭打印, 需要时取消注释)
}
else if(App.RxUart3Data.RxBuff[0] == 0x01 && App.RxUart3Data.RxBuff[1] == 0x01)
{
App.MotorPara.RestFlag = false;
int16_t h = ((App.RxUart3Data.RxBuff[2]<<8) & 0xff00) + (App.RxUart3Data.RxBuff[3] & 0x00ff);
if(h >=720 && h <= 1208)
if(App.MotorPara.RestFlag == true)
{
//Uart3ErrLog_Push(2, App.RxUart3Data.RxBuff, (uint16_t)h);//调试观测日志(关闭打印, 需要时取消注释)
}
App.MotorPara.RestFlag = false;
App.MotorPara.OverheatFlag = false;//收到高度帧, 确认复位完成
if(h >= 990 && h <= 1430)
{
App.MotorPara.Current_height = h;
}
if(App.MotorPara.InitialFlag == true && h >=720 && h <= 1200)
if(App.MotorPara.InitialFlag == true && h >= 1000 && h <= 1430)
{//缓存每个高度点对于零点应力的差值,对不同高度点的应力进行补偿
if(App.MotorPara.LU_HeightStress[(App.MotorPara.Current_height)-720] == 0
|| App.MotorPara.LL_HeightStress[(App.MotorPara.Current_height)-720] == 0
|| App.MotorPara.RU_HeightStress[(App.MotorPara.Current_height)-720] == 0
|| App.MotorPara.RL_HeightStress[(App.MotorPara.Current_height)-720] == 0)
if(App.MotorPara.LU_HeightStress[HEIGHT_TO_IDX(App.MotorPara.Current_height)] == 0
|| App.MotorPara.LL_HeightStress[HEIGHT_TO_IDX(App.MotorPara.Current_height)] == 0
|| App.MotorPara.RU_HeightStress[HEIGHT_TO_IDX(App.MotorPara.Current_height)] == 0
|| App.MotorPara.RL_HeightStress[HEIGHT_TO_IDX(App.MotorPara.Current_height)] == 0)
{
App.MotorPara.CaliNum++;
}
App.MotorPara.LU_HeightStress[(App.MotorPara.Current_height)-720] = App.ADTrack.LeftUp_Org_AdZero - App.LeftUpCS1237_TrendArray[0];
App.MotorPara.LL_HeightStress[(App.MotorPara.Current_height)-720] = App.ADTrack.LeftLow_Org_AdZero - App.LeftLowCS1237_TrendArray[0];
App.MotorPara.RU_HeightStress[(App.MotorPara.Current_height)-720] = App.ADTrack.RightUp_Org_AdZero - App.RightUpCS1237_TrendArray[0];
App.MotorPara.RL_HeightStress[(App.MotorPara.Current_height)-720] = App.ADTrack.RightLow_Org_AdZero - App.RightLowCS1237_TrendArray[0];
App.MotorPara.LU_HeightStress[HEIGHT_TO_IDX(App.MotorPara.Current_height)] = App.ADTrack.LeftUp_Org_AdZero - App.LeftUpCS1237_TrendArray[0];
App.MotorPara.LL_HeightStress[HEIGHT_TO_IDX(App.MotorPara.Current_height)] = App.ADTrack.LeftLow_Org_AdZero - App.LeftLowCS1237_TrendArray[0];
App.MotorPara.RU_HeightStress[HEIGHT_TO_IDX(App.MotorPara.Current_height)] = App.ADTrack.RightUp_Org_AdZero - App.RightUpCS1237_TrendArray[0];
App.MotorPara.RL_HeightStress[HEIGHT_TO_IDX(App.MotorPara.Current_height)] = App.ADTrack.RightLow_Org_AdZero - App.RightLowCS1237_TrendArray[0];
}
}
else
{ //未知帧(帧头非01 04/01 01): 过热等其它报错可能是任意组合, 全部记录供分析
/* 过热帧(01 02 00 10): 置OverheatFlag, HEIGHT_CONTROL跳过限位纠偏, 由SupportControlHandle判断下降触发控制盒复位 */
if(App.RxUart3Data.RxBuff[0] == 0x01 && App.RxUart3Data.RxBuff[1] == 0x02
&& App.RxUart3Data.RxBuff[2] == 0x00 && App.RxUart3Data.RxBuff[3] == 0x10)
{
App.MotorPara.OverheatFlag = true;
}
//Uart3ErrLog_Push(3, App.RxUart3Data.RxBuff, 0);//调试观测日志(关闭打印, 需要时取消注释)
}
memset(App.RxUart3Data.RxBuff, 0, sizeof(App.RxUart3Data.RxBuff));
App.RxUart3Data.RxLen = 0;
App.Uart3RxTimeOut1mSCnt = 0;