1、添加了控制阈值等级

2、添加了波形数据输出开关
This commit is contained in:
2025-09-18 15:32:27 +08:00
parent 2ff11e995c
commit 5d024ff2e2
6 changed files with 230 additions and 36 deletions
+94 -6
View File
@@ -214,11 +214,13 @@ void DebugCmdHelp(int argc, char *argv[])
DBG_LOG("Debug Cmd:\r\n\
disp task on/off -->Open the task display.\r\n\
help\
dcmotor\
motor\
level\
wave\
");
}
#if 0
//// 定义一个无参函数DebugReadData,用于读取数据
//void DebugReadData(int argc, char *argv[])
//{
@@ -266,7 +268,7 @@ void DebugCmdHelp(int argc, char *argv[])
// // 调用TimeSync函数,并将num作为参数传入
// TimeSync(num);
//}
#endif
extern uint8_t KeyASta;
extern uint8_t KeyBSta;
extern uint8_t RunSta;
@@ -304,12 +306,98 @@ void MotorSwitch(int argc, char *argv[])
DBG_LOG("Motor OFF\r\n");
}
}
extern void GradeControl(ControlLevel_m level);
void LevelSwitch(int argc, char *argv[])
{
// 如果参数个数小于2,则返回
if(argc < 2)
return;
// 如果参数为“?”,则打印帮助信息
if(strcmp(argv[1], "?") == 0)
{
DBG_LOG("level Cmd:\r\n\
level 1/2/3/4/5 -->Select control level.\r\n");
return;
}
// 如果参数为“1”,则打印“Set control level: 1”
if(strcmp(argv[1], "1") == 0)
{
App.Para.Layout.ControlLevel = LEVEL_1;//等级1
SAVE_APP_PARA((uint32_t *)&App.Para);
DBG_LOG("Set control level: 1\r\n");
DBG_LOG("SystemReset...\r\n");
NVIC_SystemReset();
}
// 如果参数为“2”,则打印“Set control level: 2”
else if(strcmp(argv[1], "2") == 0)
{
App.Para.Layout.ControlLevel = LEVEL_2;//等级2
SAVE_APP_PARA((uint32_t *)&App.Para);
DBG_LOG("Set control level: 2\r\n");
DBG_LOG("SystemReset...\r\n");
NVIC_SystemReset();
}
// 如果参数为“3”,则打印“Set control level: 1”
else if(strcmp(argv[1], "3") == 0)
{
App.Para.Layout.ControlLevel = LEVEL_3;//等级3
SAVE_APP_PARA((uint32_t *)&App.Para);
DBG_LOG("Set control level: 3\r\n");
DBG_LOG("SystemReset...\r\n");
NVIC_SystemReset();
}
// 如果参数为“4”,则打印“Set control level: 4”
else if(strcmp(argv[1], "4") == 0)
{
App.Para.Layout.ControlLevel = LEVEL_4;//等级4
SAVE_APP_PARA((uint32_t *)&App.Para);
DBG_LOG("Set control level: 4\r\n");
DBG_LOG("SystemReset...\r\n");
NVIC_SystemReset();
}
// 如果参数为“5”,则打印“Set control level: 5”
else if(strcmp(argv[1], "5") == 0)
{
App.Para.Layout.ControlLevel = LEVEL_5;//等级5
SAVE_APP_PARA((uint32_t *)&App.Para);
DBG_LOG("Set control level: 5\r\n");
DBG_LOG("SystemReset...\r\n");
NVIC_SystemReset();
}
}
void DBGWave_on_off(int argc, char *argv[])
{
// 如果参数个数小于2,则返回
if(argc < 2)
return;
// 如果参数为“?”,则打印帮助信息
if(strcmp(argv[1], "?") == 0)
{
DBG_LOG("wave Cmd:\r\n\
wave on/off -->Turn on or off waveform output.\r\n");
return;
}
// 如果参数为“on”,则打印“Test ON”
if(strcmp(argv[1], "on") == 0)
{
App.Para.Layout.DBGWaveOut = true;
SAVE_APP_PARA((uint32_t *)&App.Para);
DBG_LOG("Waveform output on.\r\n");
}
// 如果参数为“off”,则打印“Test OFF”
else if(strcmp(argv[1], "off") == 0)
{
App.Para.Layout.DBGWaveOut = false;
SAVE_APP_PARA((uint32_t *)&App.Para);
DBG_LOG("Waveform output off.\r\n");
}
}
const DBGFunType DebugFun[DEBUG_CMD_CNT] = {
"help", DebugCmdHelp,
"motor", MotorSwitch,
"motor", MotorSwitch,
"level", LevelSwitch,
"wave", DBGWave_on_off,
};
#endif
+79 -20
View File
@@ -21,15 +21,18 @@ AppDetect_t App;
static void show(uint8_t ch,int32_t ad)
{
if(App.Para.Layout.DBGWaveOut == true)
{
uint8_t bao[7];
bao[0] = 0x5A;
bao[1] = ch;
bao[2] = ad & 0xFF;
bao[3] = ad >> 8 & 0xFF;
bao[4] = ad >> 16 & 0xFF;
bao[5] = ad >> 24 & 0xFF;
bao[6] = 0xA5;
DebugUartSend(bao,7);
bao[0] = 0x5A;
bao[1] = ch;
bao[2] = ad & 0xFF;
bao[3] = ad >> 8 & 0xFF;
bao[4] = ad >> 16 & 0xFF;
bao[5] = ad >> 24 & 0xFF;
bao[6] = 0xA5;
DebugUartSend(bao,7);
}
}
void LEFTUP_CS1237AinADataProcessCallBack(int32_t AD)
{
@@ -71,7 +74,39 @@ void RIGHTLOW_CS1237AinADataProcessCallBack(int32_t AD)
App.RightLowCS1237_TrendArray[0] = AD;
App.RightLowCS1237ReadEndFlag = true;
}
#if 1
void GradeControl(ControlLevel_m level)
{
switch(level){
case LEVEL_1:{
break;}
case LEVEL_2:{
break;}
case LEVEL_3:{
App.ADTrack.Slope_VPT = 2000;
App.ADTrack.LeftUpVPT = 40000;
App.ADTrack.LeftLowVPT = 40000;
App.ADTrack.RightUpVPT = 40000;
App.ADTrack.RightLowVPT = 40000;
App.ADTrack.LeftUpShieldVPT = 10000;
App.ADTrack.LeftLowShieldVPT = 10000;
App.ADTrack.RightUpShieldVPT = 10000;
App.ADTrack.RightLowShieldVPT = 10000;
break;}
case LEVEL_4:{
break;}
case LEVEL_5:{
break;}
}
}
#if(USE_AGC == 1)
void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_t *rl_ad)
{
int32_t lu_diff[OSC_CNT], Olu_diff1, Olu_diff2, Olu_diff3;
@@ -155,7 +190,7 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
&& (Oll_diff3 <= -App.ADTrack.LeftLowVPT)))
{
if((abs(Olu_diff1) > abs(Orl_diff1) + App.ADTrack.LeftUpShieldVPT)
&& (abs(Oll_diff1) > abs(Oru_diff1) + App.ADTrack.LeftLowpShieldVPT))
&& (abs(Oll_diff1) > abs(Oru_diff1) + App.ADTrack.LeftLowShieldVPT))
{
BDC_UP();
App.UpFlag = true;
@@ -404,6 +439,19 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
#endif
static void AppInit(void)
{
memset(&App, 0x00, sizeof(App));
READ_APP_PARA((uint32_t *)&App.Para);
if(App.Para.FactoryFlag != 0x00){
App.Para.FactoryFlag = 0x00;
/*参数初始化*/
App.Para.Layout.ControlLevel = LEVEL_3;//出厂默认等级3
App.Para.Layout.DBGWaveOut = false;
SAVE_APP_PARA((uint32_t *)&App.Para);
}
if(App.Para.Layout.ControlLevel > 5 || App.Para.Layout.ControlLevel < 1){
App.Para.Layout.ControlLevel = LEVEL_3;//出厂默认等级3
SAVE_APP_PARA((uint32_t *)&App.Para);
}
DBG_LOG("\r\n\r\n");
DBG_LOG("****************************************************\r\n");
DBG_LOG("** **\r\n");
@@ -423,6 +471,7 @@ static void AppInit(void)
App.Status = APP_STATUS_WAIT;
App.TD1mSDelayCnt = 2000;
App.RStatus = READ_STATUS_START;
GradeControl(App.Para.Layout.ControlLevel);//等级控制
App.WaitFlag = false;
}
@@ -515,7 +564,9 @@ static void ReadLoopHandler(void)
App.RightLowCS1237ReadEndFlag == true &&
App.WaitFlag == true)
{
#if(USE_AGC == 1)
SupportControlHandle(App.LeftUpCS1237_TrendArray, App.LeftLowCS1237_TrendArray, App.RightUpCS1237_TrendArray, App.RightLowCS1237_TrendArray);
#endif
}
App.RStatus = READ_STATUS_START;
break;}
@@ -546,16 +597,6 @@ static void AppLoopHandler(void)
App.StopFlag = true;
App.EvenRunning = false;
App.ADTrack.Slope_VPT = 2000;
App.ADTrack.LeftUpVPT = 40000;
App.ADTrack.LeftLowVPT = 40000;
App.ADTrack.RightUpVPT = 40000;
App.ADTrack.RightLowVPT = 40000;
App.ADTrack.LeftUpShieldVPT = 10000;
App.ADTrack.LeftLowpShieldVPT = 10000;
App.ADTrack.RightUpShieldVPT = 10000;
App.ADTrack.RightLowShieldVPT = 10000;
App.ADTrack.LeftUp_Org_AdZero = App.LeftUpCS1237_TrendArray[0];
App.ADTrack.LeftLow_Org_AdZero = App.LeftLowCS1237_TrendArray[0];
App.ADTrack.RightUp_Org_AdZero = App.RightUpCS1237_TrendArray[0];
@@ -606,10 +647,18 @@ int main(void)
#if(USE_DEBUG == 1)
DebugLoopHandler();
#endif
#if(USE_CS1237_LEFTUP == 1)
LEFTUP_CS1237DataLoopCollect();
#endif
#if(USE_CS1237_LEFTLOW == 1)
LEFTLOW_CS1237DataLoopCollect();
#endif
#if(USE_CS1237_RIGHTUP == 1)
RIGHTUP_CS1237DataLoopCollect();
#endif
#if(USE_CS1237_RIGHTLOW == 1)
RIGHTLOW_CS1237DataLoopCollect();
#endif
ReadLoopHandler();
DcmotorLoopHandler();
AppLoopHandler();
@@ -627,10 +676,20 @@ void SysTick_IrqHandler(void)
SysTick_IncTick();
App1mSRoutine();
Dbg1msRoutine();
#if(USE_CS1237_LEFTUP == 1)
LEFTUP_CS12371mSRoutine();
#endif
#if(USE_CS1237_LEFTLOW == 1)
LEFTLOW_CS12371mSRoutine();
#endif
#if(USE_CS1237_RIGHTUP == 1)
RIGHTUP_CS12371mSRoutine();
#endif
#if(USE_CS1237_RIGHTLOW == 1)
RIGHTLOW_CS12371mSRoutine();
#endif
Dcmotor1msRoutine();
}