Project

General

Profile

Statistics
| Revision:

root / trunk / code / projects / diagnostic_station / station / test_encoders.c @ 1202

History | View | Annotate | Download (1.2 KB)

1
#include "test_encoders.h"
2
#include "global.h"
3
#include "comm_robot.h"
4

    
5
#define num_measurements 4
6
#define velocity 200
7
#define on_delay 500
8
#define off_delay 800
9

    
10
void test_encoders_direction (uint8_t direction1, uint8_t direction2)
11
{
12
        // reset_encoders ();
13
        for (uint8_t m=0; m<num_measurements; ++m)
14
        {
15
                robot_set_motors (direction1, velocity, direction2, velocity);
16
                delay_ms (on_delay);
17
                
18
                robot_set_motors_off ();
19
                delay_ms (off_delay);
20

    
21
                // TODO use the robot_set_motors_time function, but wait for completion
22
                // message from robot
23
                
24
                // TODO instead of waiting a fixed time, wait until the wheels
25
                // are not moving any more, using the station's encoders.
26
        
27
        //        send (turn motor on for time)
28
        //        wait (done)
29
        //        wait_stopped
30
        //        send (read encoders)
31
        //        receive (data)
32
        //        read encoders
33
        }
34

    
35
}
36

    
37
void test_encoder_all (void)
38
{
39
        usb_puts("# Testing encoders" NL);
40

    
41
        test_encoders_direction (FORWARD, BACKWARD);
42
        test_encoders_direction (BACKWARD, FORWARD);
43

    
44
        //send data
45
        
46
        usb_puts("# Testing encoders finished" NL);
47
}
48

    
49
void test_encoder (uint8_t num)
50
{
51
        if (!(num==1 || num==2)) return;
52
        
53
        // TODO implement single encoder testing
54
        test_encoder_all ();
55
}