You Are Here: Home » AVR ATmega Projects » Game - Entertainment Projects » Laser Pong Using Atmega32

Laser Pong Using Atmega32




Wall of Pong is a fast-moving, interactive, laser-based pong game playable on any flat surface.

The system uses a digitally controlled laser projection platform to draw a pong ball onto any flat surface. This allows for a large playing area that can be set up almost anywhere. Hand held paddles with embedded sensors are given to each player. The real life paddles increases the interactivity of the game and makes it an enjoyable and dynamic derivative of the original PONG arcade game.

Laser Pong Using Atmega32

This project was a five week design lab for ECE 476 at Cornell University. Video of the final demonstration is available in the Results section.

Adrian Wong (aw259)
Bhavin Rokad (bkr24).

High Level Design

Inspiration | Concept | Mathematics | Standards

Project Inspiration

The Wall of Pong is actually the successor to the project that we were originally designing for ECE 476. Our original objective was to design a laser tracking system built around a circular saccade (see “Laser-Based Finger Tracking System Suitable for MOEMS Integration” by S. Perrin, A. Cassinelli, and M. Ishikawa). We completed most of the project, but we were unable to design the necessary focusing optics. As a result, we decided to adapt our base platform to the Wall of Pong concept.

The Wall of Pong brings the arcade PONG game to the real world by projecting an image of the pong ball on any flat surface and allowing players to play the game with real paddles. The game also targets all three of our personal objectives for our ECE 476 final project: an interactive electromechanical system with fast operation. We wanted a project that involved interaction between the user and the system with very fast response times to user’s actions to give a satisfying experience. We also wanted to stress a project with electromechanical components, as we wanted something tangible with our project instead of a project based entirely in software.

Overall Concept

The laser platform is built around three main components: the laser project platform, the hand held paddles, and the microcontroller. The first is the laser beam projection platform. The laser beam is first projected onto a rotating mirror. The reflected beam will be circular due to a slight off-axis mounting angle. The circular beam can then be steered using two motors. One motor controls the x-axis motion and the second motor controls the y-axis motion. The mechanical mechanism that allows for orthogonal rotation of the mirror in independent axes is called a gimbal.

The second component is the hand held paddles. Each player will hold a paddle that has three embedded light sensors. The light sensors can detect when the laser beam hits the paddle. The light sensors are spaced close enough together so that they can collectively detect any ball collision along the full length of the paddle. The paddles are wired into the microcontroller through a long flexible cable.

The third component is the microcontroller itself. The microcontroller will control the operation of the gimbal to move the ball around the playing field and have it bounce off virtual walls. The microcontroller also handles the detection of the projected laser beam by two hand held paddles.

Background Mathematics

The pong ball is drawn using a gimbaled laser platform and two paddles are wired to detect the pong ball projection. Our two primary concerns were the angular resolution of our system as well as the operating speed of the laser pong ball.

Angular Resolution

Our target specification was to have an angular resolution of less than 0.3 degrees for targeting of the laser beam. This corresponds to 5.236 mm of spatial resolution at 1 meter range. We overdesigned the system with a 100% margin by designing for 0.15 degrees of spatial resolution in both axes. This means that our final design can place the laser beam with 2.6 mm of accuracy in both x and y axes at 1 meter range.

With each degree of mirror rotation, the projected beam actually moves twice as much. This can easily be seen by considering the law of reflection (angle of incidence is equal to angle of reflection). If the incident beam is held steady and the mirror is rotated by an angle θ, the incident angle as measured off the normal of the mirror has increased by θ and the reflection angle has increased by θ as well. The angle between the incident beam and the reflected beam has now increased by 2θ. This means that the target resolution must be 0.075 degrees per step for the motor mounted to the mirror.

The stepper motors only have a 7.5 degree step resolution. In order to increase this to 0.075 degrees per step to reach the target specification, the stepper motor must have a 100 fold increase in resolution. This is achieved through a combination of software and hardware. The software can double the resolution by half stepping the stepper motors. The remainder must be achieved through hardware.

One approach is to design a gear train for the stepper motor, which can increase the angular resolution as well as the torque output of the motor. The gear train must have a 50:1 gear reduction. The brass gear on the stepper motor has 10 teeth at 48 diametral pitch. A naive approach would involve a 500 tooth gear meshed to the 10 tooth pinion gear. That approach, however, would create 10.5” diameter gear. This is much too large for the mechanical gimbal design. Instead, our proposed compound gear train runs uses two 100 teeth gears and an intermediary 20 tooth gear (10:100 and 20:100). This achieves the 50:1 gear reduction target.

For the x-axis rotation, we can circumvent the loss of mirror resolution due to reflection by mounting the laser onto the same platform as the mirror. Since the laser moves along with the mirror, we simply rotate the entire assembly. This reduces our requirement to 0.15 degrees or a 50:1 gear reduction. We can again apply the half stepping approach to relax the hardware requirement to a 25:1 gear reduction. The y-axis gimbal assembly can fit on a 6.25” diameter gear, which corresponds to a 300 tooth gear at 48 pitch. If this gear is meshed directly to the 10 tooth pinion gear, this exceeds our target specification by creating a 30:1 gear reduction.

Operating Speed

With such a large gear reduction, the actual movement of the laser beam is also reduced by a factor of 50. We were concerned that the stepper motors would not be able to step quickly enough to move the ball in a satisfying manner for the game.

Our goal was for the ball to move at least 10 cm per second at 1 meter range. This corresponds to 5.71 degrees per second of angular velocity. Going through the 50:1 gear reduction, the stepper motor must reach 285 degrees per second. This corresponds to a frequency of 4.974 Hz in full step operation or 9.948 Hz at half step operation. This is readily achievable using a 16 MHz microcontroller.

Standards and Trademarks

Our system utilized a readily available, unaltered, laser pointer compliant with class IIIa laser power and safety specifications. In the United States, OHSA standards govern laser safety and personal protective equipment (PPE).

Additionally, the IEC 825 standard defines the maximum exposure limits of lasers and LEDs. The ANSI Z136-1 standard addresses the engineering and procedural controls necessary when using class IIIa lasers. Compliance with these safety standards is crucial for the safe and successful development of the laser game and therefore were followed closely.

The mechanical model design in Solidworks used ANSI standards.

PONG is trademarked by Hasbro Interactive. However, the context of our project is unlikely to cause any confusion between Hasbro’s intellectual property and our own. Specifically, our project is presented within the context of a senior year microcontroller course, and the title Wall of Pongwill not be used in any commercial derivations. Also, it is unlikely that one would confuse the laser projected pong system with the arcade game to the right.

Implementation

Software Details

Our final program is a reduced version of what we had written for our laser tracking system project. We removed all the features not necessary in the Wall of Pong (such as the digital phase locked loop), and we kept the core framework (such as the stepper motor functions). The main operation sequence will be described; specific details on stepper motor actuation, ADC control, and serial communication are described in separate sections below.

Main Operation Sequence

The program starts by initializing all ports, timers, USARTs, and application variables in the initialize function. After initialization, the program runs through the calibration sequence which sets the boundary of the playing field. The calibration function is a five state FSM that transitions whenever a paddle registers a hit. The first four states store the left, right, up, and down borders of the playing region by recording the coordinate of the ball when the paddle hit occurred. There is also a centering function that returns the ball to the center of the field. The center point is recalculated once the boundaries of the field are defined.

Once calibration has been completed, the game begins by calling start_game, which sends the ball moving in a random direction from the center. While running the main control loop, the program checks for paddle hits and boundary collisions. If the program detects a collision with a paddle or an upper or lower boundary, the ball reverses direction on that axis. However, if the program detects a collision with the left or right boundaries, the player on that side is designated as the loser.

Stepper Motors

Laser Pong Using Atmega32 Schemetic

The two stepper motors are actuated by the Timer 2 Compare Match ISR. The motors are controlled by energizing the motor windings in a specific sequence. The sequence is stored in an array titled full_step. There is also an alternative stepping sequence known as half stepping that energizes two sets of windings simultaneously. This effectively reduces the step size in half and doubles the resolution of the stepper motor. This sequence is stored in an array titled half_step. On each interrupt, the step indices for the x-axis and y-axis are incremented, decremented, or unchanged depending on the current ball direction. The x and y coordinates the ball are also adjusted appropriately. The output on port C to the ULN2003AN Darlington array is generated by looking up the correct step for each motor and combining the x-axis and y-axis outputs into the upper and lower nibbles of port C.

PartQuantityCostTotalSource
$48.66
10k PDIP Resistor Pack
1
ECE 476 Digital Lab
RS-232 Serial Port
1
$1.00
$1.00
ECE 476 Digital Lab
MAX233CPP
1
Sampled
Red LED
1
ECE 476 Digital Lab
Jumpers
3
ECE 476 Digital Lab
16 MHz Crystal Oscillator
1
ECE 476 Digital Lab
LM340T5 Voltage Regulator
1
$0.42
$0.42
ECE 476 Digital Lab
Slide Switch
1
ECE 476 Digital Lab
TIP31A NPN BJT Transistor
1
ECE 476 Digital Lab
2N3904 NPN BJT Transistor
1
ECE 476 Digital Lab
2N3906 PNP BJT Transistor
1
ECE 476 Digital Lab
1N4001 Diode
1
ECE 476 Digital Lab
10k Trimpot
2
ECE 476 Digital Lab
ULN2003AN Darlington Array
2
$1.00
$2.00
ECE 476 Digital Lab
Atmel ATMega32
1
$8.00
$8.00
ECE 476 Digital Lab
8 pin DIP Socket
2
$0.50
$1.00
ECE 476 Digital Lab
40 pin DIP Socket
1
$0.50
$0.50
ECE 476 Digital Lab
Laser Diode
1
Previously Owned
PF35T-48L4 Stepper Motor
2
$1.00
$2.00
ECE 476 Digital Lab
Brushless DC fan
1
$1.00
$1.00
ECE 476 Digital Lab
Acrylic Sheet
2
$4.00
$8.00
Equivalent
Cutting Time
3
$2.50
$7.50
Equivalent
PDV9006ND CaS Photocells
6
$1.04
$6.24
Digikey
12V Power supply
1
$5.00
$5.00
ECE 476 Digital Lab
Custom PC Board
1
$5.00
$5.00
ECE 476 Digital Lab
Small solder board
1
$1.00
$1.00
ECE 476 Digital Lab
Mirrors
1
$1.00
$1.00
Lowes

 

For more detail: Laser Pong Using Atmega32

Leave a Comment

You must be logged in to post a comment.

Read previous post:
Movement to Music: A Wearable Wireless Motion Sensor system Using Atmega32

Introduction In this digital age, new interfaces for musical expression provide much broader musical possibilities than have ever existed before....

Close
Scroll to top