avant la coupe de belgique
[aversive.git] / projects / microb2010 / cobboard / actuator.c
1 /*
2  *  Copyright Droids Corporation (2009)
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: actuator.c,v 1.4 2009-04-24 19:30:41 zer0 Exp $
19  *
20  */
21
22 #include <aversive.h>
23 #include <aversive/pgmspace.h>
24 #include <aversive/wait.h>
25 #include <aversive/error.h>
26
27 #include <ax12.h>
28 #include <uart.h>
29 #include <spi.h>
30 #include <encoders_spi.h>
31 #include <pwm_ng.h>
32 #include <timer.h>
33 #include <scheduler.h>
34 #include <clock_time.h>
35
36 #include <pid.h>
37 #include <quadramp.h>
38 #include <control_system_manager.h>
39 #include <blocking_detection_manager.h>
40
41 #include <rdline.h>
42
43 #include "sensor.h"
44 #include "../common/i2c_commands.h"
45 #include "main.h"
46 #include "actuator.h"
47
48 #define COBROLLER_SPEED 800
49 //#define COBROLLER_SPEED 400
50
51 #define SERVO_DOOR_OPEN 260
52 #define SERVO_DOOR_CLOSED 500
53 #define SERVO_DOOR_BLOCK 500
54
55 #define SERVO_CARRY_L_OPEN 295
56 #define SERVO_CARRY_L_CLOSED 400 // 510
57
58 #define SERVO_CARRY_R_OPEN 455
59 #define SERVO_CARRY_R_CLOSED 350 // 250
60
61 void actuator_init(void);
62
63 void servo_carry_open(void)
64 {
65         pwm_ng_set(SERVO_CARRY_L_PWM, SERVO_CARRY_L_OPEN);
66         pwm_ng_set(SERVO_CARRY_R_PWM, SERVO_CARRY_R_OPEN);
67 }
68
69 void servo_carry_close(void)
70 {
71         pwm_ng_set(SERVO_CARRY_L_PWM, SERVO_CARRY_L_CLOSED);
72         pwm_ng_set(SERVO_CARRY_R_PWM, SERVO_CARRY_R_CLOSED);
73 }
74
75 void servo_door_open(void)
76 {
77         pwm_ng_set(SERVO_DOOR_PWM, SERVO_DOOR_OPEN);
78 }
79
80 void servo_door_close(void)
81 {
82         pwm_ng_set(SERVO_DOOR_PWM, SERVO_DOOR_CLOSED);
83 }
84
85 void servo_door_block(void)
86 {
87         pwm_ng_set(SERVO_DOOR_PWM, SERVO_DOOR_BLOCK);
88 }
89
90 void cobroller_on(uint8_t side)
91 {
92         if (side == I2C_LEFT_SIDE)
93                 cobboard.left_cobroller_speed = COBROLLER_SPEED;
94         else
95                 cobboard.right_cobroller_speed = -COBROLLER_SPEED;
96 }
97
98 void cobroller_off(uint8_t side)
99 {
100         if (side == I2C_LEFT_SIDE)
101                 cobboard.left_cobroller_speed = 0;
102         else
103                 cobboard.right_cobroller_speed = 0;
104 }
105
106 void cobroller_reverse(uint8_t side)
107 {
108         if (side == I2C_LEFT_SIDE)
109                 cobboard.left_cobroller_speed = -COBROLLER_SPEED;
110         else
111                 cobboard.right_cobroller_speed = COBROLLER_SPEED;
112 }
113
114 void actuator_init(void)
115 {
116
117 }