通过高度校准应力初版

This commit is contained in:
2026-03-26 10:11:46 +08:00
parent 0e05817f63
commit 2657c1ca27
8 changed files with 794 additions and 309 deletions
@@ -49,6 +49,7 @@ bool count_smaller(int32_t *arr, uint8_t size, int32_t target);
uint16_t CRC_Modbus(uint16_t wBase, uint8_t *para, uint16_t length);
uint8_t CRC_Sum(uint8_t *_pbuff, uint16_t _cmdLen);
bool isAllZero(uint8_t *arr, int size);
int fixWithMedianWindow(int arr[], int size, int windowSize, int threshold);
#endif
+70 -29
View File
@@ -21,13 +21,14 @@
#define USE_I2C1 0 //I2C1开关,0、关闭,1、启用
#define USE_SPI1 0 //SPI1开关,0、关闭,1、启用
#define USE_SPI3 0 //SPI3开关,0、关闭,1、启用
#define USE_USART3 1
#define USE_BOOTLOADER 0 //BOOTLOADER开关,0、关闭,1、启用
#define USE_CS1237_LEFTUP 1 //左上CS1237开关,0、关闭,1、启用
#define USE_CS1237_LEFTLOW 1 //左下CS1237开关,0、关闭,1、启用
#define USE_CS1237_RIGHTUP 1 //右上CS1237开关,0、关闭,1、启用
#define USE_CS1237_RIGHTLOW 1 //右CS1237开关,0、关闭,1、启用
#define USE_CS1237_RIGHTLOW 1 //右CS1237开关,0、关闭,1、启用
#define USE_AGC 1 //算法控制开关,0、关闭,1、启用
//<<---------------------------- MCU -------------------------------->>
@@ -50,7 +51,64 @@
#define DBG_RX_IRQn (Int000_IRQn)
#define DBG_ER_IRQn (Int001_IRQn)
#endif
//< USART3
//#if(USE_USART3 == 1)
//#define USAR3_CH (M4_USART3)
//#define USAR3_RX_PORT (PortH)
//#define USAR3_RX_PIN (Pin02)
//#define USAR3_TX_PORT (PortC)
//#define USAR3_TX_PIN (Pin13)
//#define USAR3_RX_FUNC (Func_Usart3_Rx)
//#define USAR3_TX_FUNC (Func_Usart3_Tx)
//#define USAR3_RI_NUM (INT_USART3_RI)
//#define USAR3_EI_NUM (INT_USART3_EI)
//#define USAR3_TI_NUM (INT_USART3_TI)
//#define USAR3_TCI_NUM (INT_USART3_TCI)
//#define USAR3_FCG1_PERIPH (PWC_FCG1_PERIPH_USART3)
//#define USAR3_RXPIN_EXIT_CH (ExtiCh14)
//#define USAR3_RXPIN_EXIT_SRC (INT_PORT_EIRQ14)
//#define USAR3_RX_IRQn (Int006_IRQn)
//#define USAR3_ER_IRQn (Int007_IRQn)
//#endif
#if(USE_USART3 == 1)
#define USART3_CH (M4_USART3)
#define USART3_RX_PORT (PortH)
#define USART3_RX_PIN (Pin02)
#define USART3_RX_FUNC (Func_Usart3_Rx)
#define USART3_USART_RI_NUM (INT_USART3_RI)
#define USART3_USART_EI_NUM (INT_USART3_EI)
#define USART3_FCG1_PERIPH (PWC_FCG1_PERIPH_USART3)
#define USART3_RX_IRQn (Int006_IRQn)
#define USART3_ER_IRQn (Int007_IRQn)
//#define USART3_RXPIN_IRQn Int002_IRQn
#endif
// RS485
#if(USE_RS485 == 1)
#define RS485_USART_CH (M4_USART1)
//#define RS485_USART_RX_PORT (PortB)
//#define RS485_USART_RX_PIN (Pin08)
//#define RS485_USART_TX_PORT (PortB)
//#define RS485_USART_TX_PIN (Pin09)
#define RS485_USART_RX_PORT (PortA)
#define RS485_USART_RX_PIN (Pin15)
#define RS485_USART_TX_PORT (PortA)
#define RS485_USART_TX_PIN (Pin12)
#define RS485_USART_RX_FUNC (Func_Usart1_Rx)
#define RS485_USART_TX_FUNC (Func_Usart1_Tx)
#define RS485_USART_RI_NUM (INT_USART1_RI)
#define RS485_USART_EI_NUM (INT_USART1_EI)
#define RS485_USART_TI_NUM (INT_USART1_TI)
#define RS485_USART_TCI_NUM (INT_USART1_TCI)
#define RS485_FCG1_PERIPH (PWC_FCG1_PERIPH_USART1)
#define RS485_RXPIN_EXIT_CH (ExtiCh14)
#define RS485_RXPIN_EXIT_SRC (INT_PORT_EIRQ14)
#define RS485_CTRL_PORT (PortC)
#define RS485_CTRL_PIN (Pin13)
#define RS485_TX() PORT_SetBits(RS485_CTRL_PORT, RS485_CTRL_PIN)
#define RS485_RX() PORT_ResetBits(RS485_CTRL_PORT, RS485_CTRL_PIN)
#endif
// SPI3
#if(USE_SPI3 == 1)
/* SPI3_SCK Port/Pin definition */
@@ -79,32 +137,6 @@
#define SPI3_UNIT (M4_SPI3)
#define SPI3_UNIT_CLOCK (PWC_FCG1_PERIPH_SPI3)
#endif
// RS485
#if(USE_RS485 == 1)
#define RS485_USART_CH (M4_USART1)
//#define RS485_USART_RX_PORT (PortB)
//#define RS485_USART_RX_PIN (Pin08)
//#define RS485_USART_TX_PORT (PortB)
//#define RS485_USART_TX_PIN (Pin09)
#define RS485_USART_RX_PORT (PortA)
#define RS485_USART_RX_PIN (Pin15)
#define RS485_USART_TX_PORT (PortA)
#define RS485_USART_TX_PIN (Pin12)
#define RS485_USART_RX_FUNC (Func_Usart1_Rx)
#define RS485_USART_TX_FUNC (Func_Usart1_Tx)
#define RS485_USART_RI_NUM (INT_USART1_RI)
#define RS485_USART_EI_NUM (INT_USART1_EI)
#define RS485_USART_TI_NUM (INT_USART1_TI)
#define RS485_USART_TCI_NUM (INT_USART1_TCI)
#define RS485_FCG1_PERIPH (PWC_FCG1_PERIPH_USART1)
#define RS485_RXPIN_EXIT_CH (ExtiCh14)
#define RS485_RXPIN_EXIT_SRC (INT_PORT_EIRQ14)
#define RS485_CTRL_PORT (PortC)
#define RS485_CTRL_PIN (Pin13)
#define RS485_TX() PORT_SetBits(RS485_CTRL_PORT, RS485_CTRL_PIN)
#define RS485_RX() PORT_ResetBits(RS485_CTRL_PORT, RS485_CTRL_PIN)
#endif
//< RTC
#if(USE_RTC == 1)
#define RTC_IRQn Int001_IRQn
@@ -207,9 +239,15 @@ void RS485UsartErrIrqCallback(void);
void RS485_RxPinIntCallBack(void);
void RS485UsartRxIrqCallback(void);
void RS485UartSend(uint8_t *sData, uint16_t sLen);
void RS485_1msRoutine(void);
uint8_t Uart3Rec(void);
void Usart3ErrIrqCallback(void);
void Usart3_RxPinIntCallBack(void);
void Usart3RxIrqCallback(void);
void Usart3Send(uint8_t *sData, uint16_t sLen);
void Uart3_Config(uint32_t BaudRate);
void DbgUsartRxIrqCallback(void);
void DBGUsartErrIrqCallback(void);
void DBG_RxPinIntCallBack(void);
@@ -237,7 +275,7 @@ uint32_t mf_showfree(uint8_t *drv);
void TimeGet(struct tm *cTime);
int TimeTs(void);
void TimeShow(uint32_t dwStamp);
void TimeSync(time_t ts) ;
void TimeSync(time_t ts);
void delay_5ns(uint32_t ns);
@@ -253,3 +291,6 @@ void ExtInt06IntDisable(void);
+31 -8
View File
@@ -11,8 +11,8 @@
#define SLOPE_CNT 20
#define SLOPE_VPT 1000
#define PRESS_VPT 10
#define FOLLOW_VPT 20
#define PRESS_VPT 3
#define FOLLOW_VPT 10
#define SHIELD_VPT 5000
#define EME_STOP_VPT 4000
#define CENTRE_VPT 2000
@@ -25,6 +25,8 @@
#define TRAVEL_TIME_MS 30000
#define PEAK 1200 //1200mm
#define VALLEY 720 //720mm
#define BDC_STOP() (SET_TWIN_BIT0(),SET_TWIN_BIT1())
#define BDC_UP() (SET_TWIN_BIT0(),CLR_TWIN_BIT1())
@@ -63,7 +65,16 @@ typedef struct{
int32_t RightUp_Org_AdZero;//右上设备原始AD零点
int32_t RightLow_Org_AdZero;//右下设备原始AD零点
}ADTrack_t;
typedef struct{//电机参数
bool InitialFlag;//初始标志位
bool CaliFlag;
int16_t Current_height;//当前高度mm
int16_t CaliNum;//标校数量
int32_t LU_HeightStress[488];//左上传感器对应高度应力
int32_t LL_HeightStress[488];//左下传感器对应高度应力
int32_t RU_HeightStress[488];//右上传感器对应高度应力
int32_t RL_HeightStress[488];//右上传感器对应高度应力
}MotorPara_t;
/*数据读取状态机*/
typedef enum {
READ_STATUS_IDLE,
@@ -84,10 +95,12 @@ typedef enum {
APP_STATUS_IDLE,
APP_STATUS_ON,
APP_STATUS_OFF,
APP_STATUS_UP1,
APP_STATUS_DOWN,
APP_STATUS_UP2,
APP_STATUS_WAIT,
APP_STATUS_MOTOR_INIT,
APP_STATUS_WAIT_MOTOR_INIT,
APP_STATUS_WAIT_MOTOR_CALI_UP,
APP_STATUS_WAIT_MOTOR_CALI_DOWN,
APP_STATUS_WAIT_STEADY,
APP_STATUS_ZERO_MARKING,
}AppStatus_m;
typedef struct{
@@ -97,16 +110,26 @@ typedef struct{
uint8_t RxBuff[10];
}Uart1Rx_t;
typedef struct{
__IO uint16_t rPayLen;
__IO bool HeaderFrame;
__IO uint16_t RxLen;
uint8_t RxBuff[4];
}Uart3Rx_t;
typedef struct {
AppStatus_m Status;//状态
ReadStatus_m RStatus;
AppPara_T Para;
Uart1Rx_t RxUart1Data;
Uart3Rx_t RxUart3Data;
ADTrack_t ADTrack;
ADTrack_t ADTrack;
MotorPara_t MotorPara;
uint32_t TD1mSDelayCnt;
uint32_t Read1mSDelayCnt;
uint32_t Uart1Delay1mSCnt;
uint32_t Uart3RxTimeOut1mSCnt;
uint32_t StopCollDelay1mSCnt;
uint32_t RunCollDelay1mSCnt;
uint32_t EmergencyDelay1mSCnt;