PANTS • THE CHRONICLES OF PARTICIPANTS • THE CHRONICLES O
frequency variations are achieved in the ISR of timer 4.
The PWM is generated by setting and complementing
bit 12 of PORTF. The duty factor of the generated signal is
varied by inserting the condition: TMR4<(PR4*0.75). PR4,
the period register, and the scalar 0.75 is used to condition
the parts of the rectangular signal for which a certain value
is sent to the output:
shows a welcome message, then asks for the current time.
A combination of buttons and switches is used to set and
save it, as well as the alarm time. It is important to note
that while either the time or the alarm is being set, the
screen is stable; it doesn’t fluctuate.
The LCD screen is also updated to show the current
time. This is done every time the first or second digit of the
minute/hour changes. If the current time reaches the alarm
time, the screen shows the “ALARM!!!” message.
In order to vary the signal a little to make it as
annoying as possible, the following simple algorithm has
been developed, which changes the pitch and the period of
the signal by modifying the period register according to the
variables x and aux:
The purpose of the ADC (analog-to-digital converter) is
to convert sensor data into a format readable and
interpretable by the processor. This piece is essential since it
drives the entire motion of the robot, in function of the
front and back sensor input data.
The ADC incorporated in the PIC32 used is a 10-bit
successive approximation register. Three channels are used
— one for each sensor — so the results are stored in three
The servo control block implements
the movement and locking mechanisms
of the platform on which the third
sensor is situated (described above).
The SPI (Serial Peripheral Interface)
is a synchronous interface used for
communicating with external
peripherals. In our case, it’s used to
control the PMOD CLS. The functioning
of the SPI communication involves a
buffer, SPIxBUF, which gets data from
the internal data bus of the
microcontroller. The data is then
transmitted to two registers: SPIxRXB
and SPIx TRX. The first is responsible for
receiving data from the peripheral, the
second is responsible for transmitting.
These are FIFO (First In, First Out)
buffers working in Enhanced Buffer
The SPI operations require that the
devices involved are designated master
or slave. In this case, the PIC32MX4 has
been designated the master and the
PMODCLS as the slave device.
When started, the LCD screen
SERVO 12.2012 55