HE CHRONICLES OF PARTICIPANTS • THE CHRONICLES OF PARTICI
responsible for detecting any obstacles which would
impede the robot in movement. An important factor to
take into account is the directivity angle of the sensors. Be
sure to place them so that they detect any obstacle on a
strip at least as wide as the robot. The third sensor — the
one in the back — is situated directly above the stop button.
We’ve placed this one on a servo platform to overcome the
narrow directivity angle problem and to reduce costs by
eliminating the need for additional sensors.
The platform rotates approximately 180 degrees, so it
covers the entire area from which the user can approach.
The sensors are then connected to the CON3. The RTCC
module — which uses the I2C protocol — has to be
connected to one of the two onboard I2C connectors. The
servo also has its corresponding power and control pins
which can be chosen from the eight servo connector pin
sets. The AMP module features a mono speaker and a
headphone jack; for the purpose of this design, the speaker
jack was used. Every other Pmod is connected to an
onboard port, JA to JK. A detailed connection diagram is
shown in Figure 1.
The software we used was:
• Microchip MPLab v8.83
• Microchip MPLab C32 C compiler
• The appropriate driver for the programmer interface
The software follows a modular approach, meaning
individual parts can be extracted and used without too
much modification in other projects. Let’s discuss the
different parts of Figure 2.
54 SERVO 12.2012
The real time clock and calendar can be considered the
heart of the alarm process. It generates the alarm signal
and thereby the trigger for the audio signal generation and
the servo motor motion. It saves the current time and the
time of the alarm. In the event of central power loss, a
battery guarantees that the settings are kept.
The RTCC communicates with the PIC through the I2C
communication protocol which features a master-slave logic.
This means that they can each independently generate
interrupts based on their own events.
This functional block implements the control
mechanisms for the two DC motors. It contains several
predefined blocks which signify forward, reverse movement,
rotations in either direction, and an algorithm designed to
avoid obstacles. The motor drive principle is PWM. The idea
is that by varying the duty cycle of a rectangular signal, the
speed of the motors also varies. Two PmodHB5 circuits are
used to drive the motors.
The main.c source file contains the algorithm used to
avoid obstacles. The filtered sensor data and three functions
— one for each sensor — are used to set thresholds which
will condition the movement of the robot. Each sensor
reads data from values 0x000 to 0x3FF, so the obstacle
detection thresholds have been set at 0x200 for each
sensor. Also, the primary condition for motion is that the
sensor on the servo detects the user. The conditions in the
loops and branches within the algorithm are continuously
checked. If they are fulfilled, the corresponding motion is
It is important to note that before every change in
motor direction, it is advisable to stop the motors and
introduce a few ms delay in order to avoid a possible short
circuit, since the switching times of the transistors in the H-bridge are limited.
This block implements the generation of the audio
signal. This is done practically using a one-bit DAC (
digital-to-analog converter). The code generates a PWM signal (the
principle of pulse width modulation is the modulation of
the pulse width of a rectangular signal, thereby modifying
the average value of the waveform) at an audible
frequency, varies it according to a predefined rule, then the
signal is transmitted to the AMP1 Pmod which amplifies
and conditions the signal such that it is ready to be played
using the speaker.
The audio is a pulse width modulated signal using
timers 4 and 5 on PORTF of the board. The PWM is
conditioned by the variable trigger which is set when the
RTCC gives the alarm signal. The PWM is done in the
Interrupt Service Routine (ISR) of timer 5, while the