Go to the documentation of this file.
71 this->pointer = _pointer;
102 while(TCNT1 > 15900);
108 this->
VMAX = velocity;
110 if(this->
VMAX > 0x7FFE00)
112 this->
VMAX = 0x7FFE00;
120 this->
AMAX = acceleration;
122 if(this->
AMAX > 0xFFFE)
132 this->
DMAX = deceleration;
134 if(this->
DMAX > 0xFFFE)
173 value |= (0x01 << 4);
175 value &= ~(0x01 << 4);
259 this->xTarget =
xTarget + initialSteps;
260 this->xActual = initialSteps;
266 this->xTarget = initialSteps;
267 this->xActual = initialSteps;
279 TIMSK1 &= ~(1 << OCIE1A);
283 uint32_t
package = 0;
290 this->
status = this->pointer->
SPI(address);
292 package |= this->pointer->SPI((datagram >> 24) & 0xff);
294 package |= this->pointer->SPI((datagram >> 16) & 0xff);
296 package |= this->pointer->SPI((datagram >> 8) & 0xff);
298 package |= this->pointer->SPI((datagram) & 0xff);
303 TIMSK1 |= (1 << OCIE1A);
311 TIMSK1 &= ~(1 << OCIE1A);
318 this->
status = this->pointer->
SPI(address);
319 this->pointer->
SPI(0x00);
320 this->pointer->
SPI(0x00);
321 this->pointer->
SPI(0x00);
322 this->pointer->
SPI(0x00);
329 this->
status = this->pointer->
SPI(address);
330 value |= this->pointer->
SPI(0x00);
332 value |= this->pointer->
SPI(0x00);
334 value |= this->pointer->
SPI(0x00);
336 value |= this->pointer->
SPI(0x00);
340 TIMSK1 |= (1 << OCIE1A);
358 else if( threshold < -64)
369 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.
void enableStallguard(int8_t threshold, bool stopOnStall)
int32_t getPosition(void)
Returns the current position of the motor driver.
uStepperDriver(void)
Constructor.
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.