ini
[aversive.git] / modules / devices / brushless_motors / brushless_3phase_digital_hall / config / 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:38 zer0 Exp $
19  *
20  */
21
22 #ifndef BRUSHLESS_TYPE
23 #define BRUSHLESS_TYPE BRUSHLESS_DIGITAL
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 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_SENSORS_PULL_UP_RESISTORS
46
47 /** sensors port definitions */
48 #define BRUSHLESS_0_SENSOR_1_PORT PORTA
49 #define BRUSHLESS_0_SENSOR_1_BIT  0
50 #define BRUSHLESS_0_SENSOR_2_PORT PORTA
51 #define BRUSHLESS_0_SENSOR_2_BIT  1
52 #define BRUSHLESS_0_SENSOR_3_PORT PORTA
53 #define BRUSHLESS_0_SENSOR_3_BIT  2
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 /** this selects the timer overflow int to use
63     please enter the timer number of one of the 3 PWMs
64     for example,if one of your pwm is the 2A, enter "2" here
65     */
66 #define BRUSHLESS_TIMER  1
67
68
69
70 /** total inversion of the motor behaviour, other configuration remains the same */
71 #define BRUSHLESS_0_INVERT
72
73 /** following  parameters calculateas such : 
74     
75     fsample = fpwm / PWM_TO_SAMPLE_DIVISOR
76     
77     fevent = fsample / SAMPLE_TO_EVENT_DIVISOR
78     
79     it is recommended to have fsample at approx 10 kHz max, less if you plan a slow motor
80     SAMPLE_TO_EVENT_DIVISOR should be at least 100, or more, so that the event is slow enough for your need
81     
82     these parameters should be carefully chosen to not overload the processor
83     
84   */
85   
86 /** max 255  */
87 #define BRUSHLESS_PWM_TO_SAMPLE_DIVISOR   3
88 /** max 65535, min recommended 100 */
89 #define BRUSHLESS_SAMPLE_TO_EVENT_DIVISOR 10000 // 1,041s with a 8 MHz quartz
90
91
92 // #define BRUSHLESS_MANAGE_EXTERNAL// manual manage call
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
102 #endif // BRUSHLESS_TYPE