2 * Copyright Droids Corporation, Microb Technology, Eirbot (2005)
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.
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.
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
18 * Revision : $Id: brushless_3phase_digital_hall_double_config.h,v 1.2.2.2 2007-05-12 16:42:40 zer0 Exp $
22 #ifndef BRUSHLESS_TYPE
23 #define BRUSHLESS_TYPE BRUSHLESS_DIGITAL_DOUBLE
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
30 #define BRUSHLESS_POSITION_PRECISION 1
33 typedef s16 brushless_speed;
34 typedef s32 brushless_position;
36 typedef s16 brushless_torque; // max value is that of the PWM
39 /** motor 0 connection definition */
41 /** inversion of sensors*/
42 //#define BRUSHLESS_0_SENSORS_INVERT
44 /** sensor pull ups. This is recommended for safety */
45 //#define BRUSHLESS_0_SENSORS_PULL_UP_RESISTORS
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
56 Please activate the PWM synch in pwm.h if you use PWMs from separate timers
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)
64 /** total inversion of the motor behaviour, other configuration remains the same */
65 #define BRUSHLESS_0_INVERT
68 /** motor 1 connection definition */
70 /** inversion of sensors*/
71 //#define BRUSHLESS_1_SENSORS_INVERT
73 /** sensor pull ups. This is recommended for safety */
74 //#define BRUSHLESS_1_SENSORS_PULL_UP_RESISTORS
76 /** sensors port definitions */
77 #define BRUSHLESS_1_SENSOR_1_PORT PORTA
78 #define BRUSHLESS_1_SENSOR_1_BIT 1
79 #define BRUSHLESS_1_SENSOR_2_PORT PORTA
80 #define BRUSHLESS_1_SENSOR_2_BIT 0
81 #define BRUSHLESS_1_SENSOR_3_PORT PORTA
82 #define BRUSHLESS_1_SENSOR_3_BIT 2
85 Please activate the PWM synch in pwm.h if you use PWMs from separate timers
87 #define BRUSHLESS_1_PWM_SET_1(value) pwm_set_3A(value)
88 #define BRUSHLESS_1_PWM_SET_2(value) pwm_set_3B(value)
89 #define BRUSHLESS_1_PWM_SET_3(value) pwm_set_3C(value)
93 /** total inversion of the motor behaviour, other configuration remains the same */
94 //#define BRUSHLESS_1_INVERT
98 /** this selects the timer overflow int to use
99 please enter the timer number of one of the 6 PWMs
100 for example,if one of your pwm is the 2A, enter "2" here
102 #define BRUSHLESS_TIMER 1
104 /** following parameters calculateas such :
106 fsample = fpwm / PWM_TO_SAMPLE_DIVISOR
108 fevent = fsample / SAMPLE_TO_EVENT_DIVISOR
110 it is recommended to have fsample at approx 10 kHz max, less if you plan a slow motor
111 SAMPLE_TO_EVENT_DIVISOR should be at least 100, or more, so that the event is slow enough for your need
113 these parameters should be carefully chosen to not overload the processor
118 #define BRUSHLESS_PWM_TO_SAMPLE_DIVISOR 4 // PWM9 bits, quartz 16 MHz >> 7.8 kHz
119 /** max 65535, min recommended 100 */
120 #define BRUSHLESS_SAMPLE_TO_EVENT_DIVISOR (78*1) // environ 10ms
123 /** max speed, is in general to BRUSHLESS_SAMPLE_TO_EVENT_DIVISOR
124 but can be adapted to your needs, if you need to go further down with the speed */
125 #define BRUSHLESS_MAX_SPEED BRUSHLESS_SAMPLE_TO_EVENT_DIVISOR
129 //#define LOADTEST // define this to test the maximum processor load !
131 //#define ASMHEADER // optimized PWM division : particularly useful with 8 bit timers ! Using this can display one warning
134 #endif // BRUSHLESS_TYPE