Datasheet
Chapter 8 • Robot Control with Distance Detection
266 • Robotics with the BOE Shield-Bot
3. What statement is used to sweep through the list of frequencies used for IR
distance measurements?
4. What’s a summing junction?
5. In our closed loop proportional control block diagrams, what two values are used
to calculate the error term?
6. How do delays in the
loop function contribute to setting the sampling rate?
Exercise
1. Write a segment of code that does the frequency sweep for just four frequencies
instead of five.
Project
1. Write a sketch that allows you to hold your hand in front of the BOE Shield-Bot
and push it backwards and forwards with no turning.
Question Solutions
1. The relative sensitivity at 35 kHz is 30%. For 36 kHz, it’s 50%.
2. Precede a variable declaration with the
const keyword.
3. A
for loop that starts indexing at 38000 and increases by 1000 with each
repetition.
4. A summing junction is a part of a block diagram that indicates two inputs are
added together (or one subtracted from another) resulting in an output.
5. The error term is the measured level subtracted from the desired set point level.
6. If a distance sample is taken with each repetition of the
loop function, then the
delays more or less determine how long it takes between each sample. That’s
called the sample interval, and 1 ÷ sample interval = sampling rate.
Exercise Solution
1. Just reduce the for statement’s condition from f <=42000 to f <= 41000.
for(long f = 38000; f <= 42000; f += 1000) {
distance += irDetect(irLedPin, irReceivePin, f);
}
// Declarations
const int setpoint = 2; // Target distances
const int kpl = -45; // Proportional control constants
const int kpr = -55;