Works really nice now. 20 usecs base period => 50 kHz, 25 kHz pulse freq.

This commit is contained in:
Hakan Bastedt
2024-04-07 21:45:53 +02:00
parent 544dd5ed85
commit ab1a306d86
2 changed files with 7 additions and 7 deletions

View File

@@ -146,7 +146,7 @@ private:
};
// For the example
#define BASE_PERIOD 40000
#define BASE_PERIOD 20000
#define SERVO_PERIOD 2000000
#define JOINT_X_STEPGEN_MAXACCEL 0.0
#define JOINT_Z_STEPGEN_MAXACCEL 0.0

View File

@@ -62,11 +62,11 @@ void syncWithLCNC()
deltaSyncTime = syncTime - prevSyncTime;
deltaMakePulsesCnt = makePulsesCnt - prevMakePulsesCnt;
prevMakePulsesCnt = makePulsesCnt;
Step->updateStepGen(pos_cmd1, pos_cmd2); // Update positions
Step->makeAllPulses(); // Make first step right here
basePeriodCnt = SERVO_PERIOD / BASE_PERIOD; //
baseTimer->refresh(); //
baseTimer->resume(); // Make the other steps in ISR
Step->updateStepGen(pos_cmd1, pos_cmd2); // Update positions
Step->makeAllPulses(); // Make first step right here
basePeriodCnt = SERVO_PERIOD / BASE_PERIOD; //
baseTimer->refresh(); //
baseTimer->resume(); // Make the other steps in ISR
// baseTimer->isRunning();
}
@@ -220,7 +220,7 @@ void setup(void)
baseTimer = new HardwareTimer(TIM11); // The base period timer
uint32_t usecs = BASE_PERIOD / sync0CycleTime;
// setFrequencyAdjustedMicrosSeconds(baseTimer, usecs);
baseTimer->setOverflow(35, MICROSEC_FORMAT);
baseTimer->setOverflow(BASE_PERIOD / 1000, MICROSEC_FORMAT);
baseTimer->attachInterrupt(basePeriodCB);
syncTimer = new HardwareTimer(TIM3); // The Linuxcnc servo period sync timer