Project

General

Profile

Statistics
| Revision:

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

History | View | Annotate | Download (1.06 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

    
38
void test_encoders (void)
39
{
40
        usb_puts("# Testing encoders" NL);
41

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

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