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...

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.

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

if(old_dir != new_dir || old_sw != 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

No comments:

Post a Comment