2012-12-30

Arcade Stick


The arcade stick is done!!!!!
:D


Basic Operations
1. Controller reads the inputs from the joystick and the push buttons
2. Controller sends this information to the PC via serial communication
(well... using ftdi so virtual serial communication...)
3. The PC-side receiver translates this information into other useful instructions for the PC

I am using PIC 16F876a microcontroller as the controller
and a software written in MATLAB as the receiver.


For More Information

Check out the following posts:



Videos

Using the stick as a mouse:
Using the stick as an arcade stick:


By Joe Kwuen

2012-12-28

Arcade Stick: Receiver


This post contains extra details on the receiver of my arcade stick.
PC receives and translates serial data from the controller using MATLAB and JAVA robot class.
I have programmed to operate my stick normally as an arcade stick, and also as a mouse.
In this post I will provide enough hints for anyone to use MATLAB for such purpose.


MATLAB Serial Communication Problem

I noticed many people including me were having problem with MATLAB's serial communication module.

DO THIS BEFORE ANYTHING ELSE!

The following code most likely will fix whatever problem you are having.
priorPorts = instrfind
delete(priorPorts)

MATLAB's serial communication apparently does not work well when there are any... 
(even the closed ports) 
previously declared ports.
The above code just finds and deletes the memory previously allocated for them.

Some useful MATLAB functions are:
serial
fopen
serial.BytesAvailable 
fread


JAVA Robot

first import the class for simplifications later on
import java.awt.Robot;
import java.awt.event.*;
import java.awt.event.KeyEvent;

make a robot class
robot = Robot;

have fun :D

key simulation:
if (sw1 ~= sw10)
if(sw1 == 1)
robot.keyPress(java.awt.event.KeyEvent.VK_H);
robot.delay(20);
else
robot.keyRelease(java.awt.event.KeyEvent.VK_H);
robot.delay(20);
end
sw10 = sw1;
end

The delay of 20 ms simulates how actual keyboard works. 
A keypress function must be released else it will be like a stuck key.

mouse simulation:
pos = get(0, 'PointerLocation');
x_pos = pos(1)+speed;
y_pos = 768-pos(2)+speed;
mouse.mouseMove(x_pos, y_pos);

Read pointer location and move the mouse. 
You can set sensitivity by changing the speed variable.
The first line is included such that you may use your real mouse as well as the joystick to simultaneously move the mouse cursor.



By Joe Kwuen

Arcade Stick - Controller

This post contains extra details on the controller of my arcade stick.
The controller side of the Arcade Stick is fairly simple.
It is just a microcontroller - PIC 16F876a programmed using MPLAB with CCS C compiler.

During the main loop the controller
1. Reads the status of input ports
2. Organizes the info
3. Decides whether to send the info to the PC or not


Checking for Updates
pretty straight forward - just digital reads...


Organization
Just two bytes of information sending to the PC:
1 byte of joystick info
1 byte of push button info

The first byte consists of
0 - 0 - 0 - 0 - LEFT? - RIGHT? - DOWN? - UP?
there are four bits of zeroes as fillers because I am using 8N1 serial communication.
The other four bits are assigned to each direction.
For example, 0x08 = left and 0x0A = Left-Down

The second byte consists of
SW7 - SW6 - SW5 - ...
I guess it's self-explanatary that I am using each bit to indicate each switch.


Decision...
The following code is being used to decide whether to send the info or not:

if(old_dir != new_dir || old_sw != sw)
{
putchar(new_dir);
putchar(sw);
old_dir = new_dir;
old_sw = sw;
}

The controller sends info only when the inputs have changed.

This greatly simplifies the PC software and improves the operation of the arcade stick.



By Joe Kwuen

2012-11-20

Arcade Stick #1

This is the first posting on the arcade stick I am working on.
I play a lot of fighting games; yet I still don't have a descent fighting stick.
That is why I decided to make my own.

The components of this project are:
8 Push-Buttons
1 Joystick
Indicator Lights to Help Improve my Gaming Skills
Digital Controls to Provide Accurate and Fast Responses from the Inputs
USB Connection
C# User Interface

I finished the top side of my arcade stick.
It is made out of heavy cardboard, and plexiglass.
I used my school mechanic shop for drilling and etc.

I began testing just the direction controls on breadboard.
When I finish them
then I will start adding more circuitry and coding for the other inputs.

Anyways
I am posting a video of my arcade stick so far:



By Joe Kwuen

NOT AVAILABLE


INFO ON THIS PROJECT IS NOT AVAILABLE!

THIS MAY BE BECAUSE IT WAS
A SPONSORED PROJECT.

PLEASE CONTACT ME IF YOU NEED MORE INFO


By Joe Kwuen