Hardware Design
A schematic describing the design of the circuit of the receiver is shown in the picture below.
In total, the receiver needs to implement four analog outputs (one for each of the original joystick axes). The mbed has one built-in digital output on pin 18, so that will be used to implement one. Since this DAC has a 3.3V range, software will ensure that the most significant bit is 0, keeping the range of analog values in the lower half, or below about 1.65V, which is the proper range for the analog joystick. The mbed also features two I2C buses, and on each of these we put a MCP4725 I2C DAC, which provided two additional analog outputs. Unfortunately, because the least significant address pin of the MCP4725 was hard-coded (wired) to 0 by the breakout board, we could not put multiple DAC board slaves on a single I2C bus; therefore, to implement the final analog output, we constructed a 4-bit resistor ladder DAC, as shown above. Again, in order to prevent the voltage from going over 1.65V, the most significant bit was hard-coded to 0 (connected to ground). This DAC only gives three bits of precision (for a total of 8 states of that joystick), however, because it is used for the strafe axis (arguably the one with the least need for precision), the user usually will not notice this limitation.
To actually connect these software-controllable analog values to the Xbox 360 controller, both analog joysticks were removed (desoldered) from the controller PCB and in place of the middle pin contacts (recall that an analog joystick is simply a potentiometer) we soldered a wire leading to one of the four analog outputs above.
To implement software-controllable buttons without the need to manipulate and implement the matrix layout of the Xbox 360 controller in software on the mbed, we elected to implement each button as a relay. A relay is an electrically-controlled switch in which driving a current through an electromagnet closes a mechanical switch. These relays are controlled using GPIO pins on the mbed (the current draw is immeasurably small). On the Xbox 360 controller, we scraped away each button contact with a blade to reach the copper underneath, and soldered a wire to each contact (two per button). The wires for each button were then connected across the terminals of a relay that is controlled by the mbed. Therefore, if we want to make a connection that presses the ‘A’ button from the mbed, all we need to do is turn the corresponding GPIO pin to high, which will close the switch inside the relay, and convince the controller that the ‘A’ button is being pressed. For brevity and clarity of important details, only one button’s implementation is shown above. However, it is important to note that one relay, one GPIO pin, and two wire leads to the Xbox 360 controller are necessary for each button that you wish to control.
Note that while we implement the two triggers as binary (on or off) switches, because these are analog triggers on the Xbox 360 controller, they each have their own dedicated line, and we can merely drive this line to the desired voltage. Because the mbed uses 3.3V levels, and the trigger is designed to vary between 1.65V (unpressed) and 0.3V (pressed, will work properly if given 0V as well), we use the voltage divider shown above on the trigger output pins (p15 and p16 for RT and LT, respectively), which gives a value of 1.65V to the controller contact when the output pin is high (assuming a low current draw from the output) and 0V when the input is low.
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
A picture of the completed receiver can be seen in the first picture below. This picture highlights the relays, DACs, mbed, and XBee wireless module. The second gives a close-up of the Xbox 360 controller PCB.
No comments:
Post a Comment