40 void uStepperDriver::reset(
void ){
64 this->pointer = _pointer;
65 this->chipSelect(
true);
73 this->enableStealth();
87 void uStepperDriver::readMotorStatus(
void)
95 this->VMAX = velocity;
97 if(this->VMAX > 0x7FFE00)
99 this->VMAX = 0x7FFE00;
107 this->AMAX = acceleration;
109 if(this->AMAX > 0xFFFE)
119 this->DMAX = deceleration;
121 if(this->DMAX > 0xFFFE)
131 this->current = current;
137 this->holdCurrent = current;
160 value |= (0x01 << 4);
162 value &= ~(0x01 << 4);
167 void uStepperDriver::setDirection(
bool direction )
208 void uStepperDriver::enableStealth()
257 pointer->pidPositionStepsIssued = 0;
264 TIMSK1 &= ~(1 << OCIE1A);
266 this->pointer->setSPIMode(3);
273 this->chipSelect(
false);
275 this->
status = this->pointer->SPI(address);
277 package |= this->pointer->SPI((datagram >> 24) & 0xff);
279 package |= this->pointer->SPI((datagram >> 16) & 0xff);
281 package |= this->pointer->SPI((datagram >> 8) & 0xff);
283 package |= this->pointer->SPI((datagram) & 0xff);
285 this->chipSelect(
true);
288 TIMSK1 |= (1 << OCIE1A);
296 TIMSK1 &= ~(1 << OCIE1A);
299 this->pointer->setSPIMode(3);
302 this->chipSelect(
false);
303 this->
status = this->pointer->SPI(address);
304 this->pointer->SPI(0x00);
305 this->pointer->SPI(0x00);
306 this->pointer->SPI(0x00);
307 this->pointer->SPI(0x00);
308 this->chipSelect(
true);
313 this->chipSelect(
false);
314 this->
status = this->pointer->SPI(address);
315 value |= this->pointer->SPI(0x00);
317 value |= this->pointer->SPI(0x00);
319 value |= this->pointer->SPI(0x00);
321 value |= this->pointer->SPI(0x00);
322 this->chipSelect(
true);
325 TIMSK1 |= (1 << OCIE1A);
330 void uStepperDriver::chipSelect(
bool state)
void setHoldCurrent(uint8_t current)
Set motor driver hold current.
int32_t readRegister(uint8_t address)
Reads a register from the motor driver.
void setRampMode(uint8_t mode)
Set motor driver to position mode or velocity mode.
void init(uStepperS *_pointer)
Initiation of the motor driver.
int32_t getVelocity(void)
Returns the current speed of the motor driver.
#define I_SCALE_ANALOG(n)
void setVelocity(uint32_t velocity)
Set motor velocity.
Prototype of class for accessing all features of the uStepper S in a single object.
#define VELOCITY_MODE_NEG
void setHome(void)
Resets the internal position counter of the motor driver.
void setPosition(int32_t position)
Set the motor position.
uStepperDriver(void)
Constructor.
void updateCurrent(void)
Writes the current setting registers of the motor driver.
#define VELOCITY_MODE_POS
void setCurrent(uint8_t current)
Set motor driver current.
int32_t getPosition(void)
Returns the current position of the motor driver.
void setShaftDirection(bool direction)
Set motor driver direction.
void stop(void)
Stops any ongoing movement with deceleration.
void setDeceleration(uint32_t deceleration)
Set motor deceleration.
Function prototypes and definitions for the uStepper S library.
void setAcceleration(uint32_t acceleration)
Set motor acceleration.
int32_t writeRegister(uint8_t address, uint32_t datagram)
Write a register of the motor driver.