Project

General

Profile

Revision 854

Did a lot of cleaning up and commenting. Made the error codes returned
by encoder_read more explicit - so if you get weird values check the documentation.

A lot of stubs and incomplete code, I made these things explicit in the source and documentation.

View differences:

encoders.h
1
/**
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

  
1 13
#ifndef __ENCODERS_H__
2 14
#define __ENCODERS_H__
3 15

  
4 16

  
5
#define RIGHT 1
6 17
#ifndef LEFT
7 18
	#define LEFT 0
8 19
#endif
9
#ifndef LEFT
10
	#define LEFT 0
20
#ifndef RIGHT
21
	#define RIGHT 1
11 22
#endif
12
#define INVALID 1024
13
#define MAGNET_FAILURE 1025
14 23

  
24
/** @brief Magnet misaligned - likely distance from encoder problem. **/
25
#define ENCODER_MAGNET_FAILURE 1025
26
/** @brief Encoder misaligned - likely on XY plane. **/
27
#define ENCODER_MISALIGNED 1027
28
/** @brief Not enough time has passed - encoders not initialized in hardware. **/
29
#define ENCODER_DATA_NOT_READY 1026
15 30

  
16 31
//delay_ms argument after a full read is complete
17 32
#define ENCODER_DELAY 20
......
23 38
#define OCF _BV(4)
24 39
#define COF _BV(3)
25 40

  
26
//Data invlalid alarm (May be invalid):
41
//Data invalid alarm (May be invalid):
27 42
#define LIN _BV(2)
28 43

  
29 44
#define MagINCn _BV(1)
......
31 46

  
32 47
#define BUFFER_SIZE 23
33 48

  
49
/** @brief Initialize encoders. **/
34 50
void encoders_init(void);
51
/** @brief Read instantaneous encoder value. **/
35 52
int encoder_read(char encoder);
53
/** @brief Currently a stub - DO NOT Use. **/
36 54
char encoder_direction(char encoder);
37
void encoders_print_data_array(void);
38 55

  
56
/** @brief Get total distance traveled. **/
39 57
int encoder_get_dx(char encoder);
58
/** @brief Reset distance counter. **/
40 59
void encoder_rst_dx(char encoder);
60
/** @brief Get time count: The number of encoder reads that have occurred. **/
41 61
int encoder_get_tc(void);
62
/** @brief Reset the time count. **/
42 63
void encoder_rst_tc(void);
43 64

  
65
/** @brief Still untested, so use at your own risk. **/
44 66
int encoder_get_v(char encoder);
45 67

  
46
//waits for the next encoder reading, then returns
68
/** @brief Waits for the next encoder reading, then returns. **/
47 69
void encoder_wait( int nReadings );
48 70

  
49 71
#endif

Also available in: Unified diff