SimpleFOClibrary  2.1
StepperMotor.h
Go to the documentation of this file.
1 
6 #ifndef StepperMotor_h
7 #define StepperMotor_h
8 
9 #include "Arduino.h"
13 #include "common/foc_utils.h"
14 #include "common/time_utils.h"
15 #include "common/defaults.h"
16 
20 class StepperMotor: public FOCMotor
21 {
22  public:
28  StepperMotor(int pp, float R = NOT_SET);
29 
36 
42 
44  void init() override;
46  void disable() override;
48  void enable() override;
49 
60  int initFOC( float zero_electric_offset = NOT_SET , Direction sensor_direction = Direction::CW) override;
67  void loopFOC() override;
76  void move(float target = NOT_SET) override;
77 
78  float Ualpha,Ubeta;
79 
80  private:
81 
82  // FOC methods
91  void setPhaseVoltage(float Uq, float Ud , float angle_el);
92 
94  int alignSensor();
96  int absoluteZeroSearch();
97 
98  // Open loop motion control
105  float velocityOpenloop(float target_velocity);
112  float angleOpenloop(float target_angle);
113  // open loop variables
114  long open_loop_timestamp;
115 };
116 
117 
118 #endif
FOCMotor.h
StepperMotor::StepperMotor
StepperMotor(int pp, float R=NOT_SET)
Definition: StepperMotor.cpp:6
StepperMotor::initFOC
int initFOC(float zero_electric_offset=NOT_SET, Direction sensor_direction=Direction::CW) override
Definition: StepperMotor.cpp:85
CW
@ CW
Definition: Sensor.h:8
FOCMotor
Definition: FOCMotor.h:58
NOT_SET
#define NOT_SET
Definition: foc_utils.h:27
StepperDriver
Definition: StepperDriver.h:4
defaults.h
StepperMotor::init
void init() override
Definition: StepperMotor.cpp:27
Sensor.h
foc_utils.h
StepperMotor::Ubeta
float Ubeta
Phase voltages U alpha and U beta used for inverse Park and Clarke transform.
Definition: StepperMotor.h:78
StepperMotor::linkDriver
void linkDriver(StepperDriver *driver)
Definition: StepperMotor.cpp:22
StepperMotor::loopFOC
void loopFOC() override
Definition: StepperMotor.cpp:215
FOCMotor::target
float target
current target value - depends of the controller
Definition: FOCMotor.h:131
FOCMotor::sensor_direction
int sensor_direction
if sensor_direction == Direction::CCW then direction will be flipped to CW
Definition: FOCMotor.h:181
StepperMotor::disable
void disable() override
Definition: StepperMotor.cpp:60
StepperDriver.h
StepperMotor::Ualpha
float Ualpha
Definition: StepperMotor.h:78
StepperMotor
Definition: StepperMotor.h:21
StepperMotor::move
void move(float target=NOT_SET) override
Definition: StepperMotor.cpp:234
StepperMotor::driver
StepperDriver * driver
Definition: StepperMotor.h:41
time_utils.h
Direction
Direction
Definition: Sensor.h:7
StepperMotor::enable
void enable() override
Definition: StepperMotor.cpp:70