ini
[aversive.git] / modules / devices / brushless_motors / brushless_3phase_digital_hall_double / brushless.h
1 /*  \r
2  *  Copyright Droids Corporation, Microb Technology, Eirbot (2005)\r
3  * \r
4  *  This program is free software; you can redistribute it and/or modify\r
5  *  it under the terms of the GNU General Public License as published by\r
6  *  the Free Software Foundation; either version 2 of the License, or\r
7  *  (at your option) any later version.\r
8  *\r
9  *  This program is distributed in the hope that it will be useful,\r
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of\r
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
12  *  GNU General Public License for more details.\r
13  *\r
14  *  You should have received a copy of the GNU General Public License\r
15  *  along with this program; if not, write to the Free Software\r
16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
17  *\r
18  *  Revision : $Id: brushless.h,v 1.2.2.3 2007-05-23 17:18:12 zer0 Exp $\r
19  *\r
20  */\r
21 \r
22 \r
23 #ifndef _BRUSHLESS_\r
24 #define _BRUSHLESS_\r
25 \r
26 #include <aversive.h>\r
27 \r
28 #include <brushless_3phase_digital_hall_double_config.h>\r
29 \r
30 \r
31 \r
32 /** This module handles two brushless motors with 3 phases, wired in triangle or star.\r
33     2x 3 hall sensors are used wih digital output.\r
34     2x 3 PWM are outputted, these MUST be synchronized !!\r
35     \r
36     The control value is a voltage. This can be assimiled to a torque at low speeds.\r
37     \r
38     There is a possibility of also of limiting the speed. This is accomplished by slowing down the sampling speed of the \r
39     sensors. Doing this,the motor effective torque is reduced when the speed is such that the sensor actuation\r
40     approaches the sampling frequency.\r
41     use this technique carefully, because the motor has already his full voltage applied, an can dissipate a lot of energy, especially at low speeds.\r
42     \r
43     \r
44     there is no external manage function, as the manage is done at the PWM speed (overflow of one PWM timer is used.)\r
45     This function is speed optimized.\r
46     */\r
47 \r
48 typedef struct\r
49 {\r
50   brushless_speed   speed;\r
51   brushless_position  position;\r
52 }\r
53 brushless;\r
54 \r
55 \r
56  /** initialisation, also executes pwm_init */\r
57 extern void brushless_init(void);\r
58 \r
59 /** sets a consign speed and torque \r
60     if you do not use the speed coarse limitation, please configure with BRUSHLESS_MAX_SPEED */\r
61 extern void brushless_0_set_parameters(brushless_speed speed, brushless_torque torque);\r
62 extern void brushless_1_set_parameters(brushless_speed speed, brushless_torque torque);\r
63 \r
64 /** calculates the speed update info. To be called externally only if not internally, ie\r
65     if the BRUSHLESS_MANAGE_EXTERNAL is set\r
66     */\r
67 #ifdef BRUSHLESS_MANAGE_EXTERNAL\r
68 extern void brushless_speed_update_manage(void * dummy);\r
69 #endif\r
70 \r
71 /** get current speed and position\r
72     This function is very useful to get synchronous speed and torque info\r
73 */\r
74 extern brushless brushless_0_get_mesures(void);\r
75 extern brushless brushless_1_get_mesures(void);\r
76 \r
77 /**  sets the position counter */\r
78 extern void brushless_0_set_position(brushless_position p);\r
79 extern void brushless_1_set_position(brushless_position p);\r
80 \r
81 /** registers an event function that triggers periodically, and synchronously with the speed measurement */\r
82 extern void brushless_0_register_periodic_event(void (*f)(brushless));\r
83 extern void brushless_1_register_periodic_event(void (*f)(brushless));\r
84 \r
85 \r
86 \r
87 /** acess functions for the control system interface */\r
88 \r
89 \r
90 /** get speed function, compatible with control_system. \r
91     Argument is the  number of the adressed motor, which is casted to (void*) */\r
92 extern int32_t brushless_get_speed(void * );\r
93 \r
94 /** get position function, compatible with control_system.\r
95     Argument is the  number of the adressed motor, which is casted to (void*)  */\r
96 extern int32_t brushless_get_pos(void * );\r
97 \r
98 /** set torque function, compatible with control_system.\r
99     Argument is the  number of the adressed motor, which is casted to (void*) */\r
100 extern void brushless_set_torque(void *, int32_t torque);\r
101 \r
102 /** set speed function, compatible with control_system.\r
103     Argument is the  number of the adressed motor, which is casted to (void*) */\r
104 extern void brushless_set_speed(void *, int32_t speed);\r
105 \r
106 \r
107 \r
108 #endif\r