Pololu 3pi Guía De Usuario página 35

Tabla de contenido

Publicidad

19.
// the most recent result immediately.
20.
void send_sensor_values(char calibrated)
21.
{
22.
if(calibrated)
23.
{
24.
if(!pid_enabled)
25.
read_line_sensors_calibrated(sensors, IR_EMITTERS_ON);
26.
}
27.
else
28.
read_line_sensors(sensors, IR_EMITTERS_ON);
29.
serial_send_blocking((char *)sensors, 10);
30.
}
31.
// Sends the raw (uncalibrated) sensor values.
32.
void send_raw_sensor_values()
33.
{
34.
send_sensor_values(0);
35.
}
36.
// Sends the calibated sensor values.
37.
void send_calibrated_sensor_values()
38.
{
39.
send_sensor_values(1);
40.
}
41.
// Computes the position of a black line using the read_line()
42.
// function, and sends the value.
43.
// Returns the last value computed if PID is running.
44.
void send_line_position()
45.
{
46.
int message[1];
47.
unsigned int tmp_sensors[5];
48.
int line_position;
49.
if(pid_enabled)
50.
line_position = last_proportional+2000;
51.
else line_position = read_line(tmp_sensors, IR_EMITTERS_ON);
52.
message[0] = line_position;
53.
serial_send_blocking((char *)message, 2);
54.
}
55.
// Sends the trimpot value, 0-1023.
56.
void send_trimpot()
57.
{
58.
int message[1];
59.
message[0] = read_trimpot();
60.
serial_send_blocking((char *)message, 2);
61.
}
62.
// Sends the batter voltage in millivolts
63.
void send_battery_millivolts()
64.
{
65.
int message[1];
66.
message[0] = read_battery_millivolts();
67.
serial_send_blocking((char *)message, 2);
68.
}
69.
// Drives m1 forward.
70.
void m1_forward()
71.
{
72.
char byte = read_next_byte();
73.
if(check_data_byte(byte))
74.
return;
75.
set_m1_speed(byte == 127 ? 255 : byte*2);
76.
}
77.
// Drives m2 forward.
78.
void m2_forward()
79.
{
80.
char byte = read_next_byte();
81.
if(check_data_byte(byte))
82.
return;
83.
set_m2_speed(byte == 127 ? 255 : byte*2);
84.
}
85.
// Drives m1 backward.
86.
void m1_backward()
87.
{
88.
char byte = read_next_byte();
89.
if(check_data_byte(byte))
90.
return;
91.
set_m1_speed(byte == 127 ? -255 : -byte*2);
92.
}
93.
// Drives m2 backward.
94.
void m2_backward()
95.
{
96.
char byte = read_next_byte();
97.
if(check_data_byte(byte))

Publicidad

Tabla de contenido
loading

Productos relacionados para Pololu 3pi

Tabla de contenido