SimpleFOClibrary
2.1
foc_utils.h
Go to the documentation of this file.
1
#ifndef FOCUTILS_LIB_H
2
#define FOCUTILS_LIB_H
3
4
#include "Arduino.h"
5
6
// sign function
7
#define _sign(a) ( ( (a) < 0 ) ? -1 : ( (a) > 0 ) )
8
#define _round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
9
#define _constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
10
#define _sqrt(a) (_sqrtApprox(a))
11
#define _isset(a) ( (a) != (NOT_SET) )
12
13
// utility defines
14
#define _2_SQRT3 1.15470053838
15
#define _SQRT3 1.73205080757
16
#define _1_SQRT3 0.57735026919
17
#define _SQRT3_2 0.86602540378
18
#define _SQRT2 1.41421356237
19
#define _120_D2R 2.09439510239
20
#define _PI 3.14159265359
21
#define _PI_2 1.57079632679
22
#define _PI_3 1.0471975512
23
#define _2PI 6.28318530718
24
#define _3PI_2 4.71238898038
25
#define _PI_6 0.52359877559
26
27
#define NOT_SET -12345.0
28
#define _HIGH_IMPEDANCE 0
29
#define _HIGH_Z _HIGH_IMPEDANCE
30
#define _ACTIVE 1
31
32
// dq current structure
33
struct
DQCurrent_s
34
{
35
float
d
;
36
float
q
;
37
};
38
// phase current structure
39
struct
PhaseCurrent_s
40
{
41
float
a
;
42
float
b
;
43
float
c
;
44
};
45
// dq voltage structs
46
struct
DQVoltage_s
47
{
48
float
d
;
49
float
q
;
50
};
51
52
59
float
_sin
(
float
a);
66
float
_cos
(
float
a);
67
72
float
_normalizeAngle
(
float
angle
);
73
74
81
float
_electricalAngle
(
float
shaft_angle,
int
pole_pairs);
82
89
float
_sqrtApprox
(
float
value);
90
91
#endif
angle
@ angle
Position/angle motion control.
Definition:
FOCMotor.h:30
DQCurrent_s
Definition:
foc_utils.h:34
DQVoltage_s::d
float d
Definition:
foc_utils.h:48
_sqrtApprox
float _sqrtApprox(float value)
Definition:
foc_utils.cpp:60
_sin
float _sin(float a)
Definition:
foc_utils.cpp:14
DQCurrent_s::q
float q
Definition:
foc_utils.h:36
DQCurrent_s::d
float d
Definition:
foc_utils.h:35
DQVoltage_s
Definition:
foc_utils.h:47
_electricalAngle
float _electricalAngle(float shaft_angle, int pole_pairs)
Definition:
foc_utils.cpp:53
PhaseCurrent_s
Definition:
foc_utils.h:40
PhaseCurrent_s::b
float b
Definition:
foc_utils.h:42
_cos
float _cos(float a)
Definition:
foc_utils.cpp:39
PhaseCurrent_s::a
float a
Definition:
foc_utils.h:41
DQVoltage_s::q
float q
Definition:
foc_utils.h:49
_normalizeAngle
float _normalizeAngle(float angle)
Definition:
foc_utils.cpp:47
PhaseCurrent_s::c
float c
Definition:
foc_utils.h:43
Arduino
libraries
Arduino-FOC
src
common
foc_utils.h
Generated by
1.8.18