Revision 1297
| trunk/code/projects/diagnostic_station/station/test_encoders.c (revision 1297) | ||
|---|---|---|
| 9 | 9 |
// ****************** |
| 10 | 10 |
|
| 11 | 11 |
static void send_encoder_data (uint8_t num, uint8_t direction, |
| 12 |
int16_t *data_station, int16_t *data_robot) |
|
| 12 |
int16_t *data_station, int16_t *data_robot, uint8_t num_measurements) |
|
| 13 | 13 |
{
|
| 14 | 14 |
if (direction!=motor_direction_off) |
| 15 | 15 |
{
|
| ... | ... | |
| 36 | 36 |
// ** Internal functions ** |
| 37 | 37 |
// ************************ |
| 38 | 38 |
|
| 39 |
static void test_encoders_direction (uint8_t direction1, uint8_t direction2, uint8_t num_measurements, uint8_t velocity, uint8_t on_delay, uint8_t off_delay) |
|
| 39 |
static void test_encoders_direction (uint8_t direction1, uint8_t direction2, uint8_t num_measurements, uint8_t velocity, uint16_t on_delay, uint16_t off_delay) |
|
| 40 | 40 |
{
|
| 41 | 41 |
// Allocate space for the data on the stack |
| 42 | 42 |
int16_t *data_station_l =malloc (num_measurements*sizeof (uint16_t)); |
| ... | ... | |
| 62 | 62 |
robot_read_encoders (&(data_robot_l[m]), &(data_robot_r[m])); |
| 63 | 63 |
} |
| 64 | 64 |
|
| 65 |
send_encoder_data (0, direction1, data_station_l, data_robot_l); |
|
| 66 |
send_encoder_data (1, direction2, data_station_r, data_robot_r); |
|
| 65 |
send_encoder_data (0, direction1, data_station_l, data_robot_l, num_measurements); |
|
| 66 |
send_encoder_data (1, direction2, data_station_r, data_robot_r, num_measurements); |
|
| 67 | 67 |
|
| 68 | 68 |
free (data_robot_r); |
| 69 | 69 |
free (data_robot_l); |
| ... | ... | |
| 85 | 85 |
{
|
| 86 | 86 |
usb_puts("# Testing encoders" NL);
|
| 87 | 87 |
|
| 88 |
test_encoders_direction (motor_direction_forward , motor_direction_backward, NUM, VEL, ON_DLEAY, OFF_DELAY); |
|
| 89 |
test_encoders_direction (motor_direction_backward, motor_direction_forward , NUM, VEL, ON_DLEAY, OFF_DELAY); |
|
| 88 |
test_encoders_direction (motor_direction_forward , motor_direction_backward, NUM, VEL, ON_DELAY, OFF_DELAY); |
|
| 89 |
test_encoders_direction (motor_direction_backward, motor_direction_forward , NUM, VEL, ON_DELAY, OFF_DELAY); |
|
| 90 | 90 |
|
| 91 | 91 |
usb_puts("# Testing encoders finished" NL);
|
| 92 | 92 |
} |
| ... | ... | |
| 95 | 95 |
{
|
| 96 | 96 |
if (num==1) |
| 97 | 97 |
{
|
| 98 |
test_encoders_direction (motor_direction_forward , motor_direction_off, NUM, VEL, ON_DLEAY, OFF_DELAY); |
|
| 99 |
test_encoders_direction (motor_direction_backward, motor_direction_off, NUM, VEL, ON_DLEAY, OFF_DELAY); |
|
| 98 |
test_encoders_direction (motor_direction_forward , motor_direction_off, NUM, VEL, ON_DELAY, OFF_DELAY); |
|
| 99 |
test_encoders_direction (motor_direction_backward, motor_direction_off, NUM, VEL, ON_DELAY, OFF_DELAY); |
|
| 100 | 100 |
} |
| 101 | 101 |
else if (num==2) |
| 102 | 102 |
{
|
| 103 |
test_encoders_direction (motor_direction_off, motor_direction_forward , NUM, VEL, ON_DLEAY, OFF_DELAY); |
|
| 104 |
test_encoders_direction (motor_direction_off, motor_direction_backward, NUM, VEL, ON_DLEAY, OFF_DELAY); |
|
| 103 |
test_encoders_direction (motor_direction_off, motor_direction_forward , NUM, VEL, ON_DELAY, OFF_DELAY); |
|
| 104 |
test_encoders_direction (motor_direction_off, motor_direction_backward, NUM, VEL, ON_DELAY, OFF_DELAY); |
|
| 105 | 105 |
} |
| 106 | 106 |
} |
Also available in: Unified diff