| PS2 Robot
Control: Establishing Communication.
02.03.04 By Beth Frye. Establishing a fast and reliable connection between a Sony-brand PS2 controller and the Basic Atom processor. (The Basic Stamp 2 processor cannot properly read the left vertical joystick.) |
![]() Too cool! |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Step 1. Solder a 1K ohm pull-up resistor onto the Next Step processor board as shown. This connects from I/O pin 4 to the 5vdc line. This is the Data line. On some controllers, a pull-up will also be required on the Clock line, which is I/O pin 7. The Buttons and LEDs will not be useable in this configuration. | ![]() Figure 1-1. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Step 2.
Plug in the PS2 cable as shown. Be extremely
careful to observe polarity on the power connector. Black is ground and
yellow is +5vdc. The black wire is actually the red/shield with black heat
shrink covering them. Figure 2-1 shows what each of the PS2 cable wires
are.
|
![]() Figure 2-2. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Step 3. Copy & paste the program from below into the editor and program the Basic Atom. After the program is running, click on the Terminal1 tab (item #28 in Figure 3-1 below). Change the Baud Rate to 57.6kbs (item #1). Then click Connect (item #6). If all is well, you should see numbers similar to the ones shown. Note that the program automatically puts the controller in Analog mode. Refer to Table 3-1 for a description of the bytes returned by the PS2 controller. Note that items 8 and 9 are the Digital representation of button presses. Refer to Table 3-2 for a Bit representation of button presses. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Table 3-2 and 3-3
illustrate which bits go low when the corresponding button is pressed. The arrow buttons are on what is commonly called the "D-Pad," which is the button pad on the left. L3 and R3 are the little-known Left and Right joystick buttons; trigger these by pressing down on the joysticks. R1, R2, L1, and L2 are the "shoulder buttons," that is, they are located on the controller's "shoulders." |
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
The
two analog joysticks on a Sony-brand controller will not neatly return to
a middle value of 128. The following value ranges are what the joysticks
have been known to return to.
If you need extreme accuracy with the analog joysticks, go with a Madcatz-brand controller. I've used a wireless Madcatz Lynx controller (coincidence, really!) with perfect analog joystick accuracy. They always returned to the middle value of 128. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Step 4. Code by
Nathan Scherdin. As a demonstration of the internal vibrating motors, the
following program turns on the motors with button presses. For example,
the smaller motor is turned on by the
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||