configurable stepper pulse
This commit is contained in:
parent
4e91b721c3
commit
0893e50949
|
@ -788,6 +788,7 @@ void setDefaultConfiguration(DECLARE_ENGINE_PARAMETER_SIGNATURE) {
|
||||||
|
|
||||||
engineConfiguration->useOnlyRisingEdgeForTrigger = false;
|
engineConfiguration->useOnlyRisingEdgeForTrigger = false;
|
||||||
|
|
||||||
|
boardConfiguration->idleStepperPulseDuration = 10;
|
||||||
boardConfiguration->idle.solenoidFrequency = 200;
|
boardConfiguration->idle.solenoidFrequency = 200;
|
||||||
// set idle_position 50
|
// set idle_position 50
|
||||||
boardConfiguration->manIdlePosition = 50;
|
boardConfiguration->manIdlePosition = 50;
|
||||||
|
|
|
@ -9,8 +9,9 @@
|
||||||
|
|
||||||
#include "stepper.h"
|
#include "stepper.h"
|
||||||
#include "pin_repository.h"
|
#include "pin_repository.h"
|
||||||
|
#include "engine.h"
|
||||||
|
|
||||||
#define ST_DELAY_MS 10
|
EXTERN_ENGINE;
|
||||||
|
|
||||||
static msg_t stThread(StepperMotor *motor) {
|
static msg_t stThread(StepperMotor *motor) {
|
||||||
chRegSetThreadName("stepper");
|
chRegSetThreadName("stepper");
|
||||||
|
@ -32,7 +33,7 @@ static msg_t stThread(StepperMotor *motor) {
|
||||||
int currentPosition = motor->currentPosition;
|
int currentPosition = motor->currentPosition;
|
||||||
|
|
||||||
if (targetPosition == currentPosition) {
|
if (targetPosition == currentPosition) {
|
||||||
chThdSleepMilliseconds(ST_DELAY_MS);
|
chThdSleepMilliseconds(boardConfiguration->idleStepperPulseDuration);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bool isIncrementing = targetPosition > currentPosition;
|
bool isIncrementing = targetPosition > currentPosition;
|
||||||
|
@ -78,9 +79,9 @@ void StepperMotor::pulse() {
|
||||||
palWritePad(enablePort, enablePin, false); // ebable stepper
|
palWritePad(enablePort, enablePin, false); // ebable stepper
|
||||||
|
|
||||||
palWritePad(stepPort, stepPin, true);
|
palWritePad(stepPort, stepPin, true);
|
||||||
chThdSleepMilliseconds(ST_DELAY_MS);
|
chThdSleepMilliseconds(boardConfiguration->idleStepperPulseDuration);
|
||||||
palWritePad(stepPort, stepPin, false);
|
palWritePad(stepPort, stepPin, false);
|
||||||
chThdSleepMilliseconds(ST_DELAY_MS);
|
chThdSleepMilliseconds(boardConfiguration->idleStepperPulseDuration);
|
||||||
|
|
||||||
palWritePad(enablePort, enablePin, true); // disable stepper
|
palWritePad(enablePort, enablePin, true); // disable stepper
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue