Revision 1549
Updated IR rangefinder lookup table. Now reports in millimeters with an accuracy of +-10mm.
trunk/code/lib/include/libdragonfly/rangefinder.h | ||
---|---|---|
53 | 53 |
/** @brief IR Rangefinder 5 **/ |
54 | 54 |
#define IR5 2 |
55 | 55 |
/** @brief smallest meaningful rangefinder reading (logarithmic scale) **/ |
56 |
#define MIN_IR_ADC8 20
|
|
56 |
#define MIN_IR_ADC8 27
|
|
57 | 57 |
/** @brief largest meaningful rangefinder reading (logarithmic scale) **/ |
58 |
#define MAX_IR_ADC8 133
|
|
58 |
#define MAX_IR_ADC8 98
|
|
59 | 59 |
|
60 | 60 |
/** @brief Initialize the rangefinders **/ |
61 | 61 |
void range_init(void); |
trunk/code/projects/template/main.c | ||
---|---|---|
11 | 11 |
while (1) { |
12 | 12 |
|
13 | 13 |
usb_puts("Val: "); |
14 |
bom_refresh(BOM_ALL); |
|
15 |
usb_puti(bom_get_max()); |
|
16 |
|
|
14 |
usb_puti(range_read_distance(IR2)); |
|
17 | 15 |
usb_putc('\n'); |
18 | 16 |
|
19 | 17 |
delay_ms(200); |
trunk/code/projects/libdragonfly/rangefinder.c | ||
---|---|---|
88 | 88 |
10cm from the detector. See the datasheet for more information. |
89 | 89 |
*/ |
90 | 90 |
|
91 |
static int IR_dist_conversion[114] PROGMEM = { |
|
92 |
800,791,751,714,681,651,623,597,574,552,531,512,494,478,462,447 |
|
93 |
,434,421,408,397,386,375,365,356,347,338,330,322,315,307,301,294 |
|
94 |
,288,282,276,270,265,260,255,250,245,241,237,232,228,224,221,217 |
|
95 |
,213,210,207,203,200,197,194,191,189,186,183,181,178,176,173,171 |
|
96 |
,169,166,164,162,160,158,156,154,152,151,149,147,145,144,142,140 |
|
97 |
,139,137,136,134,133,131,130,129,127,126,125,124,122,121,120,119 |
|
98 |
,118,117,115,114,113,112,111,110,109,108,107,106,105,105,104,103 |
|
99 |
,102,101 |
|
91 |
static int IR_dist_conversion[72] PROGMEM = { |
|
92 |
327,315,303,291,281,271,262,253,245,238,231,224,218,212,206,200, |
|
93 |
195,190,185,181,177,173,168,165,161,158,155,151,148,145,143,140, |
|
94 |
137,134,132,130,127,125,123,121,119,117,115,114,111,110,108,106, |
|
95 |
105,104,102,100,99,98,97,95,94,93,91,90,89,88,87,86,84,83,83,82, |
|
96 |
81,80,79,78 |
|
100 | 97 |
}; |
101 | 98 |
|
102 | 99 |
/** |
trunk/code/projects/libdragonfly/rangefinder.h | ||
---|---|---|
53 | 53 |
/** @brief IR Rangefinder 5 **/ |
54 | 54 |
#define IR5 2 |
55 | 55 |
/** @brief smallest meaningful rangefinder reading (logarithmic scale) **/ |
56 |
#define MIN_IR_ADC8 20
|
|
56 |
#define MIN_IR_ADC8 27
|
|
57 | 57 |
/** @brief largest meaningful rangefinder reading (logarithmic scale) **/ |
58 |
#define MAX_IR_ADC8 133
|
|
58 |
#define MAX_IR_ADC8 98
|
|
59 | 59 |
|
60 | 60 |
/** @brief Initialize the rangefinders **/ |
61 | 61 |
void range_init(void); |
Also available in: Unified diff