root / branches / encoders / code / projects / libdragonfly / encoders.h @ 1345
History | View | Annotate | Download (1.88 KB)
1 | 854 | justin | /**
|
---|---|---|---|
2 | *
|
||
3 | * @file encoders.h
|
||
4 | * @brief Contains functions for reading encoder values.
|
||
5 | *
|
||
6 | * Contains high and low level functions for reading encoders
|
||
7 | * including reading out total distance covered, and
|
||
8 | * eventually velocity.
|
||
9 | *
|
||
10 | * @author Colony Project, CMU Robotics Club
|
||
11 | */
|
||
12 | |||
13 | 856 | justin | /**
|
14 | * @addtogroup encoders
|
||
15 | * @{
|
||
16 | **/
|
||
17 | |||
18 | 749 | bneuman | #ifndef __ENCODERS_H__
|
19 | #define __ENCODERS_H__
|
||
20 | |||
21 | |||
22 | 674 | justin | #ifndef LEFT
|
23 | #define LEFT 0 |
||
24 | #endif
|
||
25 | 854 | justin | #ifndef RIGHT
|
26 | #define RIGHT 1 |
||
27 | 674 | justin | #endif
|
28 | |||
29 | 854 | justin | /** @brief Magnet misaligned - likely distance from encoder problem. **/
|
30 | #define ENCODER_MAGNET_FAILURE 1025 |
||
31 | /** @brief Encoder misaligned - likely on XY plane. **/
|
||
32 | #define ENCODER_MISALIGNED 1027 |
||
33 | /** @brief Not enough time has passed - encoders not initialized in hardware. **/
|
||
34 | #define ENCODER_DATA_NOT_READY 1026 |
||
35 | 771 | bneuman | |
36 | //delay_ms argument after a full read is complete
|
||
37 | #define ENCODER_DELAY 20 |
||
38 | |||
39 | 674 | justin | //Data invalid flags (hardware failure):
|
40 | #define OCF _BV(4) |
||
41 | #define COF _BV(3) |
||
42 | |||
43 | 854 | justin | //Data invalid alarm (May be invalid):
|
44 | 674 | justin | #define LIN _BV(2) |
45 | |||
46 | #define MagINCn _BV(1) |
||
47 | #define MagDECn _BV(0) |
||
48 | |||
49 | 1345 | chihsiuh | //////////////////////////////
|
50 | //#define BUFFER_SIZE 23
|
||
51 | #define BUFFER_SIZE 46 |
||
52 | #define ERR_VEL 1024 |
||
53 | //////////////////////////////
|
||
54 | 676 | justin | |
55 | 1345 | chihsiuh | |
56 | 854 | justin | /** @brief Initialize encoders. **/
|
57 | 749 | bneuman | void encoders_init(void); |
58 | 854 | justin | /** @brief Read instantaneous encoder value. **/
|
59 | 674 | justin | int encoder_read(char encoder); |
60 | 854 | justin | /** @brief Currently a stub - DO NOT Use. **/
|
61 | 674 | justin | char encoder_direction(char encoder); |
62 | |||
63 | 854 | justin | /** @brief Get total distance traveled. **/
|
64 | 677 | jykong | int encoder_get_dx(char encoder); |
65 | 854 | justin | /** @brief Reset distance counter. **/
|
66 | 677 | jykong | void encoder_rst_dx(char encoder); |
67 | 854 | justin | /** @brief Get time count: The number of encoder reads that have occurred. **/
|
68 | 677 | jykong | int encoder_get_tc(void); |
69 | 854 | justin | /** @brief Reset the time count. **/
|
70 | 749 | bneuman | void encoder_rst_tc(void); |
71 | |||
72 | 854 | justin | /** @brief Still untested, so use at your own risk. **/
|
73 | 771 | bneuman | int encoder_get_v(char encoder); |
74 | |||
75 | 854 | justin | /** @brief Waits for the next encoder reading, then returns. **/
|
76 | 771 | bneuman | void encoder_wait( int nReadings ); |
77 | |||
78 | 856 | justin | /**@}**/ //end group |
79 | |||
80 | 749 | bneuman | #endif |