Caddy
A 2005 Roborodentia entry with vision and path planning capability
 All Data Structures Files Functions Variables Typedefs Macros Pages
motor_control.h
Go to the documentation of this file.
1 /*
2  * This file is part of Caddy.
3  *
4  * Caddy 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 3 of the License, or
7  * (at your option) any later version.
8  *
9  * Caddy 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 Caddy. If not, see <http://www.gnu.org/licenses/>.
16  */
31 #ifndef MOTORCNTRL_H_
32 #define MOTORCNTRL_H_
33 
34 // AVRLIB
35 #include "timer.h"
36 
37 // avr-libc
38 #include <avr/io.h>
39 #include <stdint.h>
40 
41 //Motor selection constants
42 #define LEFT_MOTOR 0
43 #define RIGHT_MOTOR 1
44 #define BOTH_MOTORS 2
45 #define LEFT_ENC 1
46 #define RIGHT_ENC 0
47 
48 //Speed definitions
49 #define MAX_BRAKE 255
50 
51 //Pin defines
52 //defined by the active high pin
53 #define MC_PORT PORTA
54 #define FORWARD_LEFT 7
55 #define FORWARD_RIGHT 5
56 #define REVERSE_LEFT 6
57 #define REVERSE_RIGHT 4
58 #define PWM_LEFT timer1PWMASet
59 #define PWM_RIGHT timer1PWMBSet
60 
61 void moveStraight(int16_t ticks, uint8_t speed);
62 void tractorTurn(uint8_t speed, int8_t brads);
63 void tankTurn(uint8_t speed, int8_t brads);
64 void enableMotors( void );
65 void disableMotors( void );
66 
67 //select left, right, or both motors
68 //sets selected motor(s) to forward at speed
69 void forward(uint8_t motorSelect, uint8_t speed);
70 //select left, right, or both motors
71 //sets selected motor(s) to reverse at speed
72 void reverse(uint8_t motorSelect, uint8_t speed);
73 //disables motor controller
74 void neutral(void);
75 //brake selected motor
76 //full brake assumed
77 void brake(uint8_t motorSelect);
78 void tickWheels(int16_t leftTicks, int16_t rightTicks, uint8_t speed);
79 
80 #endif // #ifndef MOTORCNTRL_H_