ini
[aversive.git] / modules / devices / brushless_motors / brushless_3phase_digital_hall_double / test / brushless_3phase_digital_hall_config.h
1 /*  
2  *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)
3  * 
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License
15  *  along with this program; if not, write to the Free Software
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  *
18  *  Revision : $Id: brushless_3phase_digital_hall_config.h,v 1.2.2.2 2007-05-12 16:42:39 zer0 Exp $
19  *
20  */
21
22 #ifndef BRUSHLESS_TYPE
23 #define BRUSHLESS_TYPE BRUSHLESS_DIGITAL_DOUBLE
24
25
26 /** a setting of 1 gives 6 steps per electrical turn 
27     the number of electrical poles per mechanical revolution depends on your motor.
28     Please consider that a value different from 1 rises the processor load ! so try to use 1
29     */
30 #define BRUSHLESS_POSITION_PRECISION 1
31
32
33 typedef int16_t brushless_speed;
34 typedef int32_t brushless_position;
35
36 typedef int16_t brushless_torque; // max value is that of the PWM
37
38
39 /** motor 0 connection definition */
40
41 /** inversion of sensors*/
42 //#define BRUSHLESS_0_SENSORS_INVERT
43
44 /** sensor  pull ups. This is recommended for safety */
45 //#define BRUSHLESS_0_SENSORS_PULL_UP_RESISTORS
46
47 /** sensors port definitions */
48 #define BRUSHLESS_0_SENSOR_1_PORT PORTA
49 #define BRUSHLESS_0_SENSOR_1_BIT  4
50 #define BRUSHLESS_0_SENSOR_2_PORT PORTA
51 #define BRUSHLESS_0_SENSOR_2_BIT  3
52 #define BRUSHLESS_0_SENSOR_3_PORT PORTA
53 #define BRUSHLESS_0_SENSOR_3_BIT  5
54
55 /** PWM definitions 
56     Please activate the PWM synch in pwm.h if you use PWMs from separate timers
57   */
58 #define BRUSHLESS_0_PWM_SET_1(value) pwm_set_1A(value)
59 #define BRUSHLESS_0_PWM_SET_2(value) pwm_set_1B(value)
60 #define BRUSHLESS_0_PWM_SET_3(value) pwm_set_1C(value)
61
62
63
64 /** total inversion of the motor behaviour, other configuration remains the same */
65 //#define BRUSHLESS_0_INVERT
66
67
68
69
70 /** this selects the timer overflow int to use
71     please enter the timer number of one of the 6 PWMs
72     for example,if one of your pwm is the 2A, enter "2" here
73     */
74 #define BRUSHLESS_TIMER  1
75
76 /** following  parameters calculateas such : 
77     
78     fsample = fpwm / PWM_TO_SAMPLE_DIVISOR
79     
80     fevent = fsample / SAMPLE_TO_EVENT_DIVISOR
81     
82     it is recommended to have fsample at approx 10 kHz max, less if you plan a slow motor
83     SAMPLE_TO_EVENT_DIVISOR should be at least 100, or more, so that the event is slow enough for your need
84     
85     these parameters should be carefully chosen to not overload the processor
86     
87   */
88   
89 /** max 255  */
90 #define BRUSHLESS_PWM_TO_SAMPLE_DIVISOR   4 // PWM9 bits, quartz 16 MHz  >> 7.8 kHz
91 /** max 65535, min recommended 100 */
92 #define BRUSHLESS_SAMPLE_TO_EVENT_DIVISOR 7812 // environ 1s
93
94
95 /** max speed, is in general to BRUSHLESS_SAMPLE_TO_EVENT_DIVISOR
96     but can be adapted to your needs, if you need to go further down with the speed */
97 #define BRUSHLESS_MAX_SPEED   BRUSHLESS_SAMPLE_TO_EVENT_DIVISOR 
98
99
100
101 //#define LOADTEST  // define this to test the maximum processor load !
102
103 //#define ASMHEADER // optimized PWM division : particularly useful with 8 bit timers ! Using this can display one warning
104
105
106 #endif // BRUSHLESS_TYPE
107
108