00001 /*This file has been prepared for Doxygen automatic documentation generation.*/ 00013 00014 /* Copyright (c) 2007, Atmel Corporation All rights reserved. 00015 * 00016 * Redistribution and use in source and binary forms, with or without 00017 * modification, are permitted provided that the following conditions are met: 00018 * 00019 * 1. Redistributions of source code must retain the above copyright notice, 00020 * this list of conditions and the following disclaimer. 00021 * 00022 * 2. Redistributions in binary form must reproduce the above copyright notice, 00023 * this list of conditions and the following disclaimer in the documentation 00024 * and/or other materials provided with the distribution. 00025 * 00026 * 3. The name of ATMEL may not be used to endorse or promote products derived 00027 * from this software without specific prior written permission. 00028 * 00029 * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED 00030 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 00031 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND 00032 * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, 00033 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00034 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00035 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00036 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00037 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00038 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00039 */ 00040 00041 //_____ I N C L U D E S ___________________________________________________ 00042 00043 00044 #ifndef _CONFIG_MOTOR_H_ 00045 #define _CONFIG_MOTOR_H_ 00046 00047 00051 //typedef enum {HS_001=1,HS_010=2,HS_011=3,HS_100=4,HS_101=5,HS_110=6} Hall_Position; 00052 typedef enum {MS_001=1,MS_010=2,MS_011=3,MS_100=4,MS_101=5,MS_110=6} Motor_Position; 00053 typedef enum {MS_ALIGN=1,MS_RAMP_UP=2,MS_LAST_RAMP_UP=3,MS_RUNNING=4,MS_STOP=5} Motor_State; 00054 00056 enum {RUN = TRUE, STOP = FALSE}; 00057 00058 00060 enum {CCW = TRUE, CW = FALSE}; 00061 00062 00063 // Define type of speed measure and number of samples 00064 //#define AVERAGE_SPEED_MEASUREMENT 00065 #define N_SAMPLE 8 00066 00068 enum {OPEN_LOOP = 0, SPEED_LOOP = 1, CURRENT_LOOP = 2}; 00069 00070 // Here you have to define your control coefficients 00071 00073 #define Kp_speed 30 00075 #define Ki_speed 30 00077 #define Kd_speed 0 00078 00080 #define Kp_cur 1 00082 #define Ki_cur 3 00084 #define Kd_cur 0 00085 00086 00087 // All PID coef are multiplied by 2^Kmul 00088 // For exemple : kp = 1 => Kp = 1 * 2^K_scal = 1 * 2^4 = 16 00089 // To get the right result you have to divide the number by 2^K_scal 00090 // So execute a K_scal right shift 00092 #define K_speed_scal 4 00094 #define K_cur_scal 4 00095 00096 // Speed measurement 00097 // K_SPEED = (60 * 255)/(n * t_timer0 * speed_max(rpm)) 00098 // with n : number of pairs of poles. 00099 // and t_timer0 : 16us 00100 #define K_SPEED 34152 // max speed : 7000 (MC100/MC310 motor) 00101 //#define K_SPEED 11250 // max speed : 17000 (MMT 35-1LS motor) 00102 // if you want to calculate the absolute speed 00103 // absolute_speed = alpha * measured_speed 00104 // with alpha = 60 / (n * K_SPEED * t_timer0) 00105 00106 #endif 00107 00108 /* IMAX for DAC is calculated on that way : 00109 Rshunt = 0.05 Ohm 00110 Vref = 2.56V 00111 DAC is left adjust so it is like a 8 bit DAC 00112 IMAX = imax(amp) * 0.05 * 5 * 256 / 2.56 + 128 00113 IMAX = imax * 25 + 128 00114 The result must be less than 254 */ 00115 00116 //#define IMAX (4 * 25 + 128) /* 4 amps */ 00117 #define IMAX 228 00118 00119 #define MC310_MOTOR 00120 //#define ELECTROCRAFT_MOTOR 00121 //#define RC_MOTOR 00122 00123 #ifdef MC310_MOTOR 00125 #define RAMP_UP_PERIOD 50 00126 #define RAMP_UP_INDEX_MAX 10 00127 #define RAMP_UP_STEP_MAX 40 00128 00129 #define TIMER1_AT_STARTUP_END 500 00130 00131 #define ALIGN_TIME 200 00132 #define ALIGN_DUTY 150 00133 00134 #define POT_REF_MIN 180 00135 #endif 00136 00137 00138 #ifdef ELECTROCRAFT_MOTOR 00140 #define RAMP_UP_PERIOD 50 00141 #define RAMP_UP_INDEX_MAX 9 00142 #define RAMP_UP_STEP_MAX 40 00143 00144 #define TIMER1_AT_STARTUP_END 750 00145 00146 #define ALIGN_TIME 200 00147 #define ALIGN_DUTY 150 00148 00149 #define POT_REF_MIN 180 00150 #endif 00151 00152 #ifdef RC_MOTOR 00155 #define RAMP_UP_PERIOD 50 00156 #define RAMP_UP_INDEX_MAX 14 00157 #define RAMP_UP_STEP_MAX 40 00158 00159 #define TIMER1_AT_STARTUP_END 1000 00160 00161 #define ALIGN_TIME 700 00162 #define ALIGN_DUTY 150 00163 00164 #define POT_REF_MIN 150 00165 00166 #endif // _CONFIG_MOTOR_H_
1.5.7.1