BLDC control on ATAVRMC303 with ATxMega128A1
config_motor.h
Go to the documentation of this file.
1
11
//_____ I N C L U D E S ___________________________________________________
12
13
14
15
#ifndef _CONFIG_MOTOR_H_
16
#define _CONFIG_MOTOR_H_
17
23
enum
{
HS_001
=1,
HS_010
=2,
HS_011
=3,
HS_100
=4,
HS_101
=5,
HS_110
=6};
24
25
29
enum
{
RUN
= TRUE,
STOP
= FALSE};
30
34
enum
{
CCW
= TRUE,
CW
= FALSE};
35
36
// Define Type of Pulse Width Modulation
37
//#define HIGH_AND_LOW_PWM // it doesn't run with AT90PWM3B in centered mode
38
// AT90PWM3B: for high and low pwm (fast decay mode),
39
// please use 1,2 or 4 ramps mode and adjust ADC synchro
40
41
// Define type of speed measure and number of samples
42
//#define AVERAGE_SPEED_MEASURE
43
#define n_SAMPLE 8
44
45
// Define macro for motor control
46
#define OPEN_LOOP 0
47
#define SPEED_LOOP 1
48
#define CURRENT_LOOP 2
49
50
// Here you have to define your control coefficients
51
// Kp for the proportionnal coef
52
// Ki for the integral coef
53
// Kd for the derivative coef
54
55
// Speed regulation coefficients
56
#define Kp_speed 6//1 MMT motor//8 MAXON moto
57
#define Ki_speed 4//10 MMT motor//8 MAXON motor
58
#define Kd_speed 0
59
60
// Current regulation coefficients
61
#define Kp_cur 1
62
#define Ki_cur 3
63
#define Kd_cur 0
64
65
// Position regulation coefficients
66
#define Kp_pos 9 //8
67
#define Ki_pos 3 //1
68
#define Kd_pos 20 //5
69
70
// All PID coef are multiplied by 2^Kmul
71
// For exemple : kp = 1 => Kp = 1 * 2^K_scal = 1 * 2^4 = 16
72
// To get the right result you have to divide the number by 2^K_scal
73
// So execute a K_scal right shift
74
#define K_speed_scal 4 // 4 MMT motor//5 MAXON motor
75
#define K_cur_scal 4
76
#define K_pos_scal 5
77
78
// Speed measurement
79
// K_SPEED = (60 * 255)/(n * t_timer0 * speed_max(rpm))
80
// with n : number of pairs of poles.
81
// and t_timer0 : 16us
82
#define K_SPEED 34152 // max speed : 7000 (MC100 motor)
83
//#define K_SPEED 11250 // max speed : 17000 (MMT 35-1LS motor)
84
// if you want to calculate the absolute speed
85
// absolute_speed = alpha * measured_speed
86
// with alpha = 60 / (n * K_SPEED * t_timer0)
87
88
#endif
89
90
/* IMAX for DAC is calculated on that way :
91
Rshunt = 0.1Ohm
92
Vref = 2.56V
93
DAC is left adjust so it is like a 8 bit DAC
94
IMAX = imax(amp) * 256 * 0.1 / 2.56
95
IMAX = imax * 10 */
96
#define IMAX (6 * 10)
/* 6 amps */
HS_101
Definition:
config_motor.h:23
HS_110
Definition:
config_motor.h:23
CW
Definition:
config_motor.h:34
HS_010
Definition:
config_motor.h:23
HS_001
Definition:
config_motor.h:23
STOP
Definition:
config_motor.h:29
RUN
Definition:
config_motor.h:29
HS_100
Definition:
config_motor.h:23
CCW
Definition:
config_motor.h:34
HS_011
Definition:
config_motor.h:23
config_motor.h
Generated by
1.8.13