RF-Positioning-System V0.1
by Max Heinekamp
Loading...
Searching...
No Matches
stepper.h
Go to the documentation of this file.
1
11
12#include "TMCStepper.h"
13#include "config.h"
14
20class STEPPER{
21 public:
22
30 STEPPER(int address, int step_pin, int enable_pin);
31
36 void setup();
37
42 void step();
43
49 void SetDirection(bool dir);
50
56 bool GetDirection();
57
62 void updateRMSCurrent();
63
68 void updateHoldCurrent();
69
75 uint16_t getRMSCurrent();
76
82 uint8_t getHoldCurrent();
83
88 void updateMicrosteps();
89
99 void move(float targetSpeed, float acceleration, float position, int steps_revolution);
100
112 void move(float targetSpeed, float acceleration, float position, int steps_revolution, STEPPER* stepper2, int stepper2_ratio);
113
123 void absoluteMove(float targetSpeed, float acceleration, float angle, int steps_revolution);
124
136 void absoluteMove(float targetSpeed, float acceleration, float angle, int steps_revolution, STEPPER* stepper2, int stepper2_ratio);
137
145 void runStepperSCurve(float targetSpeed, float maxJerk, int distance);
146
153 return current_position;
154 }
155
156 int Debug();
157
158 private:
163 TMC2209Stepper stepper;
164
171
176
182
183
189
195
206 float steps_remainder = 0; // Fractional step that needs to be carried over to the next move.
207
208};
209
float getCurrentPosition()
Get the current position of the motor in degrees.
Definition stepper.h:152
int enable_pin
Pin that is connected to the enable pin of the driver.
Definition stepper.h:188
uint8_t getHoldCurrent()
Get the actual hold current currently applied by the stepper driver.
Definition stepper.cpp:78
STEPPER(int address, int step_pin, int enable_pin)
Construct a new STEPPER object.
Definition stepper.cpp:18
void setup()
Set up the stepper driver and configure it.
Definition stepper.cpp:26
void move(float targetSpeed, float acceleration, float position, int steps_revolution)
Move the motor a given angle with a given acceleration and distance.
Definition stepper.cpp:87
void updateHoldCurrent()
Update the hold current of the stepper driver from the current flash value.
Definition stepper.cpp:69
int address
SPI address of the stepper driver.
Definition stepper.h:175
void updateRMSCurrent()
Update the RMS current of the stepper driver from the current flash value.
Definition stepper.cpp:63
void updateMicrosteps()
Update the microsteps of the stepper driver from the current flash value.
Definition stepper.cpp:82
float current_position
This stores the current position of the motor in degrees.
Definition stepper.h:194
float steps_remainder
This stores the fractional step that needs to be carried over to the next move.
Definition stepper.h:206
int step_pin
Pin that is connected to the step pin of the driver.
Definition stepper.h:181
void step()
Step the motor one step.
Definition stepper.cpp:48
TMC2209Stepper stepper
Stepper driver object. This is the object that interfaces with the stepper driver library.
Definition stepper.h:163
uint16_t getRMSCurrent()
Get the actual RMS current currently applied by the stepper driver.
Definition stepper.cpp:74
void SetDirection(bool dir)
Set the direction of the stepper motor.
Definition stepper.cpp:54
bool GetDirection()
Get the current direction of the stepper motor.
Definition stepper.cpp:59
void runStepperSCurve(float targetSpeed, float maxJerk, int distance)
Run the stepper motor using an S-curve profile.
Definition stepper.cpp:327
void absoluteMove(float targetSpeed, float acceleration, float angle, int steps_revolution)
Move the motor to a target location based on an absolute angle with a given speed and acceleration.
Definition stepper.cpp:269
bool direction
Direction of the motor. This is used to set the direction of the motor.
Definition stepper.h:170
Configuration file for the entire project.