configurable stepper pulse

This commit is contained in:
rusefi 2017-06-12 18:31:55 -04:00
parent 4e91b721c3
commit 0893e50949
2 changed files with 6 additions and 4 deletions

View File

@ -788,6 +788,7 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
engineConfiguration->useOnlyRisingEdgeForTrigger = false;
boardConfiguration->idleStepperPulseDuration = 10;
boardConfiguration->idle.solenoidFrequency = 200;
// set idle_position 50
boardConfiguration->manIdlePosition = 50;

View File

@ -9,8 +9,9 @@
#include "stepper.h"
#include "pin_repository.h"
#include "engine.h"
#define ST_DELAY_MS 10
EXTERN_ENGINE;
static msg_t stThread(StepperMotor *motor) {
chRegSetThreadName("stepper");
@ -32,7 +33,7 @@ static msg_t stThread(StepperMotor *motor) {
int currentPosition = motor->currentPosition;
if (targetPosition == currentPosition) {
chThdSleepMilliseconds(ST_DELAY_MS);
chThdSleepMilliseconds(boardConfiguration->idleStepperPulseDuration);
continue;
}
bool isIncrementing = targetPosition > currentPosition;
@ -78,9 +79,9 @@ void StepperMotor::pulse() {
palWritePad(enablePort, enablePin, false); // ebable stepper
palWritePad(stepPort, stepPin, true);
chThdSleepMilliseconds(ST_DELAY_MS);
chThdSleepMilliseconds(boardConfiguration->idleStepperPulseDuration);
palWritePad(stepPort, stepPin, false);
chThdSleepMilliseconds(ST_DELAY_MS);
chThdSleepMilliseconds(boardConfiguration->idleStepperPulseDuration);
palWritePad(enablePort, enablePin, true); // disable stepper
}