| Home | High Level Design | Member Task Distribution | Hardware Design | Software Design | Results of the Design | Conclusions | Media | References |
Our team’s goal was to create a game where players control a Nerf Gun with a Nintendo 64 controller and shoot at targets. The player receives points based on whether or not he hits one of the targets with a Nerf dart. The player controls the vertical and horizontal aim of the gun, as well as the trigger mechanism. We also wanted to have a graphics display that illustrates the current point value of the player, accuracy of the shot, and a diagram of what targets have been hit.
To get data from the ADC and N64, we used polling to get data. The game continues based on global flags that are accessed in the assembly and C code for structure control.
The N64 Controller is used to control the servos for the gun, fire the gun, and choose which mode you are in.
A bunch of vibration sensors that act as targets to signal if a target is hit and how well it was hit.
A Nerf Gun that is controlled by the N64 Controller that is used to fire at targets
Used to display graphics and information to the user, such as what mode they're in, who's turn it is, and what the scores are.

Most of the physical design, created N64 interface interaction, created vibration sensor polling, ISR/N64 Handler, debugging
Vibration sensor calibration, debugging, designed N64 interface interaction, pendulum, trigger, other servo control, N64 mapping, Multiple interrupt and timer design
Graphics, game software, physical design, physical implementation, debugging, ISR/N64 Handler
Go back to TopWe designed an interface to map 6 external interrupts to 2 IRQ lines. We were able to read whether or not an interrupt is pending through a register and to clear/disable interrupts through another masking register.
We used both processor timers and created our own timers to use for: polling the N64, reading the vibration sensors, and controlling the four servos. Our own timers count up to a specified value and then produce a done signal when they have completed their count. Those timers can be reset, started, and have their limit changed all from software reads and writes.
Using the bi-directional bus, we had to control the DIR pin based on if we were doing a read or a write. Given the pulse width size, we multiplied it by two to ensure we gave the system enough time for each operation. We have separate address decoders, one for read and one for write operations to ensure we did everything correctly. The decode for writing generates its own signal to control DIR and the tri-state buffer for the bus, and the read decoder generates its own read signal to allow the graphics display to drive the bus.
We use five vibration sensors, one for each target, to map whether or not a target has been hit. It a target is hit, the corresponding vibration sensor produces a voltage that is analogous to how hard it vibrates, or how accurate the hit was. We use the sensors to detect the difference between direct hits and indirect hits. The produced voltages vary from 0V to 5V.
We use four servos, one servo for rotating the gun horizontally, one servo for tilting the gun vertically, one high-powered servo for pressing the trigger, and one servo for moving one target like a pendulum. The servos are all controlled by pulse-width modulation based upon our own timers. The trigger and pendulum servos changed their pulse width based upon a specific time interval, while the other servos had their pulse-width changed based upon the direction of the N64 analog stick.
We use the Nintendo 64 controller to press B to move through the menus and fire the gun, and we use the analog joystick to move the servos that aim the gun. To get the N64 to send data, we send it a series of bits in Manchester encoding, wait 2 microseconds, and then receive 32 bits of data in Manchester encoding. We needed to be able to encode and decode Manchester encoding, as well as read the 32 bits to figure out how the analog joystick and different buttons change the values.
The software was a heavy mix of assembly and C because of the significant amount of hardware interaction and high level software design that would require a lot of work in assembly. Code controlling the graphics display and the game play were written in C, while the device drivers and interrupts were all wrriten in Assembly. Assembly allowed us to interact with the FPGA and hardware with more control than C so we wrote drivers and interrupts with assembly. Since the graphics display required data processing to display large images, we used C to easily iterate and store the data. The game's logic was easier to write in C than assembly because of the numerous components of software we had to interact with. Additionally, it was easier to write loops and test if something is ready using C in conjuction with assembly.
The game was separated into three stages:

N64 Controller is controlled by a general purpose timer that caused an interrupt every 100ms. 100ms was chosen because the servos required 100ms. We avoid filtering data by avoiding commands that occur while the servos are responding to the person's input. Since players will attempt to change directions or have the servo stop moving when the servo goes too far, there was no reason to poll the N64 controller faster.
In the game play, a flag was checked when the game was waiting for the player to hit a button to continue the game. The N64 interrupt handler would set that flag high when it detects the user hit a button. The only button used to control game flow was B, and the directional buttons controlled the gun or what mode to select depending on the state of the game. N64 controller's sensitivity was used to help control the gun incase the user wanted to move the gun in small increments versus large increments.
Since we only have two interrupt lines, the vibration sensors have a shared IRQ line. We needed to poll each of the vibration sensors after the trigger is fired. The interrupt was generated by a software timer that ran slightly faster than the ADC clock to ensure that the data was for the sensor we want when we poll it. We polled the ADC every 250ms. The value read from the ADC was compared against pre-recorded values to determine if a sensor is considered "hit". If after three seconds no hit was detected, we assume the player missed the target. A flag is written to when the ADC has detected a miss, and if it detects a hit, it stores which vibration sensor was hit.
We used a similar design to the lab 7 for controlling servos. We store the duty cycle in a global variable, and based on how much the user wants to turn (data from N64), we set the duty cycle. We used hardware timers that we created to control the servos.
Go back to TopWe encountered a few problems throughout the project, some of which compromised some of the functionality of our project. One of the major problems that we encountered was that the NERF gun we were using produced a significant amount of Electro Motive Force (EMF) when the gun was on. This EMF would cause all of the servos that we used to turn on and off at random, causing misfires and the gun to turn in the wrong direction. We managed to control this problem by isolating the power source of the NERF gun and the power source of the servos by using a secondary power supply. In addition, we were forced to wrap the front of the gun, where the motor was located, with metal foil in order to block as much EMF was we could. This managed to contain the EMF yet occasionally caused the gun to get jammed due to the foil blocking the way of the NERF darts.
The second major problem that we faced was the overall mechanical engineering knowledge that our project required. The source of this error came in our assumption that the servos would be strong enough to move the gun given enough mechanical advantage via the ‘wheel’ system we designed for the gun. The servo’s proved effective in being able to turn the gun in a radial direction and changing the elevation. The trigger proved more difficult due to our inability to transfer rotational motion into linear motion and due to the mechanical limitations of the gun. The gun was originally designed to be auto-reload with the use of a spring; however the servo was unable to move the trigger/spring combination. This required heavy modification of the gun in an attempt to fire without the spring. The end result was that we had to replace the spring into the system and upgrade to a stronger servo.
In addition to the mechanical problems of our servos, the entire platform that held the gun together proved to be a mechanical nightmare. We had metal wire and even dental floss holding key pivot points together. The reasoning for this was that we needed a pivot point that was strong enough to hold together but flexible enough to give our gun room for error. Overall, these modifications held together for the most part, yet had to be replaced somewhat frequently due to the consistent use wearing them down.
The third and final problem was getting the ADC to work correctly. It took us a long time to understand how the DIR pin would work for both the graphics display and the ADC such that both components would work in unison. The other, more demanding problem was the inefficiency of the ADC to poll multiple targets at once. When we fired a dart, the program would start polling every single vibration sensor until one detected a hit. The ADC would not always register a hit no matter what threshold we set and the ADC would not produce the correct values when the target was struck. The ADC was too slow at resetting results for a selected target so we had to compensate by editing our software.
Go back to TopDespite our problems, the game managed to work fairly successfully. The Nintendo 64 controller was able to control the movement of the gun in all directions and at two different speeds. The trigger mechanism was able to fire the gun, though was not as consistent as we would have liked it to. The targets worked for the most part and would register hits. All in all we are very happy with how the project turned out. The only things we would change if we had a chance to redo the project would be to use a gear motor for the trigger and to have better communication which led to interfacing problems.
Go back to TopVideo demonstrating our pendulum target.
Video demonstrating the game, including firing of the gun.
Click to view larger version of the images
Different angles of the gun and setup:
Board:
Targets:
Graphics Display:
Team:
Used to convert a bitmap into data that can be processed for the graphics display.