1、修复了小概率采集到错误ad值的bug

2、优化了中间抬升下降的bug
This commit is contained in:
2025-10-27 17:50:31 +08:00
parent 291a41e850
commit 445e67f234
3 changed files with 71 additions and 22 deletions
+23 -3
View File
@@ -208,7 +208,27 @@
<Ww> <Ww>
<count>11</count> <count>11</count>
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<ItemText>DcMotorDispEn</ItemText> <ItemText>App.EmergencyDelay1mSCnt,0x0A</ItemText>
</Ww>
<Ww>
<count>12</count>
<WinNumber>1</WinNumber>
<ItemText>App.ADTrack.LeftLow_Org_AdZero,0x0A</ItemText>
</Ww>
<Ww>
<count>13</count>
<WinNumber>1</WinNumber>
<ItemText>Oll_diff1,0x0A</ItemText>
</Ww>
<Ww>
<count>14</count>
<WinNumber>1</WinNumber>
<ItemText>Orl_diff1,0x0A</ItemText>
</Ww>
<Ww>
<count>15</count>
<WinNumber>1</WinNumber>
<ItemText>-(App.ADTrack.Stop_VPT),0x0A</ItemText>
</Ww> </Ww>
</WatchWindow1> </WatchWindow1>
<Tracepoint> <Tracepoint>
@@ -217,7 +237,7 @@
<DebugFlag> <DebugFlag>
<trace>0</trace> <trace>0</trace>
<periodic>1</periodic> <periodic>1</periodic>
<aLwin>1</aLwin> <aLwin>0</aLwin>
<aCover>0</aCover> <aCover>0</aCover>
<aSer1>0</aSer1> <aSer1>0</aSer1>
<aSer2>0</aSer2> <aSer2>0</aSer2>
@@ -1018,7 +1038,7 @@
<Group> <Group>
<GroupName>CS1237</GroupName> <GroupName>CS1237</GroupName>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
+2 -2
View File
@@ -180,8 +180,8 @@
#define CLR_TWIN_BIT1() PORT_ResetBits(TWIN_BIT1_PORTx, TWIN_BIT1_PINx)//拉低 #define CLR_TWIN_BIT1() PORT_ResetBits(TWIN_BIT1_PORTx, TWIN_BIT1_PINx)//拉低
typedef struct { typedef struct {
uint32_t ControlLevel;//控制等级 int32_t ControlLevel;//控制等级
uint32_t DBGWaveOut;//调试波形输出 int32_t DBGWaveOut;//调试波形输出
}__attribute__ ((packed))LayoutPara_t, *LayoutPara;//上位机下发的配置参数 }__attribute__ ((packed))LayoutPara_t, *LayoutPara;//上位机下发的配置参数
typedef struct { typedef struct {
+46 -17
View File
@@ -36,6 +36,10 @@ static void show(uint8_t ch,int32_t ad)
} }
void LEFTUP_CS1237AinADataProcessCallBack(int32_t AD) void LEFTUP_CS1237AinADataProcessCallBack(int32_t AD)
{ {
if(abs(AD - App.LeftUpCS1237_TrendArray[0]) > 2000000)
{
AD = App.LeftUpCS1237_TrendArray[0];
}
show(1,AD); show(1,AD);
for(int i = OSC_CNT-1; i > 0; i--) for(int i = OSC_CNT-1; i > 0; i--)
{ {
@@ -46,6 +50,11 @@ void LEFTUP_CS1237AinADataProcessCallBack(int32_t AD)
} }
void LEFTLOW_CS1237AinADataProcessCallBack(int32_t AD) void LEFTLOW_CS1237AinADataProcessCallBack(int32_t AD)
{ {
if(abs(AD - App.LeftLowCS1237_TrendArray[0]) > 2000000)
{
AD = App.LeftLowCS1237_TrendArray[0];
}
show(2,AD); show(2,AD);
for(int i = OSC_CNT-1; i > 0; i--) for(int i = OSC_CNT-1; i > 0; i--)
{ {
@@ -56,6 +65,10 @@ void LEFTLOW_CS1237AinADataProcessCallBack(int32_t AD)
} }
void RIGHTUP_CS1237AinADataProcessCallBack(int32_t AD) void RIGHTUP_CS1237AinADataProcessCallBack(int32_t AD)
{ {
if(abs(AD - App.RightUpCS1237_TrendArray[0]) > 2000000)
{
AD = App.RightUpCS1237_TrendArray[0];
}
show(3,AD); show(3,AD);
for(int i = OSC_CNT-1; i > 0; i--) for(int i = OSC_CNT-1; i > 0; i--)
{ {
@@ -66,6 +79,10 @@ void RIGHTUP_CS1237AinADataProcessCallBack(int32_t AD)
} }
void RIGHTLOW_CS1237AinADataProcessCallBack(int32_t AD) void RIGHTLOW_CS1237AinADataProcessCallBack(int32_t AD)
{ {
if(abs(AD - App.RightLowCS1237_TrendArray[0]) > 2000000)
{
AD = App.RightLowCS1237_TrendArray[0];
}
show(4,AD); show(4,AD);
for(int i = OSC_CNT-1; i > 0; i--) for(int i = OSC_CNT-1; i > 0; i--)
{ {
@@ -250,7 +267,7 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
App.LeftRunFalg = true; App.LeftRunFalg = true;
// if((App.LeftLowCS1237_SlopeArray[0] > App.ADTrack.Slope_VPT/3)) // if((App.LeftLowCS1237_SlopeArray[0] > App.ADTrack.Slope_VPT/3))
// { // {
if((Oll_diff1+Orl_diff1) < -App.ADTrack.LeftLowVPT/3) if((Oll_diff1+Orl_diff1) < -(App.ADTrack.LeftLowVPT/(App.Para.Layout.ControlLevel+1)))
{ {
BDC_UP(); BDC_UP();
App.UpFlag = true; App.UpFlag = true;
@@ -263,7 +280,7 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
// } // }
// else if((App.LeftLowCS1237_SlopeArray[0] < -App.ADTrack.Slope_VPT/3)) // else if((App.LeftLowCS1237_SlopeArray[0] < -App.ADTrack.Slope_VPT/3))
// { // {
if((Oll_diff1+Orl_diff1) > App.ADTrack.LeftLowVPT/3) if((Oll_diff1+Orl_diff1) > App.ADTrack.LeftLowVPT/(App.Para.Layout.ControlLevel+1))
{ {
BDC_DOWN(); BDC_DOWN();
App.UpFlag = false; App.UpFlag = false;
@@ -278,9 +295,9 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
else if(abs(Oll_diff1) < abs(Orl_diff1)) else if(abs(Oll_diff1) < abs(Orl_diff1))
{ {
App.RightRunFalg = true; App.RightRunFalg = true;
if((App.RightLowCS1237_SlopeArray[0] > App.ADTrack.Slope_VPT/3)) // if((App.RightLowCS1237_SlopeArray[0] > App.ADTrack.Slope_VPT/3))
{ // {
if((Oll_diff1+Orl_diff1) < -App.ADTrack.RightLowVPT/3) if((Oll_diff1+Orl_diff1) < -(App.ADTrack.RightLowVPT/(App.Para.Layout.ControlLevel+1)))
{ {
BDC_UP(); BDC_UP();
App.UpFlag = true; App.UpFlag = true;
@@ -290,10 +307,10 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
App.RunCollDelay1mSCnt = RUN_TIME_MS; App.RunCollDelay1mSCnt = RUN_TIME_MS;
//App.EmergencyDelay1mSCnt = EME_START_MS; //App.EmergencyDelay1mSCnt = EME_START_MS;
} }
} // }
else if((App.RightLowCS1237_SlopeArray[0] < -App.ADTrack.Slope_VPT/3)) // else if((App.RightLowCS1237_SlopeArray[0] < -App.ADTrack.Slope_VPT/3))
{ // {
if((Oll_diff1+Orl_diff1) > App.ADTrack.RightLowVPT/3) if((Oll_diff1+Orl_diff1) > App.ADTrack.RightLowVPT/(App.Para.Layout.ControlLevel+1))
{ {
BDC_DOWN(); BDC_DOWN();
App.UpFlag = false; App.UpFlag = false;
@@ -303,7 +320,7 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
App.RunCollDelay1mSCnt = RUN_TIME_MS; App.RunCollDelay1mSCnt = RUN_TIME_MS;
//App.EmergencyDelay1mSCnt = EME_START_MS; //App.EmergencyDelay1mSCnt = EME_START_MS;
} }
} // }
} }
} }
else if((LeftSlopeSum > RightSlopeSum && LeftDiffSum > RightDiffSum)) else if((LeftSlopeSum > RightSlopeSum && LeftDiffSum > RightDiffSum))
@@ -448,7 +465,10 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
App.StopCollDelay1mSCnt = STOP_TIME_MS; App.StopCollDelay1mSCnt = STOP_TIME_MS;
App.EmergencyDelay1mSCnt = EME_START_MS; App.EmergencyDelay1mSCnt = EME_START_MS;
} }
else if((LeftLowDiff + EME_STOP_VPT) < RightLowDiff && App.EmergencyDelay1mSCnt <= 0 && App.CentreRunFalg == false) else if((abs(Oll_diff1) + EME_STOP_VPT) < abs(Orl_diff1)
&& (abs(Oll_diff2) + EME_STOP_VPT) < abs(Orl_diff2)
&& (abs(Oll_diff3) + EME_STOP_VPT) < abs(Orl_diff3)
&& App.EmergencyDelay1mSCnt <= 0 && App.CentreRunFalg == false)
{ {
BDC_STOP(); BDC_STOP();
App.EmeFlag = true; App.EmeFlag = true;
@@ -469,7 +489,7 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
App.EmergencyDelay1mSCnt = EME_START_MS; App.EmergencyDelay1mSCnt = EME_START_MS;
} }
else if(((App.CentreRunFalg == false ) && (Orl_diff1 < App.ADTrack.Stop_VPT)) else if(((App.CentreRunFalg == false ) && (Orl_diff1 < App.ADTrack.Stop_VPT))
|| ((App.CentreRunFalg == true) && ((Oll_diff1 + Orl_diff1) < (-App.ADTrack.Stop_VPT)))) || ((App.CentreRunFalg == true) && ((Oll_diff1 + Orl_diff1) < (App.ADTrack.Stop_VPT))))
{ {
BDC_STOP(); BDC_STOP();
App.StopFlag = true; App.StopFlag = true;
@@ -479,7 +499,10 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
App.StopCollDelay1mSCnt = STOP_TIME_MS; App.StopCollDelay1mSCnt = STOP_TIME_MS;
App.EmergencyDelay1mSCnt = EME_START_MS; App.EmergencyDelay1mSCnt = EME_START_MS;
} }
else if(LeftLowDiff > (RightLowDiff + EME_STOP_VPT) && App.EmergencyDelay1mSCnt <= 0 && App.CentreRunFalg == false) else if(abs(Oll_diff1) > (abs(Orl_diff1) + EME_STOP_VPT)
&& abs(Oll_diff2) > (abs(Orl_diff2) + EME_STOP_VPT)
&& abs(Oll_diff3) > (abs(Orl_diff3) + EME_STOP_VPT)
&& App.EmergencyDelay1mSCnt <= 0 && App.CentreRunFalg == false)
{ {
BDC_STOP(); BDC_STOP();
App.EmeFlag = true; App.EmeFlag = true;
@@ -492,7 +515,7 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
if(App.LeftRunFalg == true) if(App.LeftRunFalg == true)
{ {
if(((App.CentreRunFalg == false ) && (ll_slope < -App.ADTrack.Slope_VPT)) if(((App.CentreRunFalg == false ) && (ll_slope < -App.ADTrack.Slope_VPT))
|| ((App.CentreRunFalg == true ) && (App.LeftUpCS1237_SlopeArray[0] + App.RightUpCS1237_SlopeArray[0]) > -App.ADTrack.Slope_VPT)) || ((App.CentreRunFalg == true ) && (App.LeftUpCS1237_SlopeArray[0] + App.RightUpCS1237_SlopeArray[0]) > App.ADTrack.Slope_VPT))
{ {
BDC_STOP(); BDC_STOP();
App.StopFlag = true; App.StopFlag = true;
@@ -503,7 +526,7 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
App.EmergencyDelay1mSCnt = EME_START_MS; App.EmergencyDelay1mSCnt = EME_START_MS;
} }
else if(((App.CentreRunFalg == false ) && (Oll_diff1 > -App.ADTrack.Stop_VPT)) else if(((App.CentreRunFalg == false ) && (Oll_diff1 > -App.ADTrack.Stop_VPT))
|| ((App.CentreRunFalg == true) && ((Oll_diff1 + Orl_diff1) > -(App.ADTrack.Stop_VPT)))) || ((App.CentreRunFalg == true) && ((Oll_diff1 + Orl_diff1) > -App.ADTrack.Stop_VPT)))
{ {
BDC_STOP(); BDC_STOP();
App.StopFlag = true; App.StopFlag = true;
@@ -513,7 +536,10 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
App.StopCollDelay1mSCnt = STOP_TIME_MS; App.StopCollDelay1mSCnt = STOP_TIME_MS;
App.EmergencyDelay1mSCnt = EME_START_MS; App.EmergencyDelay1mSCnt = EME_START_MS;
} }
else if((LeftLowDiff + EME_STOP_VPT) < RightLowDiff && App.EmergencyDelay1mSCnt <= 0 && App.CentreRunFalg == false) else if((abs(Oll_diff1) + EME_STOP_VPT) < abs(Orl_diff1)
&& (abs(Oll_diff2) + EME_STOP_VPT) < abs(Orl_diff2)
&& (abs(Oll_diff3) + EME_STOP_VPT) < abs(Orl_diff3)
&& App.EmergencyDelay1mSCnt <= 0 && App.CentreRunFalg == false)
{ {
BDC_STOP(); BDC_STOP();
App.EmeFlag = true; App.EmeFlag = true;
@@ -544,7 +570,10 @@ void SupportControlHandle(int32_t *lu_ad, int32_t *ll_ad, int32_t *ru_ad, int32_
App.StopCollDelay1mSCnt = STOP_TIME_MS; App.StopCollDelay1mSCnt = STOP_TIME_MS;
App.EmergencyDelay1mSCnt = EME_START_MS; App.EmergencyDelay1mSCnt = EME_START_MS;
} }
else if(LeftLowDiff > (RightLowDiff + EME_STOP_VPT) && App.EmergencyDelay1mSCnt <= 0 && App.CentreRunFalg == false) else if(abs(Oll_diff1) > (abs(Orl_diff1) + EME_STOP_VPT)
&& abs(Oll_diff2) > (abs(Orl_diff2) + EME_STOP_VPT)
&& abs(Oll_diff3) > (abs(Orl_diff3) + EME_STOP_VPT)
&& App.EmergencyDelay1mSCnt <= 0 && App.CentreRunFalg == false)
{ {
BDC_STOP(); BDC_STOP();
App.EmeFlag = true; App.EmeFlag = true;