Project

General

Profile

Revision 1212

Finished the bom test (calling the not-finished hardware functions for now)

View differences:

trunk/code/projects/diagnostic_station/station/test_bom.c
1 1
#include "test_bom.h"
2 2
#include "global.h"
3 3

  
4
#include "hardware_turntable.h"
5
#include "hardware_rbom.h"
6
#include "comm_robot.h"
7

  
8
static uint16_t bom_emitter_position (uint8_t num)
9
{
10
	switch (num)
11
	{
12
		case 0:  return  100; break;
13
		case 1:  return  200; break;
14
		case 2:  return  300; break;
15
		case 3:  return  400; break;
16
		case 4:  return  500; break;
17
		case 5:  return  600; break;
18
		case 6:  return  700; break;
19
		case 7:  return  800; break;
20
		case 8:  return  900; break;
21
		case 9:  return 1000; break;
22
		case 10: return 1100; break;
23
		case 11: return 1200; break;
24
		case 12: return 1300; break;
25
		case 13: return 1400; break;
26
		case 14: return 1500; break;
27
		case 15: return 1600; break;
28
		default: return 0; break;
29
	}
30
}
31

  
32
static uint16_t bom_detector_position (uint8_t num)
33
{
34
	return bom_emitter_position (num)-50;
35
}
36

  
37

  
4 38
void test_bom_bitmask (uint16_t emitter_bitmask, uint16_t detector_bitmask)
5 39
{
6 40
	usb_puts("# Testing BOM" NL);
......
9 43
	{
10 44
		if (emitter_bitmask&1)
11 45
		{
46
			uint16_t values[4];
47
			
12 48
			usb_puts("# Testing BOM emitter ");
13 49
			usb_puti(n);
14 50
			usb_puts(NL);
15
	//		rotate (emitter position)
16
	//		send (turn on only light i)
17
	//		wait (done)
18
	//		read values
19
	//		send (turn off lights)
20
	//		wait (done)
21
	//send data
22
			usb_puts ("data bom emitter ");
23
			usb_puti (n);
24
			usb_puts (" 1 2 3 4");
51
			
52
			turntable_rotate_to_position (bom_emitter_position (n));
53
			robot_set_bom (1<<n); // TODO check: wait until done
54
		
55
			rbom_update ();
56
#define N 0
57
#define E 1
58
#define S 2
59
#define W 3
60
			values[N]=rbom_read (RBOM_SENSOR_N);
61
			values[E]=rbom_read (RBOM_SENSOR_E);
62
			values[S]=rbom_read (RBOM_SENSOR_S);
63
			values[W]=rbom_read (RBOM_SENSOR_W);
64

  
65
			robot_set_bom (0); // TODO check: wait until done
66

  
67
			// Send data
68
			usb_puts ("data bom emitter");
69
			usb_puts (" N/"); usb_puti (values[N]);
70
			usb_puts (" E/"); usb_puti (values[E]);
71
			usb_puts (" S/"); usb_puti (values[S]);
72
			usb_puts (" W/"); usb_puti (values[W]);
73
#undef N
74
#undef E
75
#undef S
76
#undef W
25 77
			usb_puts (NL);
26 78
		}
27 79
		
......
30 82
			usb_puts("# Testing BOM detector ");
31 83
			usb_puti(n);
32 84
			usb_puts(NL);
33
	//		rotate (detector position)
34
	//		
35
	//		turn light on
36
	//		send (read data)
37
	//		receive (data)
38
	//		turn lights off
39
	//		send (read data)
40
	//		receive (data)
41
	//send data
85
			turntable_rotate_to_position (bom_detector_position (n));
86

  
87
			rbom_set (true);
88
			uint16_t on_value=robot_read_bom (n);
89
			rbom_set (false);
90
			uint16_t off_value=robot_read_bom (n);
91

  
92
			// Send data
42 93
			usb_puts ("data bom detector ");
43 94
			usb_puti (n);
44
			usb_puts (" 1");
95
			usb_puts (" on/");
96
			usb_puti (on_value);
97
			usb_puts (" off/");
98
			usb_puti (off_value);
45 99
			usb_puts (NL);
46 100
		}
47
		
48
	//	turn lights off
49 101
	}
50
	
51 102

  
52 103
	usb_puts("# Testing BOM finished" NL);
53 104
}
trunk/code/projects/diagnostic_station/station/hardware_turntable.c
7 7

  
8 8
void turntable_rotate_to_position (uint16_t position)
9 9
{
10
	usb_puts ("# Rotating to position ");
10
	usb_puts ("# Turntable rotating to ");
11 11
	usb_puti (position);
12 12
	usb_puts (NL);
13 13
	
14 14
	// FIXME implement
15 15
	
16
	usb_puts ("# Robot position reached");
16
	usb_puts ("# Turntable position reached" NL);
17 17
}
18 18

  
trunk/code/projects/diagnostic_station/station/hardware_turntable.h
5 5
#include "global.h"
6 6

  
7 7
void turntable_init (void);
8
void turntable_rotate_to_position (uint16_t position);
8 9

  
9 10
#endif
trunk/code/projects/diagnostic_station/station/comm_robot.c
127 127
	return data_received;
128 128
}
129 129

  
130
uint16_t robot_read_bom (uint8_t num)
131
{
132
	// FIXME implement
133
	return 0;
134
}
135

  
136

  
130 137
void receive_encoders(int* data, int length){
131 138
	((int*)data_received)[0] = data[0];
132 139
	((int*)data_received)[1] = data[1];
trunk/code/projects/diagnostic_station/station/comm_robot.h
9 9
void robot_set_motors (uint8_t direction1, uint8_t speed1, uint8_t direction2, uint8_t speed2);
10 10
void robot_set_motors_off (void);
11 11
void robot_set_bom (uint16_t bitmask);
12

  
12 13
char* robot_read_encoders (void);
14
uint16_t robot_read_bom (uint8_t num);
15

  
13 16
void robot_station_receive(char type, int source, unsigned char* packet, int length);
14 17

  
15 18
#define motor_direction_off 0
trunk/code/projects/diagnostic_station/station/hardware_rbom.h
8 8
 * Inverse BOM sensor macros for (N)orth,
9 9
 * (S)outh, (E)ast, and (W)est positions.
10 10
 */
11
#define N_SENSOR AN3
12
#define E_SENSOR AN4
13
#define S_SENSOR AN5
14
#define W_SENSOR AN6
11
#define RBOM_SENSOR_N AN3
12
#define RBOM_SENSOR_E AN4
13
#define RBOM_SENSOR_S AN5
14
#define RBOM_SENSOR_W AN6
15 15

  
16 16
void rbom_init (void);
17 17

  
trunk/code/projects/diagnostic_station/station/comm_server.c
214 214

  
215 215
static void handle_message_start_test_bom (char *buffer)
216 216
{
217
	// TODO: handle start_test bom _emitter/detector_ all/num
217 218
	handle_message_start_test_component (buffer, test_bom_all_helper, test_bom_helper);
218 219
}
219 220

  
......
305 306
// ## Main loop ##
306 307
// ###############
307 308

  
308
static void ready ()
309
static void ready (void)
309 310
{
310 311
	usb_puts ("# Ready" NL);
311 312
}

Also available in: Unified diff