Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / unit_tests / test_ir.c @ 1979

History | View | Annotate | Download (1.44 KB)

1
/* 
2
 * This test is for the old line following sensors formerly installed on
3
 * bickles, which did not use a mux and have a different method of reading
4
 * compared to the current line following sensors (the ones with the mux and
5
 * the row of 8 IR emitters/recievers on the bottom of the robot).
6
 *
7
 * For a test that tests the new IR sensors, see test_linefollow.c
8
 */
9
#include <dragonfly_lib.h>
10

    
11
#define TEST_PORT                3
12
#define TEST_ALL                1
13
#define TEST_INDIV                0
14

    
15
int testir(void)
16
{
17
        analog_init(0);
18
        int port;
19
        int ports[] = {13, 12, 3, 2, 9, 8, 1};
20
//        analog_init(ADC_START);
21
//        usb_puti(analog_loop_status());
22
        
23
        if(TEST_ALL)
24
        {
25
                if(TEST_INDIV)
26
                {
27
                        while(1)
28
                        {        
29
                                for(port = 0; port <5; port++)
30
                                {
31
                                        usb_puti(analog_get10(ports[port]));
32
                                        usb_putc('\t');
33
                                }
34
                                
35
                                for(port = 5; port <7; port++)
36
                                {
37
                                        usb_puti(analog_get10(ports[port]));
38
                                        usb_putc('\t');
39
                                }
40
                                usb_putc('\n');
41
                                delay_ms(50);
42
                        }
43
                
44
                }
45
                else
46
                {        
47
                        while(1)
48
                        {        
49
                                for(port = 0; port <= 6; port++)
50
                                {
51
                                        usb_puti(analog_get10(ports[port]));
52
                                        usb_putc('\t');
53
                                }
54
                                usb_putc('\n');
55
                                delay_ms(50);
56
                        }
57
                }
58
        }
59
        else
60
        {
61
                while(1)
62
                {        
63
                        usb_puti(analog_get10(ports[TEST_PORT]));
64
                        usb_putc('\n');
65
                        delay_ms(50);
66
                }
67

    
68
        }
69

    
70
        return 0;
71
}
72
/*Mapping of IR sensor to port number:
73
Line following (L to R on robot):
74
1: 5
75
2: 4
76
3: 3
77
4: 2
78
5: 9
79

80
Bar-code reading:
81
L: 8
82
R: 1
83
*/