Go to the documentation of this file.
73 this->pointer = _pointer;
104 while(TCNT1 > 15900);
110 this->
VMAX = velocity;
112 if(this->
VMAX > 0x7FFE00)
114 this->
VMAX = 0x7FFE00;
122 this->
AMAX = acceleration;
124 if(this->
AMAX > 0xFFFE)
134 this->
DMAX = deceleration;
136 if(this->
DMAX > 0xFFFE)
175 value |= (0x01 << 4);
177 value &= ~(0x01 << 4);
241 if (value & 0x00800000)
268 this->xTarget =
xTarget + initialSteps;
269 this->xActual = initialSteps;
275 this->xTarget = initialSteps;
276 this->xActual = initialSteps;
288 TIMSK1 &= ~(1 << OCIE1A);
292 uint32_t
package = 0;
299 this->
status = this->pointer->
SPI(address);
301 package |= this->pointer->SPI((datagram >> 24) & 0xff);
303 package |= this->pointer->SPI((datagram >> 16) & 0xff);
305 package |= this->pointer->SPI((datagram >> 8) & 0xff);
307 package |= this->pointer->SPI((datagram) & 0xff);
312 TIMSK1 |= (1 << OCIE1A);
320 TIMSK1 &= ~(1 << OCIE1A);
327 this->
status = this->pointer->
SPI(address);
328 this->pointer->
SPI(0x00);
329 this->pointer->
SPI(0x00);
330 this->pointer->
SPI(0x00);
331 this->pointer->
SPI(0x00);
338 this->
status = this->pointer->
SPI(address);
339 value |= this->pointer->
SPI(0x00);
341 value |= this->pointer->
SPI(0x00);
343 value |= this->pointer->
SPI(0x00);
345 value |= this->pointer->
SPI(0x00);
349 TIMSK1 |= (1 << OCIE1A);
367 else if( threshold < -64)
386 stall_speed = stall_speed * 1.2;
Prototype of class for accessing all features of the uStepper S in a single object.
void init(uStepperS *_pointer)
Initiation of the motor driver.
void disableStallguard(void)
#define VELOCITY_MODE_NEG
void setAcceleration(uint32_t acceleration)
Set motor acceleration.
int32_t readRegister(uint8_t address)
Reads a register from the motor driver.
void readMotorStatus(void)
int32_t getVelocity(void)
Returns the current speed of the motor driver.
void setVelocity(uint32_t velocity)
Set motor velocity.
void setSPIMode(uint8_t mode)
void setHome(int32_t initialSteps=0)
Resets the internal position counter of the motor driver.
void updateCurrent(void)
Writes the current setting registers of the motor driver
void chipSelect(bool state)
void setCurrent(uint8_t current)
Set motor driver current.
void setPosition(int32_t position)
Set the motor position.
int32_t getPosition(void)
Returns the current position of the motor driver.
uStepperDriver(void)
Constructor.
void enableStallguard(int8_t threshold, bool stopOnStall, float rpm)
uint16_t getStallValue(void)
Returns the load measurement used for Stall detection.
void stop(void)
Stops any ongoing movement with deceleration.
uint8_t SPI(uint8_t data)
void setDirection(bool direction)
volatile int32_t pidPositionStepsIssued
#define VELOCITY_MODE_POS
void setShaftDirection(bool direction)
Set motor driver direction.
void setHoldCurrent(uint8_t current)
Set motor driver hold current.
void setDeceleration(uint32_t deceleration)
Set motor deceleration.
#define I_SCALE_ANALOG(n)
void setRampMode(uint8_t mode)
Set motor driver to position mode or velocity mode.
int32_t writeRegister(uint8_t address, uint32_t datagram)
Write a register of the motor driver.