SimpleFOClibrary 2.4.0
Loading...
Searching...
No Matches
HybridStepperMotor.h
Go to the documentation of this file.
1/**
2 * @file HybridStepperMotor.h
3 *
4 */
5
6#ifndef HybridStepperMotor_h
7#define HybridStepperMotor_h
8
9#include "Arduino.h"
13#include "common/foc_utils.h"
14#include "common/time_utils.h"
15#include "common/defaults.h"
16
17/**
18 Stepper Motor class
19*/
21{
22public:
23 /**
24 * HybridStepperMotor class constructor
25 * @param pp pole pair number
26 * @param R motor phase resistance - [Ohm]
27 * @param KV motor KV rating (1/K_bemf) - rpm/V
28 * @param Lq motor q-axis inductance - [H]
29 * @param Ld motor d-axis inductance - [H]
30 */
31 HybridStepperMotor(int pp, float R = NOT_SET, float KV = NOT_SET, float L_q = NOT_SET, float L_d = NOT_SET);
32
33 /**
34 * Function linking a motor and a foc driver
35 *
36 * @param driver BLDCDriver handle for hardware peripheral control
37 */
39
40 BLDCDriver* driver; //!< BLDCDriver instance
41
42 float Ua, Ub, Uc; //!< Phase voltages used for inverse Park and Clarke transform
43
44 // Methods implementing the FOCMotor interface
45
46 /** Motor hardware init function */
47 int init() override;
48 /** Motor disable function */
49 void disable() override;
50 /** Motor enable function */
51 void enable() override;
52
53 /**
54 * Method using FOC to set Uq to the motor at the optimal angle
55 * Heart of the FOC algorithm
56 *
57 * @param Uq Current voltage in q axis to set to the motor
58 * @param Ud Current voltage in d axis to set to the motor
59 * @param angle_el current electrical angle of the motor
60 */
61 void setPhaseVoltage(float Uq, float Ud, float angle_el) override;
62
63 /**
64 * Method estimating the Back EMF voltage based
65 * based on the current velocity and KV rating
66 *
67 * @param velocity Current motor velocity
68 */
69 float estimateBEMF(float velocity) override;
70
71
72 // Methods overriding the FOCMotor default behavior
73
74 /**
75 * Measure resistance and inductance of a HybridStepperMotor and print results to debug.
76 * If a sensor is available, an estimate of zero electric angle will be reported too.
77 * TODO: determine the correction factor
78 * @param voltage The voltage applied to the motor
79 * @returns 0 for success, >0 for failure
80 */
82 // correction factor is not correct here,
83 // we need to add the driver reistance to compensate for the voltage drop on it, but it is a good starting point for now
85 };
86
87 /**
88 * Link the currentsense
89 */
91
92
93};
94
95#endif
@ velocity
Velocity motion control.
Definition FOCMotor.h:51
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
CurrentSense * current_sense
Definition FOCMotor.h:302
void setPhaseVoltage(float Uq, float Ud, float angle_el) override
void linkDriver(BLDCDriver *driver)
float estimateBEMF(float velocity) override
BLDCDriver * driver
BLDCDriver instance.
float Uc
Phase voltages used for inverse Park and Clarke transform.
int characteriseMotor(float voltage)
void linkCurrentSense(CurrentSense *current_sense)
#define NOT_SET
Definition foc_utils.h:34