00001 00015 /*_____ I N C L U D E S ____________________________________________________*/ 00016 #include "compiler.h" 00017 #include "mcu.h" 00018 #include "inavr.h" 00019 00020 #ifndef _CONFIG_MOTOR_H_ 00021 #define _CONFIG_MOTOR_H_ 00022 00028 #ifdef USE_INTERNAL_COMPARATORS 00029 /* enum with the bemf signals from comparator outputs */ 00030 // enum {HS_001=3,HS_010=6,HS_011=2,HS_100=5,HS_101=1,HS_110=4}; 00031 enum {HS_011=2,HS_001=3,HS_101=1,HS_100=5,HS_110=4,HS_010=6}; 00032 #else 00033 /* enum with the bemf signals from port inputs */ 00034 enum {HS_001=1,HS_010=2,HS_011=3,HS_100=4,HS_101=5,HS_110=6}; 00035 #endif 00036 00040 enum {RUN = TRUE, STOP = FALSE}; 00041 00045 enum {CCW = TRUE, CW = FALSE}; 00046 00050 #define HIGH_AND_LOW_PWM 00051 00055 #define DUTY_RAMP_UP 140 00056 00060 enum {OPEN_LOOP = 0, SPEED_LOOP = 1, CURRENT_LOOP = 2, POSITION_LOOP = 3}; 00061 00062 // Here you have to define your control coefficients 00063 // Kp for the proportionnal coef 00064 // Ki for the integral coef 00065 // Kd for the derivative coef 00066 00067 // Speed regulation coefficients 00068 //#define Kp_speed 16//1 MMT motor//8 MAXON moto 00069 #define Kp_speed 6 00070 #define Ki_speed 2 00071 #define Kd_speed 0 00072 #define Klin_speed 185 /* to linearize the duty cycle responds */ 00073 00074 // Current regulation coefficients 00075 #define Kp_cur 1 00076 #define Ki_cur 3 00077 #define Kd_cur 0 00078 00079 // Position regulation coefficients 00080 #define Kp_pos 9 //8 00081 #define Ki_pos 3 //1 00082 #define Kd_pos 20 //5 00083 00084 // All PID coef are multiplied by 2^Kmul 00085 // For exemple : kp = 1 => Kp = 1 * 2^K_scal = 1 * 2^4 = 16 00086 // To get the right result you have to divide the number by 2^K_scal 00087 // So execute a K_scal right shift 00088 #define K_speed_scal 5 00089 #define K_cur_scal 4 00090 #define K_pos_scal 5 00091 00092 // Speed measurement 00093 // K_SPEED = (60 * 255)/(p * t_timer0 * speed_max(rpm)) 00094 // with p : number of pairs of poles. 00095 // and t_timer0 : 8us @ 8MHz / 4us @ 16MHz 00096 //#define K_SPEED 77116 /* 6200 rpm/ 4 pairs/ @8MHz */ 00097 #define K_SPEED 136607 /* 7000 rpm/ 4 pairs/ @16MHz */ 00098 /* speed(rpm) = measured_speed * 60 / (K_SPEED * 4E-6 * p) */ 00099 /* the result must be multiplied by 27.45 to get a value in rpm */ 00100 00101 #endif
1.4.7