SimpleFOClibrary  2.1
BLDCMotor.h
Go to the documentation of this file.
1 #ifndef BLDCMotor_h
2 #define BLDCMotor_h
3 
4 #include "Arduino.h"
8 #include "common/foc_utils.h"
9 #include "common/time_utils.h"
10 #include "common/defaults.h"
11 
15 class BLDCMotor: public FOCMotor
16 {
17  public:
23  BLDCMotor(int pp, float R = NOT_SET);
24 
31 
38 
40  void init() override;
42  void disable() override;
44  void enable() override;
45 
50  int initFOC( float zero_electric_offset = NOT_SET , Direction sensor_direction = Direction::CW) override;
57  void loopFOC() override;
58 
67  void move(float target = NOT_SET) override;
68 
69  float Ua, Ub, Uc;
70  float Ualpha, Ubeta;
71 
72 
73  private:
74  // FOC methods
83  void setPhaseVoltage(float Uq, float Ud, float angle_el);
85  int alignSensor();
87  int alignCurrentSense();
89  int absoluteZeroSearch();
90 
91 
92  // Open loop motion control
99  float velocityOpenloop(float target_velocity);
106  float angleOpenloop(float target_angle);
107  // open loop variables
108  long open_loop_timestamp;
109 };
110 
111 
112 #endif
FOCMotor.h
CW
@ CW
Definition: Sensor.h:8
FOCMotor
Definition: FOCMotor.h:58
BLDCDriver
Definition: BLDCDriver.h:6
NOT_SET
#define NOT_SET
Definition: foc_utils.h:27
defaults.h
BLDCMotor::disable
void disable() override
Definition: BLDCMotor.cpp:61
BLDCMotor::Ua
float Ua
Definition: BLDCMotor.h:69
BLDCMotor::Ubeta
float Ubeta
Phase voltages U alpha and U beta used for inverse Park and Clarke transform.
Definition: BLDCMotor.h:70
Sensor.h
foc_utils.h
BLDCMotor::initFOC
int initFOC(float zero_electric_offset=NOT_SET, Direction sensor_direction=Direction::CW) override
Definition: BLDCMotor.cpp:85
BLDCMotor::enable
void enable() override
Definition: BLDCMotor.cpp:71
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
BLDCMotor::loopFOC
void loopFOC() override
Definition: BLDCMotor.cpp:244
BLDCMotor::Ub
float Ub
Definition: BLDCMotor.h:69
BLDCMotor
Definition: BLDCMotor.h:16
BLDCDriver.h
BLDCMotor::move
void move(float target=NOT_SET) override
Definition: BLDCMotor.cpp:295
time_utils.h
BLDCMotor::driver
BLDCDriver * driver
Definition: BLDCMotor.h:37
BLDCMotor::init
void init() override
Definition: BLDCMotor.cpp:26
Direction
Direction
Definition: Sensor.h:7
BLDCMotor::BLDCMotor
BLDCMotor(int pp, float R=NOT_SET)
Definition: BLDCMotor.cpp:6
BLDCMotor::linkDriver
void linkDriver(BLDCDriver *driver)
Definition: BLDCMotor.cpp:21
BLDCMotor::Ualpha
float Ualpha
Definition: BLDCMotor.h:70
BLDCMotor::Uc
float Uc
Current phase voltages Ua,Ub and Uc set to motor.
Definition: BLDCMotor.h:69