@@ -248,7 +248,7 @@ int main(void) | |||||
NowFrequency = PulseOutput[Options.StartPulse].Frequency; | NowFrequency = PulseOutput[Options.StartPulse].Frequency; | ||||
NowPulse = Options.StartPulse; | NowPulse = Options.StartPulse; | ||||
N_Acc = PulseOutput[Options.StartPulse].Frequency / 2000 * Options.AccDownTime; | |||||
N_Acc = PulseOutput[Options.StartPulse].Frequency * Options.AccDownTime / 2000; | |||||
CPU_CRITICAL_EXIT() ; ///退出临界区 | CPU_CRITICAL_EXIT() ; ///退出临界区 | ||||
@@ -335,9 +335,6 @@ void Y1Direction(void *p_arg) | |||||
AccUp = (double)(Options.InitSpeed / Options.AccUpTime); | AccUp = (double)(Options.InitSpeed / Options.AccUpTime); | ||||
AccDown = - (double)(Options.InitSpeed / Options.AccDownTime); | AccDown = - (double)(Options.InitSpeed / Options.AccDownTime); | ||||
/* 计算当前段脉冲减速的脉冲数 */ | |||||
N_Acc = PulseOutput[NowPulse].Frequency / 2000 * Options.AccDownTime; | |||||
/* 挂起指定的时钟节拍 */ | /* 挂起指定的时钟节拍 */ | ||||
OSTimeDly(100, OS_OPT_TIME_DLY, &err); | OSTimeDly(100, OS_OPT_TIME_DLY, &err); | ||||
} | } | ||||
@@ -460,7 +457,7 @@ void PulseGetCount(void *p_arg) | |||||
if (TIM2->CNT != 0) CNT_Only[NowPulse] = TIM2->CNT; | if (TIM2->CNT != 0) CNT_Only[NowPulse] = TIM2->CNT; | ||||
AllPulseCNT = CNT_Only[0] + CNT_Only[1] + CNT_Only[2] + CNT_Only[3] + | AllPulseCNT = CNT_Only[0] + CNT_Only[1] + CNT_Only[2] + CNT_Only[3] + | ||||
CNT_Only[4] + CNT_Only[5] + CNT_Only[6] + CNT_Only[7] + | CNT_Only[4] + CNT_Only[5] + CNT_Only[6] + CNT_Only[7] + | ||||
CNT_Only[8] + CNT_Only[9]; | |||||
CNT_Only[8] + CNT_Only[9] + CNT_Only[10]; | |||||
CountSave(); | CountSave(); | ||||
OSTimeDly(10, OS_OPT_TIME_DLY, &err); | OSTimeDly(10, OS_OPT_TIME_DLY, &err); | ||||
@@ -552,7 +549,6 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) | |||||
if (ArrTimes <= (int32_t)(PulseOutput[NowPulse].Frequency - PulseOutput[PrePulse].Frequency) / AccUp) | if (ArrTimes <= (int32_t)(PulseOutput[NowPulse].Frequency - PulseOutput[PrePulse].Frequency) / AccUp) | ||||
{ | { | ||||
SetFrequency(Options.SentPost, PulseOutput[PrePulse].Frequency + ArrTimes * AccUp); | SetFrequency(Options.SentPost, PulseOutput[PrePulse].Frequency + ArrTimes * AccUp); | ||||
if(ArrTimes == 0) PulseStart(); /* 开始产生脉冲 */ | |||||
ArrTimes++; | ArrTimes++; | ||||
} | } | ||||
else | else | ||||
@@ -569,7 +565,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) | |||||
if (ArrTimes <= (int32_t)(PulseOutput[NowPulse].Frequency - PulseOutput[PrePulse].Frequency) / AccDown) | if (ArrTimes <= (int32_t)(PulseOutput[NowPulse].Frequency - PulseOutput[PrePulse].Frequency) / AccDown) | ||||
{ | { | ||||
SetFrequency(Options.SentPost, PulseOutput[PrePulse].Frequency + ArrTimes * AccDown); | SetFrequency(Options.SentPost, PulseOutput[PrePulse].Frequency + ArrTimes * AccDown); | ||||
if (ArrTimes == 0) PulseStart(); /* 开始产生脉冲 */ | |||||
// if (ArrTimes == 0) PulseStart(); /* 开始产生脉冲 */ | |||||
ArrTimes++; | ArrTimes++; | ||||
} | } | ||||
else | else | ||||
@@ -591,7 +587,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) | |||||
if (ArrTimes <= Options.AccUpTime) | if (ArrTimes <= Options.AccUpTime) | ||||
{ | { | ||||
SetFrequency(Options.SentPost, NowFrequency + ArrTimes * AccUp); | SetFrequency(Options.SentPost, NowFrequency + ArrTimes * AccUp); | ||||
if(ArrTimes == 0) PulseStart(); /* 开始产生脉冲 */ | |||||
// if(ArrTimes == 0) PulseStart(); /* 开始产生脉冲 */ | |||||
ArrTimes++; | ArrTimes++; | ||||
} | } | ||||
else | else | ||||
@@ -608,7 +604,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) | |||||
if (ArrTimes <= Options.AccDownTime) | if (ArrTimes <= Options.AccDownTime) | ||||
{ | { | ||||
SetFrequency(Options.SentPost, NowFrequency + ArrTimes * AccDown); | SetFrequency(Options.SentPost, NowFrequency + ArrTimes * AccDown); | ||||
if (ArrTimes == 0) PulseStart(); /* 开始产生脉冲 */ | |||||
// if (ArrTimes == 0) PulseStart(); /* 开始产生脉冲 */ | |||||
ArrTimes++; | ArrTimes++; | ||||
} | } | ||||
else | else | ||||
@@ -624,28 +620,29 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) | |||||
/* 第一段脉冲的加速 */ | /* 第一段脉冲的加速 */ | ||||
if (NowPulse == Options.StartPulse && PulseStartFlag == 1) | if (NowPulse == Options.StartPulse && PulseStartFlag == 1) | ||||
{ | { | ||||
if (ArrTimes < PulseOutput[NowPulse].Frequency / AccUp) | |||||
{ | |||||
if (ArrTimes <= PulseOutput[Options.StartPulse].Frequency / AccUp) | |||||
{ | |||||
ArrTimes++; | ArrTimes++; | ||||
SetFrequency(Options.SentPost, ArrTimes * AccUp); | SetFrequency(Options.SentPost, ArrTimes * AccUp); | ||||
if (ArrTimes == 1) PulseStart(); /* 开始产生脉冲 */ | if (ArrTimes == 1) PulseStart(); /* 开始产生脉冲 */ | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
SetFrequency(Options.SentPost, PulseOutput[NowPulse].Frequency); | SetFrequency(Options.SentPost, PulseOutput[NowPulse].Frequency); | ||||
HAL_TIM_Base_Stop_IT(&htim3); // 停止定时器并禁用中断 | |||||
PulseStartFlag = 0; | PulseStartFlag = 0; | ||||
ArrTimes = 0; | ArrTimes = 0; | ||||
HAL_TIM_Base_Stop_IT(&htim3); // 停止定时器并禁用中断 | |||||
} | } | ||||
} | } | ||||
/* 最后一段脉冲的减速 */ | /* 最后一段脉冲的减速 */ | ||||
if (PulseRuning == 0) | |||||
if (PulseRuning == 0 && NowPulse == 10) | |||||
{ | { | ||||
if (ArrTimes <= PulseOutput[PrePulse].Frequency / (- AccDown)) | |||||
if (ArrTimes < PulseOutput[PrePulse].Frequency / (- AccDown)) | |||||
{ | { | ||||
SetFrequency(Options.SentPost, PulseOutput[PrePulse].Frequency + ArrTimes * AccDown); | SetFrequency(Options.SentPost, PulseOutput[PrePulse].Frequency + ArrTimes * AccDown); | ||||
if (ArrTimes == 0) PulseStart(); /* 开始产生脉冲 */ | |||||
// if (ArrTimes == 0) PulseStart(); /* 开始产生脉冲 */ | |||||
ArrTimes++; | ArrTimes++; | ||||
} | } | ||||
else | else | ||||
@@ -221,7 +221,7 @@ void TIM2_IRQHandler(void) | |||||
__HAL_TIM_CLEAR_FLAG(&htim2, TIM_FLAG_UPDATE); | __HAL_TIM_CLEAR_FLAG(&htim2, TIM_FLAG_UPDATE); | ||||
TIM2->CNT = 0; | TIM2->CNT = 0; | ||||
PulseNum ++; /* 脉冲段数增加 */ | PulseNum ++; /* 脉冲段数增加 */ | ||||
/* 计算当前段脉冲减速的脉冲数 */ | |||||
if (Options.RunMod == 0) /* 相对模式 */ | if (Options.RunMod == 0) /* 相对模式 */ | ||||
{ | { | ||||
@@ -238,6 +238,8 @@ void TIM2_IRQHandler(void) | |||||
NowPulse = PulseOutput[NowPulse].NextPulse - 1; /* 进入下一段脉冲 */ | NowPulse = PulseOutput[NowPulse].NextPulse - 1; /* 进入下一段脉冲 */ | ||||
} | } | ||||
ArrFlag = 1; | ArrFlag = 1; | ||||
N_Acc = PulseOutput[NowPulse].Frequency * Options.AccDownTime / 2000; | |||||
SetNextPulse();/* 设置下一次进入中断的脉冲数 */ | SetNextPulse();/* 设置下一次进入中断的脉冲数 */ | ||||
NowFrequency = PulseOutput[NowPulse].Frequency; /* 保存当前脉冲的频率 */ | NowFrequency = PulseOutput[NowPulse].Frequency; /* 保存当前脉冲的频率 */ | ||||
HAL_TIM_Base_Start_IT(&htim3); /* 启动定时器3和中断 */ | HAL_TIM_Base_Start_IT(&htim3); /* 启动定时器3和中断 */ | ||||
@@ -264,7 +266,7 @@ void TIM2_IRQHandler(void) | |||||
if (TIM2->ARR < PulseOutput[PulseOutput[NowPulse].NextPulse].PulseCount) /* 如果已经达到了设定的最大脉冲数 */ | if (TIM2->ARR < PulseOutput[PulseOutput[NowPulse].NextPulse].PulseCount) /* 如果已经达到了设定的最大脉冲数 */ | ||||
{ | { | ||||
PulseCount = 0; | PulseCount = 0; | ||||
HAL_TIM_PWM_Stop_IT(&htim10,TIM_CHANNEL_1); /* 停止PWM输出 */ | |||||
HAL_TIM_PWM_Stop_IT(&htim10,TIM_CHANNEL_1); /* 停止PWM输出 */ | |||||
} | } | ||||
else | else | ||||
{ | { | ||||
@@ -174,9 +174,9 @@ void MX_TIM11_Init(void) | |||||
/* USER CODE END TIM11_Init 1 */ | /* USER CODE END TIM11_Init 1 */ | ||||
htim11.Instance = TIM11; | htim11.Instance = TIM11; | ||||
htim11.Init.Prescaler = 0; | |||||
htim11.Init.Prescaler = 1; | |||||
htim11.Init.CounterMode = TIM_COUNTERMODE_UP; | htim11.Init.CounterMode = TIM_COUNTERMODE_UP; | ||||
htim11.Init.Period = 65535; | |||||
htim11.Init.Period = 1; | |||||
htim11.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; | htim11.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; | ||||
htim11.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; | htim11.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; | ||||
if (HAL_TIM_Base_Init(&htim11) != HAL_OK) | if (HAL_TIM_Base_Init(&htim11) != HAL_OK) | ||||
@@ -215,9 +215,9 @@ void MX_TIM13_Init(void) | |||||
/* USER CODE END TIM13_Init 1 */ | /* USER CODE END TIM13_Init 1 */ | ||||
htim13.Instance = TIM13; | htim13.Instance = TIM13; | ||||
htim13.Init.Prescaler = 0; | |||||
htim13.Init.Prescaler = 1; | |||||
htim13.Init.CounterMode = TIM_COUNTERMODE_UP; | htim13.Init.CounterMode = TIM_COUNTERMODE_UP; | ||||
htim13.Init.Period = 65535; | |||||
htim13.Init.Period = 1; | |||||
htim13.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; | htim13.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; | ||||
htim13.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; | htim13.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; | ||||
if (HAL_TIM_Base_Init(&htim13) != HAL_OK) | if (HAL_TIM_Base_Init(&htim13) != HAL_OK) | ||||
@@ -256,9 +256,9 @@ void MX_TIM14_Init(void) | |||||
/* USER CODE END TIM14_Init 1 */ | /* USER CODE END TIM14_Init 1 */ | ||||
htim14.Instance = TIM14; | htim14.Instance = TIM14; | ||||
htim14.Init.Prescaler = 0; | |||||
htim14.Init.Prescaler = 1; | |||||
htim14.Init.CounterMode = TIM_COUNTERMODE_UP; | htim14.Init.CounterMode = TIM_COUNTERMODE_UP; | ||||
htim14.Init.Period = 65535; | |||||
htim14.Init.Period = 1; | |||||
htim14.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; | htim14.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; | ||||
htim14.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; | htim14.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; | ||||
if (HAL_TIM_Base_Init(&htim14) != HAL_OK) | if (HAL_TIM_Base_Init(&htim14) != HAL_OK) | ||||
@@ -1013,7 +1013,7 @@ | |||||
<item>AccDown</item> | <item>AccDown</item> | ||||
<item>ArrTimes</item> | <item>ArrTimes</item> | ||||
<item>temp</item> | <item>temp</item> | ||||
<item></item> | |||||
<item /> | |||||
</expressions> | </expressions> | ||||
<col-names> | <col-names> | ||||
<item>Expression</item> | <item>Expression</item> | ||||
@@ -20,7 +20,7 @@ | |||||
<LeaveTargetRunning>_ 0</LeaveTargetRunning> | <LeaveTargetRunning>_ 0</LeaveTargetRunning> | ||||
</StLinkDriver> | </StLinkDriver> | ||||
<DebugChecksum> | <DebugChecksum> | ||||
<Checksum>932074847</Checksum> | |||||
<Checksum>4029363809</Checksum> | |||||
</DebugChecksum> | </DebugChecksum> | ||||
<Exceptions> | <Exceptions> | ||||
<StopOnUncaught>_ 0</StopOnUncaught> | <StopOnUncaught>_ 0</StopOnUncaught> | ||||
@@ -152,7 +152,8 @@ | |||||
<mode>0</mode> | <mode>0</mode> | ||||
</DisassembleMode> | </DisassembleMode> | ||||
<Breakpoints2> | <Breakpoints2> | ||||
<Count>0</Count> | |||||
<Bp0>_ 1 "EMUL_CODE" "{$PROJ_DIR$\..\Core\Src\main.c}.644.5" 0 0 1 "" 0 "" 0</Bp0> | |||||
<Count>1</Count> | |||||
</Breakpoints2> | </Breakpoints2> | ||||
<Aliases> | <Aliases> | ||||
<A0>_ "C:\Users\Chiri\Desktop\PLSR\cmsis\uC-CPU\ARM-Cortex-M4\IAR\cpu_a.asm" "C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\cmsis\uC-CPU\ARM-Cortex-M4\IAR\cpu_a.asm"</A0> | <A0>_ "C:\Users\Chiri\Desktop\PLSR\cmsis\uC-CPU\ARM-Cortex-M4\IAR\cpu_a.asm" "C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\cmsis\uC-CPU\ARM-Cortex-M4\IAR\cpu_a.asm"</A0> | ||||
@@ -18,14 +18,30 @@ | |||||
</bookmark> | </bookmark> | ||||
<bookmark> | <bookmark> | ||||
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path> | <path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path> | ||||
<row>312</row> | |||||
<row>560</row> | |||||
</bookmark> | </bookmark> | ||||
<bookmark> | <bookmark> | ||||
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path> | <path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path> | ||||
<row>238</row> | |||||
<row>339</row> | |||||
</bookmark> | </bookmark> | ||||
<bookmark> | <bookmark> | ||||
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path> | <path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path> | ||||
<row>560</row> | |||||
<row>372</row> | |||||
</bookmark> | |||||
<bookmark> | |||||
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path> | |||||
<row>433</row> | |||||
</bookmark> | |||||
<bookmark> | |||||
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path> | |||||
<row>463</row> | |||||
</bookmark> | |||||
<bookmark> | |||||
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path> | |||||
<row>557</row> | |||||
</bookmark> | |||||
<bookmark> | |||||
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path> | |||||
<row>638</row> | |||||
</bookmark> | </bookmark> | ||||
</userBookmarks> | </userBookmarks> |