Caddy
A 2005 Roborodentia entry with vision and path planning capability
 All Data Structures Files Functions Variables Typedefs Macros Pages
encoderconf.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  */
18 //*****************************************************************************
19 //
20 // File Name : 'encoderconf.h'
21 // Title : Quadrature Encoder driver configuration
22 // Author : Pascal Stang - Copyright (C) 2003-2004
23 // Created : 2003.01.26
24 // Revised : 2004.06.25
25 // Version : 0.2
26 // Target MCU : Atmel AVR Series
27 // Editor Tabs : 4
28 //
29 // The default number of encoders supported is 2 because most AVR processors
30 // have two external interrupts. To use more or fewer encoders, you must do
31 // four things:
32 //
33 // 1. Use a processor with at least as many external interrutps as number of
34 // encoders you want to have.
35 // 2. Set NUM_ENCODERS to the number of encoders you will use.
36 // 3. Comment/Uncomment the proper ENCx_SIGNAL defines for your encoders
37 // (the encoders must be used sequentially, 0 then 1 then 2 then 3)
38 // 4. Configure the various defines so that they match your processor and
39 // specific hardware. The notes below may help.
40 //
41 //
42 // -------------------- NOTES --------------------
43 // The external interrupt pins are mapped as follows on most AVR processors:
44 // (90s8515, mega161, mega163, mega323, mega16, mega32, etc)
45 //
46 // INT0 -> PD2 (PORTD, pin 2)
47 // INT1 -> PD3 (PORTD, pin 3)
48 //
49 // The external interrupt pins on the processors mega128 and mega64 are:
50 //
51 // INT0 -> PD0 (PORTD, pin 0)
52 // INT1 -> PD1 (PORTD, pin 1)
53 // INT2 -> PD2 (PORTD, pin 2)
54 // INT3 -> PD3 (PORTD, pin 3)
55 // INT4 -> PE4 (PORTE, pin 4)
56 // INT5 -> PE5 (PORTE, pin 5)
57 // INT6 -> PE6 (PORTE, pin 6)
58 // INT7 -> PE7 (PORTE, pin 7)
59 //
60 // This code is distributed under the GNU Public License
61 // which can be found at http://www.gnu.org/licenses/gpl.txt
62 //
63 //*****************************************************************************
64 
65 #ifndef ENCODERCONF_H
66 #define ENCODERCONF_H
67 
68 // constants/macros/typdefs
69 
70 // defines for processor compatibility
71 // quick compatiblity for mega128, mega64
72 //#ifndef MCUCR
73 // #define MCUCR EICRA
74 //#endif
75 
76 // Set the total number of encoders you wish to support
77 #define NUM_ENCODERS 2
78 
79 
80 // -------------------- Encoder 0 connections --------------------
81 // Phase A quadrature encoder output should connect to this interrupt line:
82 // *** NOTE: the choice of interrupt PORT, DDR, and PIN must match the external
83 // interrupt you are using on your processor. Consult the External Interrupts
84 // section of your processor's datasheet for more information.
85 
86 // Interrupt Configuration
87 #define ENC0_SIGNAL SIG_INTERRUPT0 // Interrupt signal name
88 #define ENC0_INT INT0 // matching INTx bit in GIMSK/EIMSK
89 #define ENC0_ICR MCUCR // matching Int. Config Register (MCUCR,EICRA/B)
90 #define ENC0_ISCX0 ISC00 // matching Interrupt Sense Config bit0
91 #define ENC0_ISCX1 ISC01 // matching Interrupt Sense Config bit1
92 // PhaseA Port/Pin Configuration
93 // *** PORTx, DDRx, PINx, and Pxn should all have the same letter for "x" ***
94 #define ENC0_PHASEA_PORT PORTD // PhaseA port register
95 #define ENC0_PHASEA_DDR DDRD // PhaseA port direction register
96 #define ENC0_PHASEA_PORTIN PIND // PhaseA port input register
97 #define ENC0_PHASEA_PIN PD2 // PhaseA port pin
98 // Phase B quadrature encoder output should connect to this direction line:
99 // *** PORTx, DDRx, PINx, and Pxn should all have the same letter for "x" ***
100 //#define ENC0_PHASEB_PORT PORTC // PhaseB port register
101 //#define ENC0_PHASEB_DDR DDRC // PhaseB port direction register
102 //#define ENC0_PHASEB_PORTIN PINC // PhaseB port input register
103 //#define ENC0_PHASEB_PIN PC0 // PhaseB port pin
104 
105 
106 // -------------------- Encoder 1 connections --------------------
107 // Phase A quadrature encoder output should connect to this interrupt line:
108 // *** NOTE: the choice of interrupt pin and port must match the external
109 // interrupt you are using on your processor. Consult the External Interrupts
110 // section of your processor's datasheet for more information.
111 
112 // Interrupt Configuration
113 #define ENC1_SIGNAL SIG_INTERRUPT1 // Interrupt signal name
114 #define ENC1_INT INT1 // matching INTx bit in GIMSK/EIMSK
115 #define ENC1_ICR MCUCR // matching Int. Config Register (MCUCR,EICRA/B)
116 #define ENC1_ISCX0 ISC10 // matching Interrupt Sense Config bit0
117 #define ENC1_ISCX1 ISC11 // matching Interrupt Sense Config bit1
118 // PhaseA Port/Pin Configuration
119 // *** PORTx, DDRx, PINx, and Pxn should all have the same letter for "x" ***
120 #define ENC1_PHASEA_PORT PORTD // PhaseA port register
121 #define ENC1_PHASEA_PORTIN PIND // PhaseA port input register
122 #define ENC1_PHASEA_DDR DDRD // PhaseA port direction register
123 #define ENC1_PHASEA_PIN PD3 // PhaseA port pin
124 // Phase B quadrature encoder output should connect to this direction line:
125 // *** PORTx, DDRx, PINx, and Pxn should all have the same letter for "x" ***
126 //#define ENC1_PHASEB_PORT PORTC // PhaseB port register
127 //#define ENC1_PHASEB_DDR DDRC // PhaseB port direction register
128 //#define ENC1_PHASEB_PORTIN PINC // PhaseB port input register
129 //#define ENC1_PHASEB_PIN PC1 // PhaseB port pin
130 
131 
132 // -------------------- Encoder 2 connections --------------------
133 // Phase A quadrature encoder output should connect to this interrupt line:
134 // *** NOTE: the choice of interrupt pin and port must match the external
135 // interrupt you are using on your processor. Consult the External Interrupts
136 // section of your processor's datasheet for more information.
137 
138 // Interrupt Configuration
139 //#define ENC2_SIGNAL SIG_INTERRUPT6 // Interrupt signal name
140 #define ENC2_INT INT6 // matching INTx bit in GIMSK/EIMSK
141 #define ENC2_ICR EICRB // matching Int. Config Register (MCUCR,EICRA/B)
142 #define ENC2_ISCX0 ISC60 // matching Interrupt Sense Config bit0
143 #define ENC2_ISCX1 ISC61 // matching Interrupt Sense Config bit1
144 // PhaseA Port/Pin Configuration
145 // *** PORTx, DDRx, PINx, and Pxn should all have the same letter for "x" ***
146 #define ENC2_PHASEA_PORT PORTE // PhaseA port register
147 #define ENC2_PHASEA_PORTIN PINE // PhaseA port input register
148 #define ENC2_PHASEA_DDR DDRE // PhaseA port direction register
149 #define ENC2_PHASEA_PIN PE6 // PhaseA port pin
150 // Phase B quadrature encoder output should connect to this direction line:
151 // *** PORTx, DDRx, PINx, and Pxn should all have the same letter for "x" ***
152 #define ENC2_PHASEB_PORT PORTC // PhaseB port register
153 #define ENC2_PHASEB_DDR DDRC // PhaseB port direction register
154 #define ENC2_PHASEB_PORTIN PINC // PhaseB port input register
155 #define ENC2_PHASEB_PIN PC2 // PhaseB port pin
156 
157 
158 // -------------------- Encoder 3 connections --------------------
159 // Phase A quadrature encoder output should connect to this interrupt line:
160 // *** NOTE: the choice of interrupt pin and port must match the external
161 // interrupt you are using on your processor. Consult the External Interrupts
162 // section of your processor's datasheet for more information.
163 
164 // Interrupt Configuration
165 //#define ENC3_SIGNAL SIG_INTERRUPT7 // Interrupt signal name
166 #define ENC3_INT INT7 // matching INTx bit in GIMSK/EIMSK
167 #define ENC3_ICR EICRB // matching Int. Config Register (MCUCR,EICRA/B)
168 #define ENC3_ISCX0 ISC70 // matching Interrupt Sense Config bit0
169 #define ENC3_ISCX1 ISC71 // matching Interrupt Sense Config bit1
170 // PhaseA Port/Pin Configuration
171 // *** PORTx, DDRx, PINx, and Pxn should all have the same letter for "x" ***
172 #define ENC3_PHASEA_PORT PORTE // PhaseA port register
173 #define ENC3_PHASEA_PORTIN PINE // PhaseA port input register
174 #define ENC3_PHASEA_DDR DDRE // PhaseA port direction register
175 #define ENC3_PHASEA_PIN PE7 // PhaseA port pin
176 // Phase B quadrature encoder output should connect to this direction line:
177 // *** PORTx, DDRx, PINx, and Pxn should all have the same letter for "x" ***
178 #define ENC3_PHASEB_PORT PORTC // PhaseB port register
179 #define ENC3_PHASEB_DDR DDRC // PhaseB port direction register
180 #define ENC3_PHASEB_PORTIN PINC // PhaseB port input register
181 #define ENC3_PHASEB_PIN PC3 // PhaseB port pin
182 
183 #endif