AccelStepper::AccelStepper(uint8_t interface, uint8_t pin1, uint8_t pin2, uint8_t pin3, uint8_t pin4, bool enable) { _interface = interface; _currentPos = 0; _targetPos = 0; _speed = 0.0; _maxSpeed = 1.0; _acceleration = 0.0; _sqrt_twoa = 1.0; _stepInterval = 0; _minPulseWidth = 1; _enablePin = 0xff; _lastStepTime = 0; _pin[0] = pin1; _pin[1] = pin2; _pin[2] = pin3; _pin[3] = pin4; // NEW _n = 0; _c0 = 0.0; _cn = 0.0; _cmin = 1.0; _direction = DIRECTION_CCW; int i; for (i = 0; i < 4; i++) _pinInverted[i] = 0; if (enable) enableOutputs(); // Some reasonable default setAcceleration(1); }
AsyncDriver::AsyncDriver(uint8_t pin1, uint8_t pin2, uint8_t newDisablePin ){ init(); _pin[0] = pin1; _pin[1] = pin2; disablePin = newDisablePin; pinMode(_pin[0], OUTPUT); pinMode(_pin[1], OUTPUT); enableOutputs(); if (disablePin != 0xff){ pinMode(disablePin, OUTPUT); fastWrite(disablePin, true ); } }
void AsyncDriver::moveTo(long absolute){ uint8_t oldSREG = SREG; noInterrupts(); if ( _targetPos == absolute ){ if( _targetPos ==_currentPos){ onReady(); } }else{ if( disable_on_ready && is_disabled ){ enableOutputs(); } _targetPos = absolute; computeNewSpeed(true); } SREG = oldSREG; }
AccelStepper::AccelStepper(uint8_t pins, uint8_t pin1, uint8_t pin2, uint8_t pin3, uint8_t pin4) { _pins = pins; _currentPos = 0; _targetPos = 0; _speed = 0.0; _maxSpeed = 1.0; _acceleration = 1.0; _stepInterval = 0; _lastStepTime = 0; _pin1 = pin1; _pin2 = pin2; _pin3 = pin3; _pin4 = pin4; enableOutputs(); }
void InitStepper(Stepper_t* motor, uint8_t interface, uint16_t pin1, GPIO_TypeDef* GPIOxPin1, uint16_t pin2, GPIO_TypeDef* GPIOxPin2, uint16_t pin3, GPIO_TypeDef* GPIOxPin3, uint16_t pin4, GPIO_TypeDef* GPIOxPin4, uint8_t enable) { motor->_interface = interface; motor->_currentPos = 0; motor->_targetPos = 0; motor->_speed = 0.0; motor->_maxSpeed = 1.0; motor->_acceleration = 0.0; motor->_sqrt_twoa = 1.0; motor->_stepInterval = 0; motor->_minPulseWidth = 1; motor->_enablePin = 0xff; motor->_GPIOxEnablePin = NULL; motor->_lastStepTime = 0; motor->_pin[0] = pin1; motor->_GPIOxPin[0] = GPIOxPin1; motor->_pin[1] = pin2; motor->_GPIOxPin[1] = GPIOxPin2; motor->_pin[2] = pin3; motor->_GPIOxPin[2] = GPIOxPin3; motor->_pin[3] = pin4; motor->_GPIOxPin[3] = GPIOxPin4; // NEW motor->_n = 0; motor->_c0 = 0.0; motor->_cn = 0.0; motor->_cmin = 1.0; motor->_direction = DIRECTION_CCW; int i; for (i = 0; i < 4; i++) motor->_pinInverted[i] = 0; if (enable) enableOutputs(motor); // Some reasonable default setAcceleration(motor, 1); }
AccelStepper::AccelStepper(uint8_t interface, uint8_t pin1, uint8_t pin2, uint8_t pin3, uint8_t pin4) { _interface = interface; _currentPos = 0; _targetPos = 0; _speed = 0.0; _maxSpeed = 1.0; _acceleration = 1.0; _sqrt_twoa = 1.0; _stepInterval = 0; _minPulseWidth = 1; _enablePin = 0xff; _lastStepTime = 0; _pin[0] = pin1; _pin[1] = pin2; _pin[2] = pin3; _pin[3] = pin4; int i; for (i = 0; i < 4; i++) _pinInverted[i] = 0; enableOutputs(); }
AccelStepper::AccelStepper(uint8_t pins, uint8_t pin1, uint8_t pin2, uint8_t pin3, uint8_t pin4) { _pins = pins; _currentPos = 0; _targetPos = 0; _speed = 0.0; _maxSpeed = 1.0; _acceleration = 1.0; _stepInterval = 0; // _lastRunTime = 0; _minPulseWidth = 1; _lastStepTime = 0; _pin1 = pin1; _pin2 = pin2; _pin3 = pin3; _pin4 = pin4; //_stepInterval = 20000; //_speed = 50.0; //_lastRunTime = 0xffffffff - 20000; //_lastStepTime = 0xffffffff - 20000 - 10000; enableOutputs(); }