63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// The variable c will have values from 0 to 9, since
// values are in the range of 0 to 1000, and 1000/101 is 9
// with integer math.
char
c = bar_graph_characters[sensors[i]/101];
// Display the bar graph characters.
print_character(c);
}
}
// set the motor speeds
void
slave_set_motors(
int
speed1,
int
speed2)
{
char
message[4] = {0xC1, speed1, 0xC5, speed2};
if
(speed1 < 0)
{
message[0] = 0xC2;
// m1 backward
message[1] = -speed1;
}
if
(speed2 < 0)
{
message[2] = 0xC6;
// m2 backward
message[3] = -speed2;
}
serial_send_blocking(message,4);
}
// do calibration
void
slave_calibrate()
{
serial_send(
"\xB4"
,1);
int
tmp_buffer[5];
// read 10 characters (but we won't use them)
serial_receive_blocking((
char
*)tmp_buffer, 10, 100);
}
// reset calibration
void
slave_reset_calibration()
{
serial_send_blocking(
"\xB5"
,1);
}
// calibrate (waits for a 1-byte response to indicate completion)
void
slave_auto_calibrate()
{
int
tmp_buffer[1];
serial_send_blocking(
"\xBA"
,1);
serial_receive_blocking((
char
*)tmp_buffer, 1, 10000);
}
// sets up the pid constants on the 3pi for line following
void
slave_set_pid(
char
max_speed,
char
p_num,
char
p_den,
char
d_num,
char
d_den)
{
char
string[6] =
"\xBB"
;
string[1] = max_speed;
string[2] = p_num;
string[3] = p_den;
string[4] = d_num;
string[5] = d_den;
serial_send_blocking(string,6);
}
Pololu 3pi Robot User’s Guide
© 2001–2019 Pololu Corporation
10. Expansion Information
Page 79 of 85
Содержание 0J5840
Страница 24: ...Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 5 How Your 3pi Works Page 24 of 85...
Страница 67: ...Source code Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 10 Expansion Information Page 67 of 85...
Страница 77: ...Source code Pololu 3pi Robot User s Guide 2001 2019 Pololu Corporation 10 Expansion Information Page 77 of 85...