00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 //_____ I N C L U D E S ___________________________________________________ 00012 00013 00014 00015 #ifndef _CONFIG_MOTOR_H_ 00016 #define _CONFIG_MOTOR_H_ 00017 00023 enum {HS_001=1,HS_010=2,HS_011=3,HS_100=4,HS_101=5,HS_110=6}; 00024 00025 00029 enum {RUN = TRUE, STOP = FALSE}; 00030 00034 enum {CCW = TRUE, CW = FALSE}; 00035 00036 // Define Type of Pulse Width Modulation 00037 //#define HIGH_AND_LOW_PWM // it doesn't run with AT90PWM3B in centered mode 00038 // AT90PWM3B: for high and low pwm (fast decay mode), 00039 // please use 1,2 or 4 ramps mode and adjust ADC synchro 00040 00041 // Define type of speed measure and number of samples 00042 //#define AVERAGE_SPEED_MEASURE 00043 #define n_SAMPLE 8 00044 00045 // Define macro for motor control 00046 #define OPEN_LOOP 0 00047 #define SPEED_LOOP 1 00048 #define CURRENT_LOOP 2 00049 00050 // Here you have to define your control coefficients 00051 // Kp for the proportionnal coef 00052 // Ki for the integral coef 00053 // Kd for the derivative coef 00054 00055 // Speed regulation coefficients 00056 #define Kp_speed 8//1 MMT motor//8 MAXON moto 00057 #define Ki_speed 8//10 MMT motor//8 MAXON motor 00058 #define Kd_speed 0 00059 00060 // Current regulation coefficients 00061 #define Kp_cur 1 00062 #define Ki_cur 3 00063 #define Kd_cur 0 00064 00065 // Position regulation coefficients 00066 #define Kp_pos 9 //8 00067 #define Ki_pos 3 //1 00068 #define Kd_pos 20 //5 00069 00070 // All PID coef are multiplied by 2^Kmul 00071 // For exemple : kp = 1 => Kp = 1 * 2^K_scal = 1 * 2^4 = 16 00072 // To get the right result you have to divide the number by 2^K_scal 00073 // So execute a K_scal right shift 00074 #define K_speed_scal 4 // 4 MMT motor//5 MAXON motor 00075 #define K_cur_scal 4 00076 #define K_pos_scal 5 00077 00078 // Speed measurement 00079 // K_SPEED = (60 * 255)/(n * t_timer0 * speed_max(rpm)) 00080 // with n : number of pairs of poles. 00081 // and t_timer0 : 16us 00082 #define K_SPEED 34152 // max speed : 7000 (MC100 motor) 00083 //#define K_SPEED 11250 // max speed : 17000 (MMT 35-1LS motor) 00084 // if you want to calculate the absolute speed 00085 // absolute_speed = alpha * measured_speed 00086 // with alpha = 60 / (n * K_SPEED * t_timer0) 00087 00088 #endif 00089 00090 /* IMAX for DAC is calculated on that way : 00091 Rshunt = 0.1Ohm 00092 Vref = 2.56V 00093 DAC is left adjust so it is like a 8 bit DAC 00094 IMAX = imax(amp) * 256 * 0.1 / 2.56 00095 IMAX = imax * 10 */ 00096 #define IMAX (6 * 10) /* 6 amps */
1.5.7.1