SimpleFOClibrary 2.4.0
Loading...
Searching...
No Matches
StepperMotor.h
Go to the documentation of this file.
1/**
2 * @file StepperMotor.h
3 *
4 */
5
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
17/**
18 Stepper Motor class
19*/
21{
22 public:
23 /**
24 * StepperMotor 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 StepperMotor(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 StepperDriver class implementing all the hardware specific functions necessary PWM setting
37 */
39
40 /**
41 * StepperDriver link:
42 * - 4PWM - L298N for example
43 */
45
46
47 // Methods implementing the FOCMotor interface
48
49 /** Motor hardware init function */
50 int init() override;
51 /** Motor disable function */
52 void disable() override;
53 /** Motor enable function */
54 void enable() override;
55
56 /**
57 * Method using FOC to set Uq to the motor at the optimal angle
58 * Heart of the FOC algorithm
59 *
60 * @param Uq Current voltage in q axis to set to the motor
61 * @param Ud Current voltage in d axis to set to the motor
62 * @param angle_el current electrical angle of the motor
63 */
64 void setPhaseVoltage(float Uq, float Ud, float angle_el) override;
65
66 /**
67 * Method estimating the Back EMF voltage based
68 * based on the current velocity and KV rating
69 *
70 * @param velocity Current motor velocity
71 */
72 float estimateBEMF(float velocity) override;
73
74 // Methods overriding the FOCMotor default behavior
75
76 /**
77 * Measure resistance and inductance of a StepperMotor and print results to debug.
78 * If a sensor is available, an estimate of zero electric angle will be reported too.
79 * TODO: determine the correction factor
80 * @param voltage The voltage applied to the motor
81 * @returns 0 for success, >0 for failure
82 */
86
87};
88
89
90#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
int init() override
void disable() override
void linkDriver(StepperDriver *driver)
void enable() override
int characteriseMotor(float voltage)
void setPhaseVoltage(float Uq, float Ud, float angle_el) override
float estimateBEMF(float velocity) override
StepperDriver * driver
#define NOT_SET
Definition foc_utils.h:34