Вы находитесь на странице: 1из 16

EE4: Final Report

Electronic Game: Ball Pong

TEAM B_13:
Christophe Cresens
Maarten Derison
Niels Hendrickx
Kristof Pauwels
Dries Van den Eynde
Ball Pong: Engineering report
Intro

The idea of our project is based on a game well known by


students called Beer Pong. The game we developed
works as follows: on a round, spinning, plate are 8 holes.
The aim of the game is to throw a ball in all the holes on
the board while alternating with another player after each
(missed) throw off the holes. Every hole is equipped with
a LDR to detect if a ball was thrown into the hole and two
LEDs to visualise a hit of that hole to create a better and
more entertaining player experience. To make the game
more difficult, the red circle of figure 1 will be able to spin
by giving an input via a joystick on top of the enclosure.

Figure 1: Drawing of our electronic Ball Pong game

The game can be played by two people (or two teams of


multiple players) that compete against each other. Player 1
tries to throw a ball in a hole while player 2 can increase
the difficulty of the game for player 1 by making the round
plate spin clockwise or counter clockwise. A DC-motor
underneath the round plate will drive the movement of the
plate.

Figure 2: Conical shape of holes in rotating plate

Gameplay & Rules

In our electronic Ball Pong game, we implemented a joystick and three buttons: a player button, a
start button and a reset button. These inputs are used as a user interfaces for the game. The game
always starts in idle mode, when the game is first turned on, this mode is recognizable by a small LED
show. When the start button is pressed, the game will start and the player, who will need to throw a
ball first, is randomly chosen by the game. At the bottom of this section a gameplay example is given
to gain a better view on how the game works.

The goal of this game is to be the first player to turn off all its LEDs inside the holes on the spinning
plate. Every time the ball is thrown into a hole, the correspondent LED goes out. When a player misses
a hole, the players have to switch sides but this is not an obligation, only one of the possible rules of
the game.

Although it's already hard to throw the ball into the hole, each player can make it even more difficult
for his opponent by using the joystick on top of the enclosure. This joystick can be used to turn the

1
round plate in clockwise or counter clockwise direction. It is not mandatory to use the joystick to turn
the plate. The choice to turn the plate or not is all up to the players, its an agreement they need to
make between each other whether or not to use the joystick.

There aren't many rules in this game, its based on the creativity of the players and the arrangements
made between the two players before the start of the game. All the participants can use this game
with their own rules.

Here is an example of a game that can be played:

1: Before the start of a game, the players need to decide which color of the LEDs (green or red) they
want to have for their player profile. After selecting their player color, some agreements have to be
made like whether or not the thrower can stay in his position after scoring, or they just take turns
after each throw. After all the rules for the game are discussed, the game can start.

2: After pressing the start button once, the first player will be selected at random. The corresponding
LEDs will light up to show which player starts. As a result all the LEDs of the holes will be visible in a
color of one of the two players.

3: Now the player with the corresponding color on the board, the chosen player color discussed in
step 1, can start with throwing one ball to the holes. As an option, the other player can use the joystick
on top of the enclosure, to turn the playing board and make it more difficult to score a ball in the hole
for the throwing player.

4: If the player succeeds in getting the ball into one hole, the player can proceed with throwing a ball
to the holes, or the player profile needs to be changed according prearranged rules in step 1.
After every miss the player profile has to be changed by pressing the player button once.

5: Now player 2 has a chance to throw a ball to the eight holes which are now illuminated with the
color from the second player profile. The procedure from player 1 is here the same for player 2, to get
a ball in a hole and alter player profile after each miss.

6: The game will go on until one of the players is able to fade out all his/her eight LEDs on the spinning
plate. When this happens, a victory song will be played through the speaker and all his/her LEDs will
start to blink in the color of the winning player. This is the end state of the game.

7: To restart the game, the reset button can be pressed to get back in the idle state.

2
Requirements
In this project its obvious that the first requirement is making a game. The ultimate goal was to deliver
a successful and working game at the end of the semester.

At the end of the project we have to be able to power the spinning part of the game with a battery,
because it is not possible to power the components with a wall adaptor due to the spinning movement
of the board. This is why it is recommended to keep the overall current consumption as low as possible
to extend the battery life of our electronic game drastically. Of course it is possible to switch the
battery when it runs out of power, but it is not practical if you need to do this, for example, every 20
minutes. Another possibility, is to use a battery which has a bigger capacity (mAh). Increasing capacity
corresponds with a higher battery weight and form factor which is not optimal for our application,
where the battery needs to spin around on the plate.

Another requirement is also to encourage the competition between the two players. The fun factor of
the game increases for the players when there is a higher difficulty that can be added by the opponent
player. The addition of a joystick can take care of this.

The small size of the project also comes in handy, because of that it's easy to transport the game
everywhere. Due to the small size of the motor used in our project, the overall weight of the turning
plate needed to be minimized. The balance of this plate was also an important requirement, if the
plate is not balanced correctly it wont turn smoothly. It is therefore recommended to use stabilizing
wheels.

Block diagram

Figure 3: Block diagram for electronics turning plate Figure 4: Block diagram for electronics fixed enclosure

These images above represent a simplistic overview of the electronic components implemented in our
electronic game. The left image represents the PCB that is connected to the spinning plate which is
powered by a battery. This is the main PCB for all the game logic. The right image represents the PCB
that controls the spinning of the motor when a joystick input is received by the PIC. This board is
powered by a 10V adapter. In the sections Schematic and Components of this report, all
components of the block diagram will be explained in detail.

3
Schematics & Designs
For this project we made use of two PIC microcontroller boards. One was used to drive the motor for
the spinning plate which is controlled by a joystick. The other PIC is placed underneath the spinning
board, this microcontroller is used to keep track of the score and is also responsible for driving the
LEDs and LDRs.

Eagle schematics

Figure 5: Part 1 of the schematic for the turning plate

A 21-female header was used to connect the microcontroller, the PIC18F2550, to our PCB. The power
supply of the PIC is an external battery which is controlled by a LM7805 voltage regulator (figure 6).

Figure 6: LM7805 Voltage Regulator

To connect all the LEDs we used an MCP23S08 IO-expander. The LEDs are then multiplexed as seen in
figure 7. Also the HEF4051 is used, this is a multiplexer. The LDRs are connected through a voltage
divider circuit to the multiplexer, which channels the signal through to one single analog input of the
PIC (RA0). We can chose which LDR we want to read by controlling three digital output signals of the
PIC (RA1-RA3). The voltage divider circuit in combination with our LDRS can be found in figure 5 at
the bottom right side.

On the bottom left side of figure 5 you can see the circuit of how the pushbuttons are connected, they
are connected via a pull-up resistor. If the buttons are pushed, the PIC detects a logic 0.

At the top side of the figure 5 we see an OP-AMP used for amplification of the input signal from RA4.
For the OP-AMP the MCP601P was proposed, this is a single supply CMOS OP-AMP. This circuit was
designed to drive the speaker.

4
Figure 7: Part 2 of the schematics for the turning plate ; LEDs with 'selection circuit'

In figure 7, our schematic can be seen on how we connected our LEDs through an IO-expander. At the
bottom of the figure you can see how the LEDs are connected with the output of the MCP23S08 of
figure 5. Because we use 16 LEDs and the I0-expander only has eight outputs, the circuit from figure 7
was designed. The circuit made it possible to drive 16 LEDs using
two signals. One signal was used to select a group of LEDs while
the other signal selected the correct LED from the group.

Figure 8 shows a part of the circuit to select the correct LED. If we


want to drive LED1, first a 0 needs to be send to GP7 for
activating transistor Q1. Then a 1 on GP3, in figure 9, will activate
transistor Q2. When Q2 is activated, LED1 from figure 8 will be
connected to the ground in figure 9 and can start drawing current
to illuminate the LED.
Figure 8: Part of circuit for LED selection

Figure 9: Transistor part of circuit for LED selection

On figure 10 on the left, the joystick input and motor


steering schematics can be seen. On the 21-pin
header we placed the PIC18F2550 microcontroller.
This PIC controls the motor driver, which is in our
project the L293D. This driver has two power supply
connections. Vcc1 is the 5V for the internal logic of
the driver. Vcc2 is the power supply for the drivers, it
ranges from 4.5V to 36V. Via a jumper on the PCB it is
possible to choose between an input voltage for the
drivers of 5V or 10V.
Figure 10: Schematic for PCB on fixed enclosure
The joystick consist of two potentiometers and one
pushbutton. Because the spinning plate only moves around clockwise or counter clockwise, we only
need to read out the horizontal axis joystick potentiometer to know the position of the joystick (left-
right) and drive the motor in the correct direction.

We used the L293D driver to drive the motor. This is a 12V DC-motor with a gear box for more torque.

5
Depending on which position the joystick moves, the motor will stand still, turn clockwise or turn
counter clockwise. This is done by setting two pins of port C. These two pins, RC1 and RC2, are also
connected to the driver. When both of these outputs are zero, the motor doesnt turn around. Only
when you put a 1 to one of these port pins, the motor will turn around.

We have used a LM7805 voltage regulator on the controlling board of the motor PCB to obtain a
constant 5V voltage as power supply for the PIC and the internal logic of the L293D. The input voltage
of this LM7805 regulator is a 10V power adapter.

Board designs
To let all the hardware (LEDs, LDRs, motor, ...) work, two PCBs were designed to make the connections
from the schematics above.

PCB rotating plate

Figure 11: PCB design for rotating plate

One PCB is placed on the rotating plate which contains all the hardware to do the visualisation and
capturing the inputs for the game. Because more than half of the components, like the LEDs and LDRs,
are not placed directly to the PCB, we needed to wire these with extension wires to make the correct
connections.

PCB fixed enclosure

Figure 12: PCB design for the fixed enclosure Figure 13: Final PCB designed on protoboard

The fixed enclosure also has a PCB to manage the joystick inputs and convert these to motor
movement to drive the spinning plate in a chosen direction. Initially a PCB was designed in Eagle with
a custom made joystick footprint. But in the end the design was made on a protoboard which can be
seen in figure 13.

6
As an extra we made two voltage regulators (LM7805) on two independent boards. These voltage
regulators convert a higher input voltage (> 7V) to a constant 5V output. The constant 5V outputs of
the regulators are used as power supply for the two PIC18F2550 and also to power the internal logic
of the L293D motor driver. The reason why we made it on two independent boards was for future use
(easy to remove it of the project).

Components
The pre-specified components largely determined the choice of components. The only real choice of
components are the resistors. To get the right resistor values there were some calculations made
which can be found in the calculation part of the paper.

Figure 14: Overview of used components

The decision for the power transistor wasnt difficult. There were two choices available, the BC139
which is a PNP transistor or the BC140 which is a NPN transistor. For this project we needed both of
them to implement in the OP-AMP circuit to drive the speaker, this can be seen on figure 5 where
both transistors are used in a push-pull circuit.

The spinning plate of our electronic game is powered by a 3S


(11.1V) LiPo battery. The LiPo battery was chosen because of
its small form factor, low weight and for its large 800mAh
capacity. From this battery we only draw a maximum current of
48mA, for all the parts on the spinning plate, while playing the
game. This isnt much but is a plausible value considering the
Figure 15: Turnigy 800 mAh LiPo battery

7
low power consumption of the PIC and the multiplexing of the LEDs. Because of the large capacity
from the LiPo battery and the small current consumption from the circuit, its possible to play games
for multiple hours with just one charge.

Calculations
The only calculations that were made are those to
determine the value of the resistors in the multiplexing
schematic. For the calculations of the LDR resistor value,
there was performed some trial and error to see which
resistor value gave the best sweep for the LDR detection.

If we look at to figure 16 in the top left corner, there is a


resistor divider with a 1k resistor (pull-up) and 3k9
resistor. As a result the voltage on point B is
3 39
= = 5 = 3.9
(1+3) (1 + 39)

This means that we can calculate resistor R2.


( + ) 5 (3.9 + 0.7)
2 = = = 15
0.02

In the datasheet we find that the voltage over the greens


LEDs is 3.2V, so the voltage in point A should be at least
3.2V.
Figure 16: Multisim schematic for simulation purposes

If LEDs are multiplexed, like in our electronic game, the LEDs can easily handle a current of 100mA
according to the data sheets of our used LEDs. However, we decided to take precautions by using a
maximum current of 20mA through our LEDs instead. This corresponds with a voltage of 0,4V over the
resistor of 15 Ohm (labelled R2 in the scheme of figure 16 ).

Measurements

Voltage (V) Current (mA)

LDR 2 (light) | 5 (dark) 0,467 (light) | 0,02 (dark)

LED red 0,8 0,22

LED green 1,2 0,195

PCB spinning plate 5 48

PCB motor 5 338 (max load)

Table 1: Measured component values for voltage and current

8
The calculated current through the LEDs is 20mA but this current gets multiplexed. That is why our
measured value is much lower. The same happened with the voltage over de LEDs. The voltage and
current over and through the LDRs is dependent on the amount of light. If there is a lot of light the
current consumption through the LDRs rises. The total current consumption of the PCB on the spinning
plate is 48 mAh. This is because we must power several components (Multiplexer, IO-expander,...) and
the PIC controller. The total current consumed by the PCB of the motor is 338 mAh when the motor is
at its maximum load.

Figure 17: Measurement green LED Figure 18: Measurement red LED

Enclosure
MDF-enclosure

Figure 19: Inkscape design for the top plate of the enclosure

The enclosure for our electronic Ball Pong game was designed in Inkscape and made out of 4mm thick
MDF plate. We made use of a laser cutter in Fablab to cut all the necessary pieces out of multiple
60cmx30cm plates. On the outside of the box we also engraved our group number and some QR codes
which lead to the website of our electronic game. To inform the laser cutter if he needs to cut or
engrave, the color of the lines needed to be different in the Inkscape software. For the black colored
lines or objects the laser will engrave and for the red(RGB color for red on 255) colored lines , the laser
will cut through the MDF plate.

9
3D printed joystick extension

To make it easier to control the direction of the turning board, we designed a


joystick extender in solid works to place on top of a rubber Playstation 3 thumb
controller. This thumb controller is connected to the ALPS joystick. The
movement can now be chosen in a more enjoyable way than if we wouldn't
extended the small part that sticks out of the joystick.

Figure 20: 3D model of joystick

Support turning plate

To support the turning middle plate, we designed a construction made out of Knex to counter the
unbalance created by an uneven weight distribution of the components. We glued all the pieces
together to get a strong construction. We opted for this method because it was quick and easy to
implement in our game design.

Software
FSM game
Here we can see the two finite state machines (FSM) of this project. The first FSM (of figure 21) is from
our game logic: here we handle the switch between players and the history (or status) of the two
players. In the FSM of the game IO, we read out the LDRs and put the status of these LDRs in one byte
called ldr. This byte we used in the FSM game.

Figure 21: FSM game logic

The 16 LEDs are separated into two groups of eight LEDs (green and red), each color has one byte. The
FSM on figure XX (FSM game) sends these two bytes (one byte for the red LEDs and one byte for the
green LEDs) to the FSM game IO. The FSM game IO reads out the LDRs and drives the LEDs, based on
the value bytes.

10
FSM joystick and driver
In the FSM_IDLE state we only interpret the joystick data and read out the PWM counter variable.
Depending on the value of the joystick we made decisions in which direction, or stationary position,
the motor will spin. The PWM counter variable arranges the PWM concept. There is also a variable
PWM_DUTY. This variable is free to choose for the programmer and determines the PWM duty cycle.
PWM_DUTY is a number that can be chosen between zero and nine. Number 4 represents for example
a duty cycle of 40%. Every millisecond we increment the PWM counter (from zero to nine), as long as
the PWM counter is less than the PWM duty cycle, the PWM signal is 1.

Figure 22: FSM Joystick and motor driver

Final realization

Figure 23: Front & top view of the electronic Ball Pong game

Critical View
After designing the game and test playing with it for a few hours, we noticed some flaws in the design.
If we would have had more time to solve these flaws, we could have improved the game and gave it
a more entertaining feel.

11
First of all, the cones are a bit small which makes it hard to score a ball into one of the eight holes.
This problem occurred because of the maximum width limitation of the MDF plates offered by FabLab
(30 cm) and the requirement of making a handheld game. Because of this maximum width, the cones
needed to be made smaller to fit all of them on the rotating plate, which increases the difficulty.
Second of all, the enclosure should be more robust so it can handle more stress. Outsourcing the
enclosure (see Enterprise report) to a company which can make a strong but lightweight enclosure
will solve both problems mentioned above.

Inside the enclosure we used a construction of Knex to support the plate while its spinning. We used
Knex pieces because it was easy to experiment with, but in the future we could use a 3D printed stand
for better support.

Our electronic game called Ball Pong is a derivation of the beer pong game that is popular by students.
Because of this, students will still try to combine the game with alcohol consumption. Therefore we
need to make sure that the enclosure is waterproof so it doesn't suffer damage when there is spillage
of drinks on the game.

After doing the calculations for the total cost, we were surprised how much the DC motor actually
costs. We used this motor because it was given to us and because it had more than enough torque to
turn the table. The motor is controlled by PWM, which only provides 40% of its maximum power to
turn the circular plate. The price of the motor used in the current project is around 30 euro on Farnell.
Before the design is going in mass production, we need to calculate the amount of torque the motor
provides and replace it with a cheaper and less powerful motor, that is still strong enough for our
game application.

During the project we faced some problems which could have been avoided by doing more and better
testing. After soldering all the components on the PCB of the turning board, the PIC controller, which
manages all functions for the PCB, couldnt make a proper connection with the computer due to a
short circuit. After extensive searching, we found some possible interconnections between the ground
plane and multiple Vcc lines. After removing these, the PIC controller which is connected to the PCB
was able to be connected and be programmed by our computer. If we would have checked for
interconnections after every component we soldered, it would have been much easier to solder the
board without problems and we wouldnt have lost much time searching for the problem.

12
Conclusion
At the end of this EE4 project, we are proud of the end product we have realised. For most of the
team members it was the first time that we made a project with more than two people. Because of
this, it was sometimes hard to do the communication between the whole team. But there were also
advantages of working in such a large group because it was easy to divide the workload into multiple
parts.

As we look back to the predefined requirements we can say that every requirement is completed. We
succeeded in building a spinning plate with all the electronics of the game powered by a battery, there
are also stabilization wheels for the smooth spinning of our plate. The lifetime of the game on one
battery is also perfect and more than we expected. The total current draw of all the electronics on the
spinning plate is only 48 mAh which means we could play our game for more than 15 hours before
damaging the 800 mAh LiPo battery.

We learned a lot from each other and from our mistakes. Making our own enclosure and laser
cutting it in Fablab was a very nice extra which we could add to the project, it was also interesting to
see what's actually possible to manufacture with this technology. After this project we can say that
we all enjoyed doing the EE4 project with the group and that the team had a very humorous team
spirit!

13
Ball Pong: Enterprising report
Intro
The game was designed because there wasnt a cheap and interactive version of the beer pong game.
Because the aim of this project is not to promote drinking, the drinking part was taken out of the game
and we replaced the beer cups with simple cone shaped holes equipped with two different color LEDs
and an LDR. The game is based on beer pong, so thats why this game is a combination between
accuracy, timing and throwing skills. To make the game more interactive and competitive the
defender is able to spin the plate with the cones to increase the difficulty for the attacker. This
movement in the game is generated by giving joystick inputs to a DC-motor underneath the circular
plate. A speaker was also implemented for generating sound during the game.

Target group and placement


The target group of our electronic game are people who like to play precision ball games, between
the age of 10-30. There are different needs for this group. Because the group is age-spread the game
couldnt be too difficult to understand. Lots of buttons would only cause confusion between players
and this can lead to a player pressing an incorrect button. Because of this we only installed three
buttons and a joystick on the enclosure with clear labels to avoid commotion. Half of this target group
is still young and full of energy. Thats why the game can be played fast paced, while the other half is
already a bit older and slower but they can still play the game on their own pace. Because the game is
versatile both halves will enjoy it.

Because of the target group, the price of the game cant be too expensive because the younger
generation doesn't have as much money as the older generation. As an effect of this lower cost
property, we needed to make a cheaper selection of internal components to create a cost efficient
end product. The only crucial parts of the design that needs to be robust is the enclosure and the
joystick because these components will suffer the most from human interaction. Because the
enclosure needs to be more robust it will also be more expensive to produce them. For manufacturing
the enclosure we will outsource this task to another company which can build the casing in a more
lightweight and stronger material.

Like any other game thats made for entertainment purposes, this game will be mass produced. With
all factors in mind the price of our game is aimed around the 100 euro mark for one complete unit
with two balls .

14
Comparison

After doing some searching on the web, we found some


comparable designs which also try to make the beer pong
game more interactive to play.

A high end interactive LED table was made for playing beer
pong. The score between the two player sides can be seen
during the game and more than 1100 LEDs are implemented
for a light show.

PRICE: between 500 - 2000 euro


Figure 24: High end interactive beer pong table

Beer pong combined with a vacuum cleaner called the iRobot


Roomba. The robot is placed on a small table, because it
sensors will sense the table sides it wont fall of. Because of
this the cups will move around on top of the table, every time
when the robot senses the table side, it will change its
direction and turn around.

PRICE: 300 euro


Figure 25: Beer Pong combination with an iRobot
Roomba vacuum cleaner

Considering the cost of the components and design of our game, the total price of the game will be
much lower than the mentioned games above. We estimated that the price of our game will be around
100 euro.

Website

Figure 26: QR - code which leads to our website Figure 27: The design section of our website

A bit more information about the electronic game we created, can be found on an informative
website. The website can be easily accessed by the players of our game when they scan the QR code
of figure 26. This QR-code is also visible on top of the enclosure of the game. An overview of the used
hard-, software and enclosure can be found in the design section of the website. Also the game rules
are described in a section of the webpage.

15

Вам также может понравиться