|
|
@@ -109,7 +109,7 @@ SEGMENT_PART currentSeg = { |
|
|
|
.currentPart = 1 |
|
|
|
}; |
|
|
|
PLSR plsr = { |
|
|
|
.segmentAllNum = 4, |
|
|
|
.segmentAllNum = 3, |
|
|
|
.defaultSpeed = 1000, |
|
|
|
.defaultAccSpeedTime = 5, |
|
|
|
.defaultDecSpeedTime = 10, |
|
|
@@ -122,9 +122,9 @@ PLSR plsr = { |
|
|
|
.segment[2].pulseFreq = 6000, |
|
|
|
.segment[2].pulseNumber = 2000, |
|
|
|
.segment[2].jumpNumber = 0, |
|
|
|
.segment[3].pulseFreq = 9000, |
|
|
|
.segment[3].pulseNumber = 2000, |
|
|
|
.segment[3].jumpNumber = 0, |
|
|
|
// .segment[3].pulseFreq = 9000, |
|
|
|
// .segment[3].pulseNumber = 2000, |
|
|
|
// .segment[3].jumpNumber = 0, |
|
|
|
.startRunSegment = 0 |
|
|
|
}; |
|
|
|
|
|
|
@@ -139,11 +139,12 @@ void PlsrModuleTask(void *pArg) |
|
|
|
|
|
|
|
res = GetTimObj("tim2", &tim2); |
|
|
|
res = GetTimObj("tim10", &tim10); |
|
|
|
|
|
|
|
|
|
|
|
tim2.init(&tim2, 0, 65535); |
|
|
|
tim2.open(&tim2); |
|
|
|
|
|
|
|
tim10.init(&tim10, 168 - 1, 65535); |
|
|
|
// tim10.open(&tim10); |
|
|
|
tim10.registerIrq(&tim10, TimCallBack, ¤tSeg); |
|
|
|
// tim10.openIrq(&tim10); |
|
|
|
tim10.pwmInit(&tim10); |
|
|
|
tim10.pwmSetPulse(&tim10, TIM10->ARR); |
|
|
|
|
|
|
@@ -227,8 +228,9 @@ void TimCallBack(void *pArg) |
|
|
|
{ |
|
|
|
uint16_t reloadValue = 0; |
|
|
|
static int32_t pulseCount = 0; |
|
|
|
|
|
|
|
static int32_t allcount = 0; |
|
|
|
pulseCount++; |
|
|
|
allcount++; |
|
|
|
if (currentSeg.currentPart == 1) |
|
|
|
{ |
|
|
|
switch (currentSeg.currentState) |
|
|
@@ -245,7 +247,12 @@ void TimCallBack(void *pArg) |
|
|
|
} |
|
|
|
else |
|
|
|
currentSpeed += currentSeg.inc; |
|
|
|
|
|
|
|
|
|
|
|
if (currentSpeed <= 1000) |
|
|
|
tim10.setPsc(&tim10, 2625 - 1); |
|
|
|
else |
|
|
|
tim10.setPsc(&tim10, 3 - 1); |
|
|
|
|
|
|
|
reloadValue = 168000000 / (TIM10->PSC + 1) / (currentSpeed); |
|
|
|
tim10.setPer(&tim10, reloadValue - 1); |
|
|
|
tim10.pwmSetPulse(&tim10, TIM10->ARR / 2 + 1); |
|
|
@@ -259,7 +266,7 @@ void TimCallBack(void *pArg) |
|
|
|
} |
|
|
|
else if (currentSeg.currentPart == 2) |
|
|
|
{ |
|
|
|
if (pulseCount > currentSeg.secondPartNum - 4) |
|
|
|
if (pulseCount > currentSeg.secondPartNum - 1) |
|
|
|
{ |
|
|
|
if ((currentSegment == (plsr.segmentAllNum -1)) |
|
|
|
&& (plsr.segment[currentSegment].jumpNumber == 0)) |
|
|
@@ -282,7 +289,7 @@ void TimCallBack(void *pArg) |
|
|
|
else if (currentSeg.currentPart == 3) |
|
|
|
{ |
|
|
|
if (((currentSpeed - currentSeg.dec) <= 0) |
|
|
|
|| (pulseCount > currentSeg.thirdPartNum)) |
|
|
|
|| (pulseCount > currentSeg.thirdPartNum - 1)) |
|
|
|
{ |
|
|
|
pulseCount = 0; |
|
|
|
currentSeg.currentPart = 1; |
|
|
@@ -295,6 +302,12 @@ void TimCallBack(void *pArg) |
|
|
|
return; |
|
|
|
} |
|
|
|
currentSpeed -= currentSeg.dec; |
|
|
|
|
|
|
|
if (currentSpeed <= 1000) |
|
|
|
tim10.setPsc(&tim10, 2625 - 1); |
|
|
|
else |
|
|
|
tim10.setPsc(&tim10, 3 - 1); |
|
|
|
|
|
|
|
reloadValue = 168000000 / (TIM10->PSC + 1) / (currentSpeed); |
|
|
|
tim10.setPer(&tim10, reloadValue - 1); |
|
|
|
tim10.pwmSetPulse(&tim10, TIM10->ARR / 2 + 1); |
|
|
@@ -433,13 +446,13 @@ static void FirstSegmentProc(SEGMENT_PART *segmentPart) |
|
|
|
segmentPart->inc = segmentPart->inc - diffValue; |
|
|
|
} |
|
|
|
incAll += segmentPart->inc; |
|
|
|
if (plsr.segment[currentSegment].pulseFreq <= 5000) |
|
|
|
if (currentSpeed <= 1000) |
|
|
|
{ |
|
|
|
tim10.setPsc(&tim10, 2625 - 1); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
tim10.setPsc(&tim10, 168 - 1); |
|
|
|
tim10.setPsc(&tim10, 3 - 1); |
|
|
|
} |
|
|
|
if (currentSpeed != 0) |
|
|
|
tim10.setPer(&tim10, 168000000 / (TIM10->PSC + 1) / currentSpeed); |
|
|
|