root / trunk / code / projects / colonet / utilities / robot_wireless_relay / rangefinder.h @ 13
History | View | Annotate | Download (1.58 KB)
1 |
#ifndef _RANGEFINDER_H_
|
---|---|
2 |
#define _RANGEFINDER_H_
|
3 |
|
4 |
#define RANGE_IN0 PIN_C0
|
5 |
//old range_in0
|
6 |
//#define RANGE_IN0 PIN_AN5
|
7 |
|
8 |
/* These do not exist yet.
|
9 |
#define RANGE_IN1 PIN_??
|
10 |
#define RANGE_IN2 PIN_
|
11 |
#define RANGE_IN3 PIN_
|
12 |
#define RANGE_IN4 PIN_
|
13 |
#define RANGE_IN5 PIN_
|
14 |
#define RANGE_IN6 PIN_
|
15 |
#define RANGE_IN7 PIN_
|
16 |
*/
|
17 |
|
18 |
#define RANGE_CTRL PIN_C1
|
19 |
//old range_crtl
|
20 |
//#define RANGE_CTRL PIN_A7
|
21 |
|
22 |
#define THRESHOLD1 114 |
23 |
#define THRESHOLD2 110 |
24 |
#define THRESHOLD3 101 |
25 |
#define THRESHOLD4 85 |
26 |
#define OFFSET1 65 |
27 |
#define OFFSET2 63 |
28 |
#define OFFSET3 60 |
29 |
#define GAIN1 1525 |
30 |
#define GAIN2 1520 |
31 |
#define GAIN3 1525 |
32 |
#define CONTINUITY_FIX 39 |
33 |
#define MAX_DIST 61 |
34 |
|
35 |
#define MIN_DIST 8 |
36 |
|
37 |
#ifdef FFPP
|
38 |
// IR range finders are indexed 0-4.
|
39 |
// IR1 is front left, IR2 is front center, IR3 is front right, IR4 is rear right, IR5 is rear left.
|
40 |
|
41 |
// active low
|
42 |
#define IR_ENABLE PC7
|
43 |
|
44 |
/* Nasty IR approximation table
|
45 |
I'm using this for the heck of it. We can do whatever.
|
46 |
|
47 |
Note the minimum value is .4V (20), and the maximum is 2.6V (133).
|
48 |
Gives distance in mm.
|
49 |
|
50 |
excel formula(valid for inputs 20-133): ROUND(2353.6*(E2^(-1.1146))*10,0)
|
51 |
|
52 |
This is only valid for the GP2D12, with objects directly ahead and more than
|
53 |
10cm from the detector. See the datasheet for more information.
|
54 |
*/
|
55 |
#define MIN_IR_ADC8 20 |
56 |
#define MAX_IR_ADC8 133 |
57 |
|
58 |
|
59 |
void enable_IR(void); |
60 |
void disable_IR(void); |
61 |
int read_IR_val(int); |
62 |
int convert_IR_distance(int); |
63 |
int get_IR_distance(int); |
64 |
#endif
|
65 |
|
66 |
int read_distance(int range_id); |
67 |
int linearize_distance(int reading); |
68 |
int log_distance(int distance); |
69 |
|
70 |
#endif
|