SimpleFOClibrary 2.4.0
Loading...
Searching...
No Matches
BLDCMotor.h
Go to the documentation of this file.
1#ifndef BLDCMotor_h
2#define BLDCMotor_h
3
4#include "Arduino.h"
9#include "common/foc_utils.h"
10#include "common/time_utils.h"
11#include "common/defaults.h"
12
13/**
14 BLDC motor class
15*/
16class BLDCMotor: public FOCMotor
17{
18 public:
19 /**
20 BLDCMotor class constructor
21 @param pp pole pairs number
22 @param R motor phase resistance - [Ohm]
23 @param KV motor KV rating (1/K_bemf) - rpm/V
24 @param Lq motor q-axis inductance - [H]
25 @param Ld motor d-axis inductance - [H]
26 */
27 BLDCMotor(int pp, float R = NOT_SET, float KV = NOT_SET, float L_q = NOT_SET, float L_d = NOT_SET);
28
29 /**
30 * Function linking a motor and a foc driver
31 *
32 * @param driver BLDCDriver class implementing all the hardware specific functions necessary PWM setting
33 */
34 virtual void linkDriver(BLDCDriver* driver);
35
36
37 float Ua, Ub, Uc;//!< Current phase voltages Ua,Ub and Uc set to motor
38
39 BLDCDriver* driver; //!< BLDCDriver instance
40 // Methods implementing the FOCMotor interface
41
42 /** Motor hardware init function */
43 int init() override;
44 /** Motor disable function */
45 void disable() override;
46 /** Motor enable function */
47 void enable() override;
48
49 /**
50 * Method using FOC to set Uq to the motor at the optimal angle
51 * Heart of the FOC algorithm
52 *
53 * @param Uq Current voltage in q axis to set to the motor
54 * @param Ud Current voltage in d axis to set to the motor
55 * @param angle_el current electrical angle of the motor
56 */
57 void setPhaseVoltage(float Uq, float Ud, float angle_el) override;
58
59 /**
60 * Method estimating the Back EMF voltage based
61 * based on the current velocity and KV rating
62 *
63 * @param velocity Current motor velocity
64 */
65 float estimateBEMF(float velocity) override;
66
67
68 // Methods overriding the FOCMotor default behavior
69
70 /**
71 * Measure resistance and inductance of a BLDCMotor and print results to debug.
72 * If a sensor is available, an estimate of zero electric angle will be reported too.
73 * @param voltage The voltage applied to the motor
74 * @returns 0 for success, >0 for failure
75 */
79
80
81};
82
83
84#endif
@ velocity
Velocity motion control.
Definition FOCMotor.h:51
void disable() override
void setPhaseVoltage(float Uq, float Ud, float angle_el) override
float Ub
Definition BLDCMotor.h:37
BLDCDriver * driver
BLDCDriver instance.
Definition BLDCMotor.h:39
int init() override
Definition BLDCMotor.cpp:66
float Ua
Definition BLDCMotor.h:37
void enable() override
virtual void linkDriver(BLDCDriver *driver)
Definition BLDCMotor.cpp:61
float Uc
Current phase voltages Ua,Ub and Uc set to motor.
Definition BLDCMotor.h:37
int characteriseMotor(float voltage)
Definition BLDCMotor.h:76
float estimateBEMF(float velocity) override
int characteriseMotor(float voltage, float correction_factor)
Definition FOCMotor.cpp:96
DQVoltage_s voltage
current d and q voltage set to the motor
Definition FOCMotor.h:218
#define NOT_SET
Definition foc_utils.h:34