Monday, May 9, 2011

Transmitter (Gun) Design

The transmitter design is essentially a plastic toy gun that has been physically modified to feature the Xbox 360 controller interface.  A gyroscope is used to sense the angular velocity at which the gun is moving.  When the gun is moved or rotated, the gyroscope will sense rotation in two separate axes, and cause the voltage on one of two pins to deviate from the reference voltage accordingly.  This deviation from the reference voltage is used to generate a digital value that corresponds approximately to the deflection of an analog stick that would cause a similar effect in-game.

The remainder of the Xbox 360 controller interface (consisting of two triggers, 10 buttons, and a second analog joystick) is implemented in the same manner as the controller; however, these features are spread around the gun for ease of use.  Unlike the Xbox 360 triggers, which are analog (see section II.B), the triggers for this design are binary.  As a result, while the 360 controller features 10 buttons, we will have 12 (counting the two triggers).  For the intended games (first-person shooters), this is acceptable, as there are only two in-game states for the trigger: shoot and don’t shoot.

Hardware Design

A hardware schematic describing the design of the circuitry of the transmitter (gun) is shown in the following picture.
Schematic showing the wiring of the internals of the gun transmitter.  Note that all 12 buttons are connected to a common power, and due to the nature of software buses of GPIO pins on the mbed, can be connected to arbitrary pins.  Power and ground connections to devices on the right side are omitted for clarity.
The mbed shown above makes use of five analog inputs.  Two (p18 and p17) are used for the two axes of the movement joystick.  The other three are used to interface with the gyroscope.  The gyroscope used (the LPR530AL dual-axis gyro) has 4x amplified outputs for each of the X and Y-axes, so we connected those to ADC pins 19 and 20.  As previously discussed, because we wish to calculate the difference between these readings and the specified reference voltage, we also use ADC pin 15 to capture the reference voltage.

The buttons on the gun are implemented simply using GPIO.  Because the mbed will automatically pull down the line for a high-asserting button, there is no need to add a pull-down network to these buttons: they only need to make a connection to 3.3V from the mbed.  Inside the gun, these buttons are almost all in the middle compartment on a single soldered circuit board.  These share a common connection to 3.3V (to one side of each button) and on the other side of each is a wire leading back to the mbed.

Finally, the XBee wireless module is connected to the serial output (TX) pin on pin 28.  Additionally, to prevent the user from having to maneuver into uncomfortable positions, we added a button (labeled “Gyro disable” above) to essentially zero out the gyro in software: the result is that when the button is pressed, moving the gun will not affect the in-game character.

Software Design

The C++ source for this project can be found in its entirety at this link.  For a detailed description of how the software works, please consult the paper (also available at the link above), or the comments in the code (most of it is fairly straightforward to follow, except possibly the "packetization" code).

Finished Product

The entirety of the circuitry shown above was packed in to the three internal hollow compartments of a plastic toy gun provided from last year’s ESE 350 projects.  The completed gun (without display, showing PVC mounting rails) can be seen in the following picture:

Completed, closed gun (transmitter) without display.
The regular Xbox 360 controller buttons (A, B, X, Y, Start, Back) can be seen on an exposed circuit board on the front of the center compartment of the gun (above the trigger).  The trigger can be seen immediately below that.  The gyroscope is located immediately above the trigger, held in place (to maintain the proper organization) by tape.  The left analog joystick (a genuine Xbox 360 joystick that was removed from the wired controller that we ripped apart) can be seen on the bottom left.  The mbed microcontroller itself is in the compartment right above the joystick, which holds a small breadboard with wires leading from it to the rest of the components.  A picture of the contents of the front compartment (including the mbed) can be seen in the following picture.

Insides of the front compartment, containing mbed and wiring to buttons, gyroscope, and XBee.
Finally, the XBee wireless antenna is located in the very back of the gun (the stock).  The finished product, with screen attached, can be seen here:

Completed gun with screen attached and mounted.  Game shown is Call of Duty: Modern Warfare 2.
The button layout is consistent with the Xbox 360 controller.  In fact, the button layout was measured to exactly match that of the controller (we actually have a cut up faceplate that we can put on, however, we ran out of time).

No comments:

Post a Comment