Quellcode durchsuchen

修改脉冲加减速的代码,添加最后一段脉冲的减速功能

master
Chiri vor 1 Monat
Ursprung
Commit
cc732dea86
7 geänderte Dateien mit 630 neuen und 632 gelöschten Zeilen
  1. +15
    -23
      Core/Src/main.c
  2. +588
    -588
      EWARM/PLSR.dep
  3. +8
    -10
      EWARM/settings/PLSR.dbgdt
  4. +1
    -1
      EWARM/settings/PLSR.dnx
  5. +9
    -9
      EWARM/settings/Project.wsdt
  6. +8
    -0
      EWARM/settings/Project_EditorBookmarks.xml
  7. +1
    -1
      Hardware/PLSR.c

+ 15
- 23
Core/Src/main.c Datei anzeigen

@@ -322,14 +322,6 @@ void Y1Direction(void *p_arg)
if (NowFrequency != PulseOutput[NowPulse].Frequency && PulseRuning == 1)/* 如果现在寄存器内的频率与实际输出的频率不一致 */
{
FixArrFlag = 1; //使能频率修改脉冲加减速
if (PulseOutput[NowPulse].Frequency > NowFrequency)
{
Acc = (PulseOutput[NowPulse].Frequency - NowFrequency ) / Options.AccUpTime;
}
else
{
Acc = (PulseOutput[NowPulse].Frequency - NowFrequency ) / Options.AccDownTime;
}
HAL_TIM_Base_Start_IT(&htim3); /* 启动定时器3和中断 */
}
@@ -363,10 +355,9 @@ void PulseStartTsk(void *p_arg)
if (Register_L[0x3000] == 0x01 && EN == 1)
{
EN = 0;
PulseStartFlag = 1;
PulseRuning = 1;
PulseStartFlag = 1; /* 脉冲第一段开始标志位 */
PulseRuning = 1; /* 脉冲进行中标志位 */
NowFrequency = PulseOutput[NowPulse].Frequency; /* 保存当前脉冲的频率 */
PulseStart();
HAL_TIM_Base_Start_IT(&htim3); /* 启动定时器3和中断 */
}
else if (Register_L[0x3000] == 0x02 && EN == 0)
@@ -547,12 +538,12 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
if (htim == (&htim3))
{
/* 段切换的加减速 */
if (ArrFlag == 1)
if (ArrFlag == 1 && NowPulse != 10)
{
/* 脉冲加速 */
if (Acc > 0)
if (PulseOutput[NowPulse].Frequency > PulseOutput[PrePulse].Frequency)
{
if (ArrTimes <= Options.AccUpTime)
if (ArrTimes <= (int32_t)(PulseOutput[NowPulse].Frequency - PulseOutput[PrePulse].Frequency) / AccUp)
{
SetFrequency(Options.SentPost, PulseOutput[PrePulse].Frequency + ArrTimes * AccUp);
if(ArrTimes == 0) PulseStart(); /* 开始产生脉冲 */
@@ -567,13 +558,14 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
}
}
/* 脉冲减速 */
else if (Acc <= 0)
else if (PulseOutput[NowPulse].Frequency <= PulseOutput[PrePulse].Frequency)
{
if (ArrTimes <= Options.AccDownTime)
if (ArrTimes <= (int32_t)(PulseOutput[NowPulse].Frequency - PulseOutput[PrePulse].Frequency) / AccDown)
{
SetFrequency(Options.SentPost, PulseOutput[PrePulse].Frequency + ArrTimes * AccDown);
if (ArrTimes == 0) PulseStart(); /* 开始产生脉冲 */
ArrTimes++;
}
else
{
@@ -585,10 +577,10 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
}
}
/* 实时修改频率的加减速 */
if (FixArrFlag == 1)
if (FixArrFlag == 1 && NowPulse != 10)
{
/* 脉冲加速 */
if (Acc > 0)
if (PulseOutput[NowPulse].Frequency > NowFrequency)
{
if (ArrTimes <= Options.AccUpTime)
{
@@ -605,7 +597,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
}
}
/* 脉冲减速 */
else if (Acc <= 0)
else if (PulseOutput[NowPulse].Frequency <= NowFrequency)
{
if (ArrTimes <= Options.AccDownTime)
{
@@ -626,7 +618,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
/* 第一段脉冲的加速 */
if (NowPulse == Options.StartPulse && PulseStartFlag == 1)
{
if (ArrTimes <= Options.AccUpTime)
if (ArrTimes < PulseOutput[NowPulse].Frequency / AccUp)
{
ArrTimes++;
SetFrequency(Options.SentPost, ArrTimes * AccUp);
@@ -641,11 +633,11 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
}
}
/* 最后一段脉冲的减速 */
if (PulseRuning == 0)
if (PulseRuning == 0 && NowPulse != 10)
{
if (ArrTimes <= Options.AccDownTime)
if (ArrTimes <= PulseOutput[NowPulse].Frequency / (- AccDown))
{
SetFrequency(Options.SentPost, NowFrequency + ArrTimes * AccDown);
SetFrequency(Options.SentPost, PulseOutput[NowPulse].Frequency + ArrTimes * AccDown);
if (ArrTimes == 0) PulseStart(); /* 开始产生脉冲 */
ArrTimes++;
}


+ 588
- 588
EWARM/PLSR.dep
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


+ 8
- 10
EWARM/settings/PLSR.dbgdt
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


+ 1
- 1
EWARM/settings/PLSR.dnx Datei anzeigen

@@ -20,7 +20,7 @@
<LeaveTargetRunning>_ 0</LeaveTargetRunning>
</StLinkDriver>
<DebugChecksum>
<Checksum>2476724192</Checksum>
<Checksum>3907057673</Checksum>
</DebugChecksum>
<Exceptions>
<StopOnUncaught>_ 0</StopOnUncaught>


+ 9
- 9
EWARM/settings/Project.wsdt
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


+ 8
- 0
EWARM/settings/Project_EditorBookmarks.xml Datei anzeigen

@@ -28,4 +28,12 @@
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path>
<row>238</row>
</bookmark>
<bookmark>
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path>
<row>523</row>
</bookmark>
<bookmark>
<path>C:\Users\Chiri\Desktop\TrainCamp-Jiangyunsong-PLSR\Core\Src\main.c</path>
<row>560</row>
</bookmark>
</userBookmarks>

+ 1
- 1
Hardware/PLSR.c Datei anzeigen

@@ -33,7 +33,7 @@ int32_t PulseCount = 0;
void SetFrequency(uint8_t SentPost, uint32_t Frequency)
{
CalculatePSCARR(Frequency, 72000000, 65535, &psc, &arr);
//printf("Fre=%d,",Frequency);
printf("Fre=%d,",Frequency);
switch (SentPost)
{
case 0: TIM10->ARR = arr, TIM10->PSC = psc, TIM10->CCR1 = arr / 2; break;


Laden…
Abbrechen
Speichern