Set mode of stepper.
This commit is contained in:
parent
373a0ef295
commit
261bfa219c
|
@ -50,7 +50,8 @@ void IteadDualStepperShield::_micro (uint8_t motor) {
|
||||||
void IteadDualStepperShield::_single (uint8_t motor) {
|
void IteadDualStepperShield::_single (uint8_t motor) {
|
||||||
uint8_t stepPin = motor == 0 ? _stepA : _stepB;
|
uint8_t stepPin = motor == 0 ? _stepA : _stepB;
|
||||||
uint32_t usStep = motor == 0 ? _usStepA : _usStepB;
|
uint32_t usStep = motor == 0 ? _usStepA : _usStepB;
|
||||||
for (uint8_t i = 0; i < _microsteps; i++) {
|
uint8_t mode = motor == 0 ? _modeA : _modeB;
|
||||||
|
for (uint8_t i = 0; i < mode; i++) {
|
||||||
digitalWrite(stepPin, HIGH);
|
digitalWrite(stepPin, HIGH);
|
||||||
delayMicroseconds(usStep);
|
delayMicroseconds(usStep);
|
||||||
digitalWrite(stepPin, LOW);
|
digitalWrite(stepPin, LOW);
|
||||||
|
|
|
@ -22,7 +22,9 @@
|
||||||
|
|
||||||
class IteadDualStepperShield {
|
class IteadDualStepperShield {
|
||||||
private:
|
private:
|
||||||
const uint8_t _microsteps = 8; //8 or 16
|
|
||||||
|
|
||||||
|
|
||||||
const uint8_t _directionA = 3;
|
const uint8_t _directionA = 3;
|
||||||
const uint8_t _directionB = 7;
|
const uint8_t _directionB = 7;
|
||||||
const uint8_t _stepA = 2;
|
const uint8_t _stepA = 2;
|
||||||
|
@ -33,14 +35,19 @@ class IteadDualStepperShield {
|
||||||
const uint8_t _settingsB1 = 8;
|
const uint8_t _settingsB1 = 8;
|
||||||
const uint8_t _settingsB2 = 9;
|
const uint8_t _settingsB2 = 9;
|
||||||
|
|
||||||
|
volatile uint32_t _usStepA = 300;
|
||||||
|
volatile uint32_t _usStepB = 300;
|
||||||
|
|
||||||
|
//const uint8_t _microsteps = 8; //8 or 16
|
||||||
|
volatile uint8_t _modeA = 1; //1, 2, 4, or 8
|
||||||
|
volatile uint8_t _modeB = 1;
|
||||||
|
|
||||||
void _single(uint8_t motor);
|
void _single(uint8_t motor);
|
||||||
void _micro(uint8_t motor);
|
void _micro(uint8_t motor);
|
||||||
void _both();
|
void _both();
|
||||||
|
|
||||||
uint32_t _usStepA = 300;
|
|
||||||
uint32_t _usStepB = 300;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
IteadDualStepperShield();
|
IteadDualStepperShield();
|
||||||
|
|
||||||
uint16_t revsteps = 200; // # steps per revolution
|
uint16_t revsteps = 200; // # steps per revolution
|
||||||
|
|
Loading…
Reference in New Issue