Revision 1295 trunk/code/projects/diagnostic_station/station/test_encoders.c
| test_encoders.c (revision 1295) | ||
|---|---|---|
| 4 | 4 |
|
| 5 | 5 |
#include "hardware.h" |
| 6 | 6 |
|
| 7 |
// TODO as parameters |
|
| 8 |
#define num_measurements 4 |
|
| 9 |
#define velocity 200 |
|
| 10 |
#define on_delay 500 |
|
| 11 |
#define off_delay 800 |
|
| 12 |
|
|
| 13 | 7 |
// ****************** |
| 14 | 8 |
// ** Data sending ** |
| 15 | 9 |
// ****************** |
| ... | ... | |
| 42 | 36 |
// ** Internal functions ** |
| 43 | 37 |
// ************************ |
| 44 | 38 |
|
| 45 |
static void test_encoders_direction (uint8_t direction1, uint8_t direction2) |
|
| 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) |
|
| 46 | 40 |
{
|
| 47 | 41 |
// Allocate space for the data on the stack |
| 48 | 42 |
int16_t *data_station_l =malloc (num_measurements*sizeof (uint16_t)); |
| ... | ... | |
| 82 | 76 |
// ** Public functions ** |
| 83 | 77 |
// ********************** |
| 84 | 78 |
|
| 79 |
#define NUM 4 |
|
| 80 |
#define VEL 200 |
|
| 81 |
#define ON_DELAY 500 |
|
| 82 |
#define OFF_DELAY 800 |
|
| 83 |
|
|
| 85 | 84 |
void test_encoder_all (void) |
| 86 | 85 |
{
|
| 87 | 86 |
usb_puts("# Testing encoders" NL);
|
| 88 | 87 |
|
| 89 |
test_encoders_direction (motor_direction_forward, motor_direction_backward); |
|
| 90 |
test_encoders_direction (motor_direction_backward, motor_direction_forward); |
|
| 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); |
|
| 91 | 90 |
|
| 92 | 91 |
usb_puts("# Testing encoders finished" NL);
|
| 93 | 92 |
} |
| ... | ... | |
| 96 | 95 |
{
|
| 97 | 96 |
if (num==1) |
| 98 | 97 |
{
|
| 99 |
test_encoders_direction (motor_direction_forward, motor_direction_off); |
|
| 100 |
test_encoders_direction (motor_direction_backward, motor_direction_off); |
|
| 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); |
|
| 101 | 100 |
} |
| 102 | 101 |
else if (num==2) |
| 103 | 102 |
{
|
| 104 |
test_encoders_direction (motor_direction_off, motor_direction_forward); |
|
| 105 |
test_encoders_direction (motor_direction_off, motor_direction_backward); |
|
| 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); |
|
| 106 | 105 |
} |
| 107 | 106 |
} |
Also available in: Unified diff