Sei sulla pagina 1di 3

1

Matching Balls
Cesar Hernndez Cid A01097015
David Escobar Castillejos A01170737
ITESM Campus Puebla
Puebla, Puebla. Mxico
Embedded Systems
Abstract the next document is a report of the final project,
Matching Balls, this application consists on a game similarly to the
snake game. Matching Balls is a game that uses the accelerometer,
as the control, and wav sound to provide a nice interaction with the
user. This report provides the information used in the development
of the application.

Keywords PIC32, accelerometer, wav sounds, peripherals,


game, GDD, graphic, interface, embedded system.

I. INTRODUCTION
Technology has advanced across the history. Actually one
kind of systems that is usually used in the field of electronic
components is embedded systems. They are computer system
designed to perform one or a few dedicated functions often
with real-time computing constraints. These systems are
controlled by one or more main processing cores that are
typically either microcontrollers or digital signal processor.
Microchip
has
developed
different
kinds
of
microcontrollers. They cover the families from 8-bit to the
newest, the 32-bit family, known as PIC32. Throughout the
course, the compiler C32 was used for software applications
development, reaching its final stage with the incorporation of
FreeRTOS, that provides the embedded systems a boost in it
processing stages.

The codec incorporates a multi-bit oversampled sigma-delta


ADC. The output of the ADCs is now applied to a group of
digital filters, which prepare the digital signal for the digital
audio interface. Its DAC filters perform a signal processing
over the incoming data from the digital audio interface to
reflect the sample frequency selected. Finally, the line output
can be made pass through an amplifier before it is injected into
the headphone output; the gain of the amplifier and the mute
condition are under software control
C. Graphic Interface
The Microchip Graphics Library (MGL) is organized in
layers in order to keep the library hardware-independent. The
development of graphics is based on a set of primitives such as
lines, circles, bars, etc.; making use of theses, complex
animations can be rendered. The library also includes support
for message-passing devices and peripheral. Using this
approach, a seamless integration between user interaction and
graphics is easily implemented.
d. FreeRtos
It is an operative system which is designed for optimizing
the resources of the CPU, and the core, whit the help of the
Rtos we can create independent tasks and make a better use of
the resources and peripherals.

II. THEORETICAL BACKGROUND.


III. PROJECT DEVELOPMENT.
A. Accelerometer / gyroscope.
A gyroscope is
a
device
for
measuring
or
maintaining orientation, based on the principles of angular
momentum. In short, a gyroscope is a spinning wheel whose
axle is free to take any orientation. It changes in response to an
external torque much less and in a different direction than it
would without the large angular momentum associated with
the disk's high rate of spin and moment of inertia. Since
external torque is minimized by mounting the device
in gimbals, its orientation remains nearly fixed, regardless of
any motion of the platform on which it is mounted.
B. Wav Sounds
One of the main applications of a multimedia embedded
system is speech and audio processing. PIC32 supports this
type of applications, using the Multimedia Expansion Board,
by providing the codec WM8731.

Matching balls follows a simple logic diagram; however,


the interesting part of its development was the implementation
of all learnt in the course of embedded systems. The following
flow chart explains the function of the whole application.

Firstable, we create two tasks in FreeRtos, the GolTask and


the Screen2 task which contain all the game,
The first task only is in charge of the GoLDraw and the
process of the message. This task has the low priority but it
sends a value to the queue for the permission to the
Screen2 task with the highest priority, so once the first screen
is printed, we initialize the game with the screen in two
different ways : press in the play button and/or tilt the screen ,

when the values are in two different ranges, we add 1 pixel


to the actual position, in another two different ranges we add
two pixels, to the actual position.
Also we limit the values in the bottom, top, right and left of
the screen to see all the time the circle in the screen.

Fig1. Tasks with the priority.

Fig.3 ranges of values of accelerometer.


Fig.2 TaskGolMsg
One of the main algorithms is the reading of the values of
the accelerometer and deciding how we are going to draw the
big circle (snake), so we implement the next solution.

Firstable we read the values:

THE DRAW AND THE MATCH ALGORITHM


In this section, we decide that only we are going to draw the
circle only if there is a new data of the accelerometer, this is
with the help of the variables posxpasada and posypasada.
For the match of the balls, we compare if the position (x,y)
of the big circle(snake) and the little circle are the
same.(2x,2y), if there is a match we increase the radio of the
circle, activate two variables, and make a break to draw the
little circle in another position

for(i=0;i<10;i++) //we read the ten registers and save


{
data[i] = I2CRandomRead(i);
}
valorejex=data[3];//we select only axis x and y
valorejey=data[5];

once we have the values of the axis, we specify four


different ranges to decide how much we are going to increase
or decrease the position in x and y of the circle, so the
algorithm is the next:

Fig.4 draws the new position of the big circle only.

The following problem is in the sound library. Many


attempts were tried to solve the problem of joining it in the
main software. We had also a difficult time in previous
attempts in the course.
Finally the integration using FreeRTOS was difficult. We
still have some bugs in the application; however, it works
correctly. We had problems that covers from priorities and
the handlers applied in the software. After many tries and
modifications in the general logic and in the structure of the
game, we finally integrated it.
Fig.6 matchs algorithm

This kind of project provides us a new perspective and


new solutions to problems or projects that in a near future we
can apply to facilitate the procedures involved in the
development of any project. Finally, we would like to thanks
to the support of the professionals and professor that provide
us knowledge in the subject. In short, all this knowledge
permitted us to obtain the desire results.
V. REFERENCES.
Multimedia Board Users Guide (DS61160A)
Antonio, D. Presentations provided in the course
Embedded Systems (ITESM).
PIC32MX7XX Family Data Sheet (61156G)
BMA150_DataSheet_Rev.1.5_30May2008
24LC08 (I2C memory)

fig.7 limit in the bottom of the screen.


Another important consideration about the troubles was:
The correct selection of the algorithm in the drawing of the
circles, problems with the incorporation of the audio wav in
freeRtos, FreeRtos does not permit us the correct function of
the next level of the game and the time for each ball, so we
sacrifice this specification in order to use the operative system.
We attach the project for more specifications of the game.
Finally if the level was not complete, the screen go to the
game over screen.
IV. CONCLUSION.
It is important to always count on what is going to come;
these types of projects are so complicated that the minimal
not considered thing can change everything. We had first the
problem with the accelerometer and his axis. We face
problems in the initialization and the correct management of
the data received. After we identify in which part of the code
it needs to be placed, we started thinking about the best
algorithm to make the smoothest move and the limitation of
the screen. We tried 3 different cases and we established that
the best was the one that is described in the project
development part. We accomplished them and we continue
with the integration of the sound effects in the game.

Potrebbero piacerti anche